[Piglit] [PATCH 1/7] ARB_explicit_uniform_location: test for uniform location boundary values

Tapani Pälli tapani.palli at intel.com
Thu Mar 13 23:05:48 PDT 2014


On 03/13/2014 08:24 PM, Anuj Phogat wrote:
> On Thu, Mar 13, 2014 at 5:41 AM, Tapani Pälli <tapani.palli at intel.com> wrote:
>> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
>> ---
>>  tests/all.py                                       |   1 +
>>  .../CMakeLists.gl.txt                              |   1 +
>>  .../arb_explicit_uniform_location/loc-minmax.c     | 107 +++++++++++++++++++++
>>  3 files changed, 109 insertions(+)
>>  create mode 100644 tests/spec/arb_explicit_uniform_location/loc-minmax.c
8<
>> +}
>> +
>> +const char v_sha[] =
>> +"vec4 vertex;\n"
>> +"void main() {\n"
>> +"gl_Position = vertex;\n"
>> +"}";
>> +
>> +const char fshader_main[] =
>> +"#extension GL_ARB_explicit_uniform_location: require\n"
>> +"uniform float a;\n"
>> +"layout(location = %d) uniform float r;\n"
>> +"layout(location = %d) uniform float g;\n"
>> +"layout(location = %d) uniform float b;\n"
>> +"void main() {\n"
>> +"gl_FragColor = vec4(r, g, b, a);\n"
>> +"}";
> Using indentation in shader programs will make them more
> readable.

ok, will do

>> +
>> +#define VERIFY_LOC(uni, loc)\
>> +       if (glGetUniformLocation(prog, uni) != loc)\
>> +               piglit_report_result(PIGLIT_FAIL);
>> +
>> +void
>> +piglit_init(int argc, char **argv)
>> +{
>> +       int maxloc, randloc;
>> +       GLuint prog;
>> +
>> +       piglit_require_extension("GL_ARB_explicit_uniform_location");
>> +
>> +       glGetIntegerv(GL_MAX_UNIFORM_LOCATIONS, &maxloc);
>> +
>> +       if (!piglit_check_gl_error(GL_NO_ERROR))
>> +               piglit_report_result(PIGLIT_FAIL);
>> +
>> +        char f_sha[256];
>> +
>> +        /* random location in a range 1 .. (maxloc - 1) */
> Above two lines indented differently. Use tab.
>> +       randloc = 1 + rand() % (maxloc - 2);
>> +
>> +       /* test GL_MAX_UNIFORM_LOCATIONS - 1, 0, and rand loc in between */
>> +       snprintf(f_sha, 256, fshader_main,
>> +                 maxloc - 1,
>> +                 0,
>> +                 randloc);
> Using asprintf() here will eliminate the risk of string truncation
> which might happen if someone modifies the shader in future.

True, I just wanted to avoid alloc as the shader is fairly small and
static here but I will change this and the other tests to use asprintf.

>> +
>> +       prog = piglit_build_simple_program(v_sha, f_sha);
>> +
>> +       VERIFY_LOC("r", maxloc - 1);
>> +       VERIFY_LOC("g", 0);
>> +       VERIFY_LOC("b", randloc);
>> +
>> +       glDeleteProgram(prog);
>> +
>> +        piglit_report_result(PIGLIT_PASS);
> indented differently. Use tab.

Oops, will go through these.

Thanks for reviewing!

>> +}
>> --
>> 1.8.3.1
>>
>> _______________________________________________
>> Piglit mailing list
>> Piglit at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/piglit

// Tapani



More information about the Piglit mailing list