The initial arb_bindless_texture-uniform wasn't totally correct
after getting a confirmation from Jeff Bolz (NVIDIA).

The spec allows setting a bindless sampler uniform with either
glUniformi1*() or glUniformHandle*(), while a bound sampler
uniform can only be set using glUniform1*().

Signed-off-by: Samuel Pitoiset <[email protected]>
---
 tests/spec/arb_bindless_texture/uniform.c | 157 +++++++++++++++++++++++++++---
 1 file changed, 141 insertions(+), 16 deletions(-)

diff --git a/tests/spec/arb_bindless_texture/uniform.c 
b/tests/spec/arb_bindless_texture/uniform.c
index c4c06df05..3d7b0ad7c 100644
--- a/tests/spec/arb_bindless_texture/uniform.c
+++ b/tests/spec/arb_bindless_texture/uniform.c
@@ -61,6 +61,18 @@ static const char *fs_explicit_bound_sampler =
        "       color = texture(tex, vec2(0, 0));\n"
        "}\n";
 
+static const char *fs_explicit_bindless_sampler =
+       "#version 330\n"
+       "#extension GL_ARB_bindless_texture: require\n"
+       "\n"
+       "layout (bindless_sampler) uniform sampler2D tex;\n"
+       "out vec4 color;\n"
+       "\n"
+       "void main()\n"
+       "{\n"
+       "       color = texture(tex, vec2(0, 0));\n"
+       "}\n";
+
 static const char *fs_implicit_bound_sampler =
        "#version 330\n"
        "#extension GL_ARB_bindless_texture: require\n"
@@ -86,6 +98,19 @@ static const char *fs_explicit_bound_image =
        "       imageStore(img, ivec2(0, 0), color);\n"
        "}\n";
 
+static const char *fs_explicit_bindless_image =
+       "#version 330\n"
+       "#extension GL_ARB_bindless_texture: require\n"
+       "#extension GL_ARB_shader_image_load_store: enable\n"
+       "\n"
+       "layout (bindless_image) writeonly uniform image2D img;\n"
+       "out vec4 color;\n"
+       "\n"
+       "void main()\n"
+       "{\n"
+       "       imageStore(img, ivec2(0, 0), color);\n"
+       "}\n";
+
 static const char *fs_implicit_bound_image =
        "#version 330\n"
        "#extension GL_ARB_bindless_texture: require\n"
@@ -134,7 +159,7 @@ check_UniformHandleui64_with_explicit_bound_sampler(void 
*data)
 }
 
 static enum piglit_result
-check_UniformHandleui64_with_implicit_bound_sampler(void *data)
+check_Uniform_with_explicit_bindless_sampler(void *data)
 {
        GLuint vs, fs, prog;
        GLuint64 handle = 0;
@@ -142,7 +167,7 @@ check_UniformHandleui64_with_implicit_bound_sampler(void 
*data)
 
        vs = piglit_compile_shader_text(GL_VERTEX_SHADER, passthrough_vs_src);
        fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER,
-                                       fs_implicit_bound_sampler);
+                                       fs_explicit_bindless_sampler);
        prog = piglit_link_simple_program(vs, fs);
        glUseProgram(prog);
 
@@ -152,10 +177,12 @@ check_UniformHandleui64_with_implicit_bound_sampler(void 
*data)
 
        /* The ARB_bindless_texture spec says:
         *
-        * "When used as uniforms in the default block, the value of sampler
-        *  variables may be specified with either Uniform1i{v} or
-        *  UniformHandleui64{v}ARB."
+        * "These modifiers control whether default-block uniforms of the
+        *  corresponding types may have their values set via both
+        *  UniformHandle* and Uniform1i (bindless_sampler and bindless_image)
+        *  or only via Uniform1i (bound_sampler and bound_image)."
         */
+       glUniform1i(loc, 5);
        glUniformHandleui64ARB(loc, handle);
        glProgramUniformHandleui64vARB(prog, loc, 1, &handle);
        if (!piglit_check_gl_error(GL_NO_ERROR))
@@ -165,6 +192,48 @@ check_UniformHandleui64_with_implicit_bound_sampler(void 
*data)
 }
 
 static enum piglit_result
+check_Uniform_with_implicit_bound_sampler(void *data)
+{
+       GLuint vs, fs, prog;
+       GLuint64 handle = 0;
+       GLint loc;
+
+       vs = piglit_compile_shader_text(GL_VERTEX_SHADER, passthrough_vs_src);
+       fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER,
+                                       fs_implicit_bound_sampler);
+       prog = piglit_link_simple_program(vs, fs);
+       glUseProgram(prog);
+
+       loc = glGetUniformLocation(prog, "tex");
+       if (loc == -1)
+               return PIGLIT_FAIL;
+
+       /* The ARB_bindless_texture spec says:
+        *
+        * "These modifiers control whether default-block uniforms of the
+        *  corresponding types may have their values set via both
+        *  UniformHandle* and Uniform1i (bindless_sampler and bindless_image)
+        *  or only via Uniform1i (bound_sampler and bound_image)."
+        *
+        * "In the absence of these qualifiers, sampler and image uniforms are
+        *  considered "bound"."
+        */
+       glUniform1i(loc, 5);
+       if (!piglit_check_gl_error(GL_NO_ERROR))
+               return PIGLIT_FAIL;
+
+       glUniformHandleui64ARB(loc, handle);
+       if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+               return PIGLIT_FAIL;
+
+       glProgramUniformHandleui64vARB(prog, loc, 1, &handle);
+       if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+               return PIGLIT_FAIL;
+
+       return PIGLIT_PASS;
+}
+
+static enum piglit_result
 check_UniformHandleui64_with_explicit_bound_image(void *data)
 {
        GLuint vs, fs, prog;
@@ -199,7 +268,7 @@ check_UniformHandleui64_with_explicit_bound_image(void 
*data)
 }
 
 static enum piglit_result
-check_UniformHandleui64_with_implicit_bound_image(void *data)
+check_Uniform_with_explicit_bindless_image(void *data)
 {
        GLuint vs, fs, prog;
        GLuint64 handle = 0;
@@ -207,7 +276,7 @@ check_UniformHandleui64_with_implicit_bound_image(void 
*data)
 
        vs = piglit_compile_shader_text(GL_VERTEX_SHADER, passthrough_vs_src);
        fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER,
-                                       fs_implicit_bound_image);
+                                       fs_explicit_bindless_image);
        prog = piglit_link_simple_program(vs, fs);
        glUseProgram(prog);
 
@@ -217,10 +286,12 @@ check_UniformHandleui64_with_implicit_bound_image(void 
*data)
 
        /* The ARB_bindless_texture spec says:
         *
-        * "When used as uniforms in the default block, the value of sampler
-        *  variables may be specified with either Uniform1i{v} or
-        *  UniformHandleui64{v}ARB."
+        * "These modifiers control whether default-block uniforms of the
+        *  corresponding types may have their values set via both
+        *  UniformHandle* and Uniform1i (bindless_sampler and bindless_image)
+        *  or only via Uniform1i (bound_sampler and bound_image)."
         */
+       glUniform1i(loc, 5);
        glUniformHandleui64ARB(loc, handle);
        glProgramUniformHandleui64vARB(prog, loc, 1, &handle);
        if (!piglit_check_gl_error(GL_NO_ERROR))
@@ -230,6 +301,48 @@ check_UniformHandleui64_with_implicit_bound_image(void 
*data)
 }
 
 static enum piglit_result
+check_Uniform_with_implicit_bound_image(void *data)
+{
+       GLuint vs, fs, prog;
+       GLuint64 handle = 0;
+       GLint loc;
+
+       vs = piglit_compile_shader_text(GL_VERTEX_SHADER, passthrough_vs_src);
+       fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER,
+                                       fs_implicit_bound_image);
+       prog = piglit_link_simple_program(vs, fs);
+       glUseProgram(prog);
+
+       loc = glGetUniformLocation(prog, "img");
+       if (loc == -1)
+               return PIGLIT_FAIL;
+
+       /* The ARB_bindless_texture spec says:
+        *
+        * "These modifiers control whether default-block uniforms of the
+        *  corresponding types may have their values set via both
+        *  UniformHandle* and Uniform1i (bindless_sampler and bindless_image)
+        *  or only via Uniform1i (bound_sampler and bound_image)."
+        *
+        * "In the absence of these qualifiers, sampler and image uniforms are
+        *  considered "bound"."
+        */
+       glUniform1i(loc, 5);
+       if (!piglit_check_gl_error(GL_NO_ERROR))
+               return PIGLIT_FAIL;
+
+       glUniformHandleui64ARB(loc, handle);
+       if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+               return PIGLIT_FAIL;
+
+       glProgramUniformHandleui64vARB(prog, loc, 1, &handle);
+       if (!piglit_check_gl_error(GL_INVALID_OPERATION))
+               return PIGLIT_FAIL;
+
+       return PIGLIT_PASS;
+}
+
+static enum piglit_result
 use_glGetActiveUniform_with_sampler(void *data)
 {
        GLuint vs, fs, prog;
@@ -308,9 +421,15 @@ static const struct piglit_subtest subtests[] = {
                NULL
        },
        {
-               "Check glUniformHandleui64*ARB() with implicit bound_sampler",
-               "check_UniformHandleui64_with_implicit_bound_sampler",
-               check_UniformHandleui64_with_implicit_bound_sampler,
+               "Check glUniform*() with explicit bindless_sampler",
+               "check_Uniform_with_explicit_bindless_sampler",
+               check_Uniform_with_explicit_bindless_sampler,
+               NULL
+       },
+       {
+               "Check glUniform*() with implicit bound_sampler",
+               "check_Uniform_with_implicit_bound_sampler",
+               check_Uniform_with_implicit_bound_sampler,
                NULL
        },
        {
@@ -320,9 +439,15 @@ static const struct piglit_subtest subtests[] = {
                NULL
        },
        {
-               "Check glUniformHandleui64*ARB() with implicit bound_image",
-               "check_UniformHandleui64_with_implicit_bound_image",
-               check_UniformHandleui64_with_implicit_bound_image,
+               "Check glUniform*() with explicit bindless_image",
+               "check_Uniform_with_explicit_bindless_image",
+               check_Uniform_with_explicit_bindless_image,
+               NULL
+       },
+       {
+               "Check glUniform*() with implicit bound_image",
+               "check_Uniform_with_implicit_bound_image",
+               check_Uniform_with_implicit_bound_image,
                NULL
        },
        {
-- 
2.13.0

_______________________________________________
Piglit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to