For a while there was a bug in anv which meant that the interpolate functions wouldn’t work if the thing being interpolated contained a vertex component selector. Adding these tests will help make sure we don’t regress that.
See: https://patchwork.freedesktop.org/patch/237095/ --- .../interpolate-aoa-dynamic.vk_shader_test | 84 +++++++++++++++++++ .../glsl450/interpolate-aoa.vk_shader_test | 69 +++++++++++++++ .../interpolate-at-centroid.vk_shader_test | 68 +++++++++++++++ .../interpolate-at-offset.vk_shader_test | 72 ++++++++++++++++ .../interpolate-at-sample.vk_shader_test | 69 +++++++++++++++ 5 files changed, 362 insertions(+) create mode 100644 tests/vulkan/glsl450/interpolate-aoa-dynamic.vk_shader_test create mode 100644 tests/vulkan/glsl450/interpolate-aoa.vk_shader_test create mode 100644 tests/vulkan/glsl450/interpolate-at-centroid.vk_shader_test create mode 100644 tests/vulkan/glsl450/interpolate-at-offset.vk_shader_test create mode 100644 tests/vulkan/glsl450/interpolate-at-sample.vk_shader_test diff --git a/tests/vulkan/glsl450/interpolate-aoa-dynamic.vk_shader_test b/tests/vulkan/glsl450/interpolate-aoa-dynamic.vk_shader_test new file mode 100644 index 000000000..ad21fc0b4 --- /dev/null +++ b/tests/vulkan/glsl450/interpolate-aoa-dynamic.vk_shader_test @@ -0,0 +1,84 @@ +# GLSL 4.40 changed the relevant language in Section 8.13.2 (Interpolation +# Functions) to: +# +# "Component selection operators (e.g., .xy) may be used when specifying +# interpolant." +# +# Furthermore, GLSL 4.60 clarified that +# +# "(...) interpolant must be an l-value from an in declaration; this can +# include a variable, a block or structure member, an array element, or +# some combination of these." +# +# which means array subscripts on vectors should also be allowed. +# + +[vertex shader] +#version 440 + +layout(location = 0) in vec4 piglit_vertex; +layout(location = 1) in uvec2 indices_in; + +layout(location = 0) out vec2 a[2]; +layout(location = 2) flat out uvec2 indices_out; + +void main() +{ + gl_Position = piglit_vertex; + + a[0] = vec2(0.25, 0.5); + a[1] = vec2(0.75, 1.0); + indices_out = indices_in; +} + +[fragment shader] +#version 440 + +layout(location = 0) in vec2 a[2]; +layout(location = 2) flat in uvec2 indices; + +layout(location = 0) out vec4 color; + +void main() +{ + color.rgb = vec3(interpolateAtCentroid(a[indices.x][indices.y])); + color.a = 1.0; +} + +[indices] +0 1 2 2 1 3 +4 5 6 6 5 7 +8 9 10 10 9 11 +12 13 14 14 13 15 + +[vertex data] +0/R32G32_SFLOAT 1/R32G32_UINT +-1.0 -1.0 0 0 + 0.0 -1.0 0 0 +-1.0 0.0 0 0 + 0.0 0.0 0 0 + + 0.0 -1.0 0 1 + 1.0 -1.0 0 1 + 0.0 0.0 0 1 + 1.0 0.0 0 1 + +-1.0 0.0 1 0 + 0.0 0.0 1 0 +-1.0 1.0 1 0 + 0.0 1.0 1 0 + + 0.0 0.0 1 1 + 1.0 0.0 1 1 + 0.0 1.0 1 1 + 1.0 1.0 1 1 + +[test] +clear + +draw arrays indexed TRIANGLE_LIST 0 24 + +relative probe rect rgb (0, 0, 0.5, 0.5) (0.25, 0.25, 0.25) +relative probe rect rgb (0.5, 0, 0.5, 0.5) (0.5, 0.5, 0.5) +relative probe rect rgb (0, 0.5, 0.5, 0.5) (0.75, 0.75, 0.75) +relative probe rect rgb (0.5, 0.5, 0.5, 0.5) (1.0, 1.0, 1.0) diff --git a/tests/vulkan/glsl450/interpolate-aoa.vk_shader_test b/tests/vulkan/glsl450/interpolate-aoa.vk_shader_test new file mode 100644 index 000000000..6ea5f6c04 --- /dev/null +++ b/tests/vulkan/glsl450/interpolate-aoa.vk_shader_test @@ -0,0 +1,69 @@ +# GLSL 4.40 changed the relevant language in Section 8.13.2 (Interpolation +# Functions) to: +# +# "Component selection operators (e.g., .xy) may be used when specifying +# interpolant." +# +# Furthermore, GLSL 4.60 clarified that +# +# "(...) interpolant must be an l-value from an in declaration; this can +# include a variable, a block or structure member, an array element, or +# some combination of these." +# +# which means array subscripts on vectors should also be allowed. +# + +[vertex shader] +#version 440 + +layout(location = 0) in vec4 piglit_vertex; + +layout(location = 0) out vec3 a[2]; + +void main() +{ + gl_Position = piglit_vertex; + + a[0] = piglit_vertex.xyz; + a[1] = vec3(1.0); +} + +[fragment shader] +#version 440 + +layout(location = 0) in vec3 a[2]; + +layout(std140, push_constant) uniform block { + int u_idx; +}; + +layout(location = 0) out vec4 color; + +void main() +{ + vec2 delta1 = a[0].yx - interpolateAtCentroid(a[0].yx); + float delta2 = a[0][2] - interpolateAtCentroid(a[0][2]); + float delta3 = a[0][u_idx] - interpolateAtCentroid(a[0][u_idx]); + + if (delta1 != vec2(0.0)) { + color = vec4(0.1, delta1.x + 0.5, delta1.y + 0.5, 0.0); + } else if (delta2 != 0.0) { + color = vec4(0.2, delta2 + 0.5, 0.0, 0.0); + } else if (delta3 != 0.0) { + color = vec4(0.3, delta3 + 0.5, 0.0, 0.0); + } else { + color = vec4(0.0, 1.0, 0.0, 1.0); + } +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear + +uniform int 0 0 +draw rect -1 -1 1 2 + +uniform int 0 1 +draw rect 0 -1 1 2 + +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/vulkan/glsl450/interpolate-at-centroid.vk_shader_test b/tests/vulkan/glsl450/interpolate-at-centroid.vk_shader_test new file mode 100644 index 000000000..f59c231b1 --- /dev/null +++ b/tests/vulkan/glsl450/interpolate-at-centroid.vk_shader_test @@ -0,0 +1,68 @@ +# GLSL 4.40 changed the relevant language in Section 8.13.2 (Interpolation +# Functions) to: +# +# "Component selection operators (e.g., .xy) may be used when specifying +# interpolant." +# +# Furthermore, GLSL 4.60 clarified that +# +# "(...) interpolant must be an l-value from an in declaration; this can +# include a variable, a block or structure member, an array element, or +# some combination of these." +# +# which means array subscripts on vectors should also be allowed. +# + +[vertex shader] +#version 440 + +layout(location = 0) in vec4 piglit_vertex; + +layout(location = 0) out vec3 a; + +void main() +{ + gl_Position = piglit_vertex; + + a = piglit_vertex.xyz; +} + +[fragment shader] +#version 440 + +layout(location = 0) in vec3 a; + +layout(std140, push_constant) uniform block { + int u_idx; +}; + +layout(location = 0) out vec4 color; + +void main() +{ + vec2 delta1 = a.yx - interpolateAtCentroid(a.yx); + float delta2 = a[2] - interpolateAtCentroid(a[2]); + float delta3 = a[u_idx] - interpolateAtCentroid(a[u_idx]); + + if (delta1 != vec2(0.0)) { + color = vec4(0.1, delta1.x + 0.5, delta1.y + 0.5, 0.0); + } else if (delta2 != 0.0) { + color = vec4(0.2, delta2 + 0.5, 0.0, 0.0); + } else if (delta3 != 0.0) { + color = vec4(0.3, delta3 + 0.5, 0.0, 0.0); + } else { + color = vec4(0.0, 1.0, 0.0, 1.0); + } +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear + +uniform int 0 0 +draw rect -1 -1 1 2 + +uniform int 0 1 +draw rect 0 -1 1 2 + +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/vulkan/glsl450/interpolate-at-offset.vk_shader_test b/tests/vulkan/glsl450/interpolate-at-offset.vk_shader_test new file mode 100644 index 000000000..a41243bd8 --- /dev/null +++ b/tests/vulkan/glsl450/interpolate-at-offset.vk_shader_test @@ -0,0 +1,72 @@ +# GLSL 4.40 changed the relevant language in Section 8.13.2 (Interpolation +# Functions) to: +# +# "Component selection operators (e.g., .xy) may be used when specifying +# interpolant." +# +# Furthermore, GLSL 4.60 clarified that +# +# "(...) interpolant must be an l-value from an in declaration; this can +# include a variable, a block or structure member, an array element, or +# some combination of these." +# +# which means array subscripts on vectors should also be allowed. +# + +[vertex shader] +#version 440 + +layout(location = 0) in vec4 piglit_vertex; + +layout(location = 0) out vec3 a; + +void main() +{ + gl_Position = piglit_vertex; + + a = piglit_vertex.xyz; +} + +[fragment shader] +#version 440 + +layout(location = 0) in vec3 a; + +layout(std140, push_constant) uniform block { + int u_idx; + uniform vec2 u_offset; +}; + +layout(location = 0) out vec4 color; + +void main() +{ + /* u_offset is always 0, so these should all be the same. */ + vec2 delta1 = a.yx - interpolateAtOffset(a.yx, u_offset); + float delta2 = a[2] - interpolateAtOffset(a[2], u_offset); + float delta3 = a[u_idx] - interpolateAtOffset(a[u_idx], u_offset); + + if (delta1 != vec2(0.0)) { + color = vec4(0.1, delta1.x + 0.5, delta1.y + 0.5, 0.0); + } else if (delta2 != 0.0) { + color = vec4(0.2, delta2 + 0.5, 0.0, 0.0); + } else if (delta3 != 0.0) { + color = vec4(0.3, delta3 + 0.5, 0.0, 0.0); + } else { + color = vec4(0.0, 1.0, 0.0, 1.0); + } +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear + +uniform vec2 8 0 0 + +uniform int 0 0 +draw rect -1 -1 1 2 + +uniform int 0 1 +draw rect 0 -1 1 2 + +probe all rgba 0.0 1.0 0.0 1.0 diff --git a/tests/vulkan/glsl450/interpolate-at-sample.vk_shader_test b/tests/vulkan/glsl450/interpolate-at-sample.vk_shader_test new file mode 100644 index 000000000..088a452d8 --- /dev/null +++ b/tests/vulkan/glsl450/interpolate-at-sample.vk_shader_test @@ -0,0 +1,69 @@ +# GLSL 4.40 changed the relevant language in Section 8.13.2 (Interpolation +# Functions) to: +# +# "Component selection operators (e.g., .xy) may be used when specifying +# interpolant." +# +# Furthermore, GLSL 4.60 clarified that +# +# "(...) interpolant must be an l-value from an in declaration; this can +# include a variable, a block or structure member, an array element, or +# some combination of these." +# +# which means array subscripts on vectors should also be allowed. +# + +[vertex shader] +#version 440 + +layout(location = 0) in vec4 piglit_vertex; + +layout(location = 0) out vec3 a; + +void main() +{ + gl_Position = piglit_vertex; + + a = piglit_vertex.xyz; +} + +[fragment shader] +#version 440 + +layout(location = 0) in vec3 a; + +layout(std140, push_constant) uniform block { + int u_idx; +}; + +layout(location = 0) out vec4 color; + +void main() +{ + /* There is no multi-sampling, so these should all be the same. */ + vec2 delta1 = a.yx - interpolateAtSample(a.yx, 0); + float delta2 = a[2] - interpolateAtSample(a[2], 0); + float delta3 = a[u_idx] - interpolateAtSample(a[u_idx], 0); + + if (delta1 != vec2(0.0)) { + color = vec4(0.1, delta1.x + 0.5, delta1.y + 0.5, 0.0); + } else if (delta2 != 0.0) { + color = vec4(0.2, delta2 + 0.5, 0.0, 0.0); + } else if (delta3 != 0.0) { + color = vec4(0.3, delta3 + 0.5, 0.0, 0.0); + } else { + color = vec4(0.0, 1.0, 0.0, 1.0); + } +} + +[test] +clear color 0.0 0.0 0.0 0.0 +clear + +uniform int 0 0 +draw rect -1 -1 1 2 + +uniform int 0 1 +draw rect 0 -1 1 2 + +probe all rgba 0.0 1.0 0.0 1.0 -- 2.17.1 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit