diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-06-14 08:35:43 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-06-14 08:35:43 -0700 |
| commit | 34c7cdc68fd5b7b8132250c4de0d562c9ba0adbb (patch) | |
| tree | 6e2308639ac3205fb7a8760ff61def7779352699 | |
| parent | 604e0fc8dc859e5d3954fd1e074e5288659cb439 (diff) | |
Testing: Adding binding-generation tests for some GLSL shaders
Most of the Vulkan GLSL shaders in the `sascha-willems` corpus use completely regular parameter bindings, e.g.:
```
layout (binding = 0) uniform sampler2D samplerPositionDepth;
layout (binding = 1) uniform sampler2D samplerNormal;
layout (binding = 2) uniform sampler2D ssaoNoise;
```
With the Slang compiler, we can write this kind of stuff more compactly as:
```
uniform sampler2D samplerPositionDepth;
uniform sampler2D samplerNormal;
uniform sampler2D ssaoNoise;
```
and get the exact same result (in fact, we will generate output GLSL matching the first example).
There are a few spot tests for this in the HLSL case, but I hadn't done anything for GLSL yet.
Now that we have the ability to specify multiple tests to run on each input file, it was easy enough to go in and tweak some of these files to be usable as binding-generation tests.
I didn't ammend all of the GLSL shaders for two reasons:
1. Not all of the shaders will work with completely automatic binding generation done on a per-file basis. In some cases, the parameter layout needs to consider multiple files (and the order in which the files are supplied could matter). This is probably best handled with more directed tests.
2. There is going to be a ton of duplication if I just have 100s of tests that all confirm that, yes, the Slang compiler can count vertex inputs starting from zero. These shaders aren't really presenting a whole lot of unique cases to work with.
That said, a level of confidence greater than zero is always better than zero confidence.
| -rw-r--r-- | .gitignore | 12 | ||||
| -rw-r--r-- | tests/glsl/sascha-willems/base/textoverlay.frag | 13 | ||||
| -rw-r--r-- | tests/glsl/sascha-willems/base/textoverlay.vert | 13 | ||||
| -rw-r--r-- | tests/glsl/sascha-willems/bloom/phongpass.vert | 27 | ||||
| -rw-r--r-- | tests/glsl/sascha-willems/ssao/ssao.frag | 23 |
5 files changed, 55 insertions, 33 deletions
diff --git a/.gitignore b/.gitignore index a0a57b5aa..e62d06013 100644 --- a/.gitignore +++ b/.gitignore @@ -10,15 +10,9 @@ intermediate/ # files generated by test runner *.actual -*.hlsl.expected -*.fx.expected -*.glsl.expected -*.vert.expected -*.frag.expected -*.geom.expected -*.tesc.expected -*.tese.expected -*.comp.expected +*.expected +!*.slang.expected +!*.slang.*.expected *.expected.png *.actual.png diff --git a/tests/glsl/sascha-willems/base/textoverlay.frag b/tests/glsl/sascha-willems/base/textoverlay.frag index e5dbb08de..c77198765 100644 --- a/tests/glsl/sascha-willems/base/textoverlay.frag +++ b/tests/glsl/sascha-willems/base/textoverlay.frag @@ -1,11 +1,18 @@ #version 450 core //TEST:COMPARE_GLSL: +//TEST:COMPARE_GLSL:-DBINDING -layout (location = 0) in vec2 inUV; +#if defined(__SLANG__) && defined(BINDING) +#define LAYOUT(X) /* empty */ +#else +#define LAYOUT(X) layout(X) +#endif -layout (binding = 0) uniform sampler2D samplerFont; +LAYOUT(location = 0) in vec2 inUV; -layout (location = 0) out vec4 outFragColor; +LAYOUT(binding = 0) uniform sampler2D samplerFont; + +LAYOUT(location = 0) out vec4 outFragColor; void main(void) { diff --git a/tests/glsl/sascha-willems/base/textoverlay.vert b/tests/glsl/sascha-willems/base/textoverlay.vert index 8a20fd8b2..5d5dacab6 100644 --- a/tests/glsl/sascha-willems/base/textoverlay.vert +++ b/tests/glsl/sascha-willems/base/textoverlay.vert @@ -1,10 +1,17 @@ #version 450 core //TEST:COMPARE_GLSL: +//TEST:COMPARE_GLSL:-DBINDING -layout (location = 0) in vec2 inPos; -layout (location = 1) in vec2 inUV; +#if defined(__SLANG__) && defined(BINDING) +#define LAYOUT(X) /* empty */ +#else +#define LAYOUT(X) layout(X) +#endif -layout (location = 0) out vec2 outUV; +LAYOUT(location = 0) in vec2 inPos; +LAYOUT(location = 1) in vec2 inUV; + +LAYOUT(location = 0) out vec2 outUV; out gl_PerVertex { diff --git a/tests/glsl/sascha-willems/bloom/phongpass.vert b/tests/glsl/sascha-willems/bloom/phongpass.vert index ac0a77ab9..a3c77cb48 100644 --- a/tests/glsl/sascha-willems/bloom/phongpass.vert +++ b/tests/glsl/sascha-willems/bloom/phongpass.vert @@ -1,26 +1,33 @@ #version 450 //TEST:COMPARE_GLSL: +//TEST:COMPARE_GLSL:-DBINDING + +#if defined(__SLANG__) && defined(BINDING) +#define LAYOUT(X) /* empty */ +#else +#define LAYOUT(X) layout(X) +#endif #extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_shading_language_420pack : enable -layout (location = 0) in vec4 inPos; -layout (location = 1) in vec2 inUV; -layout (location = 2) in vec3 inColor; -layout (location = 3) in vec3 inNormal; +LAYOUT(location = 0) in vec4 inPos; +LAYOUT(location = 1) in vec2 inUV; +LAYOUT(location = 2) in vec3 inColor; +LAYOUT(location = 3) in vec3 inNormal; -layout (binding = 0) uniform UBO +LAYOUT(binding = 0) uniform UBO { mat4 projection; mat4 view; mat4 model; } ubo; -layout (location = 0) out vec3 outNormal; -layout (location = 1) out vec2 outUV; -layout (location = 2) out vec3 outColor; -layout (location = 3) out vec3 outViewVec; -layout (location = 4) out vec3 outLightVec; +LAYOUT(location = 0) out vec3 outNormal; +LAYOUT(location = 1) out vec2 outUV; +LAYOUT(location = 2) out vec3 outColor; +LAYOUT(location = 3) out vec3 outViewVec; +LAYOUT(location = 4) out vec3 outLightVec; out gl_PerVertex { diff --git a/tests/glsl/sascha-willems/ssao/ssao.frag b/tests/glsl/sascha-willems/ssao/ssao.frag index cdcbfd3ec..ef0035013 100644 --- a/tests/glsl/sascha-willems/ssao/ssao.frag +++ b/tests/glsl/sascha-willems/ssao/ssao.frag @@ -1,29 +1,36 @@ -//TEST:COMPARE_GLSL: #version 450 +//TEST:COMPARE_GLSL: +//TEST:COMPARE_GLSL:-DBINDING + +#if defined(__SLANG__) && defined(BINDING) +#define LAYOUT(X) /* empty */ +#else +#define LAYOUT(X) layout(X) +#endif #extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_shading_language_420pack : enable -layout (binding = 0) uniform sampler2D samplerPositionDepth; -layout (binding = 1) uniform sampler2D samplerNormal; -layout (binding = 2) uniform sampler2D ssaoNoise; +LAYOUT(binding = 0) uniform sampler2D samplerPositionDepth; +LAYOUT(binding = 1) uniform sampler2D samplerNormal; +LAYOUT(binding = 2) uniform sampler2D ssaoNoise; layout (constant_id = 0) const int SSAO_KERNEL_SIZE = 64; layout (constant_id = 1) const float SSAO_RADIUS = 0.5; -layout (binding = 3) uniform UBOSSAOKernel +LAYOUT(binding = 3) uniform UBOSSAOKernel { vec4 samples[SSAO_KERNEL_SIZE]; } uboSSAOKernel; -layout (binding = 4) uniform UBO +LAYOUT(binding = 4) uniform UBO { mat4 projection; } ubo; -layout (location = 0) in vec2 inUV; +LAYOUT(location = 0) in vec2 inUV; -layout (location = 0) out float outFragColor; +LAYOUT(location = 0) out float outFragColor; void main() { |
