[Piglit] [PATCH 7/8] arb_texture_multisample: add test for texelFetch()

Chris Forbes chrisf at ijw.co.nz
Mon Jan 7 14:21:22 PST 2013


This test actually gets *simpler*, generalized to arbitrary sample
counts. I'll cook something up tonight.

-- Chris

On Tue, Jan 8, 2013 at 10:24 AM, Paul Berry <stereotype441 at gmail.com> wrote:
> On 5 January 2013 01:07, Chris Forbes <chrisf at ijw.co.nz> wrote:
>>
>> Writes a test pattern to individual samples in a multisample texture,
>> and tests texelFetch() reads the correct values for each sample.
>>
>> Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
>
>
> Unforunately, I think we need to generalize this test to test a variety of
> sample counts.  Otherwise, there's just too much danger of a bug that's
> specific to one particular sample count going undetected.  For example, when
> we get around to implementing Ivy Bridge's "compressed" layout, the
> texelFetch() logic will need to load a 32-bit value from the MCS surface in
> 8x MSAA mode, and only an 8-bit value in 4x MSAA mode.
>
>>
>> ---
>>  tests/all.tests                                    |   2 +
>>  .../spec/arb_texture_multisample/CMakeLists.gl.txt |   1 +
>>  .../texel-fetch-execution.c                        | 159
>> +++++++++++++++++++++
>>  3 files changed, 162 insertions(+)
>>  create mode 100644
>> tests/spec/arb_texture_multisample/texel-fetch-execution.c
>>
>> diff --git a/tests/all.tests b/tests/all.tests
>> index 19d7cf9..8a56a27 100644
>> --- a/tests/all.tests
>> +++ b/tests/all.tests
>> @@ -850,6 +850,8 @@ add_concurrent_test(arb_texture_multisample,
>> 'arb_texture_multisample-sample-mas
>>  add_concurrent_test(arb_texture_multisample,
>> 'arb_texture_multisample-sample-mask-value')
>>  add_concurrent_test(arb_texture_multisample,
>> 'arb_texture_multisample-sample-mask-execution')
>>  add_concurrent_test(arb_texture_multisample,
>> 'arb_texture_multisample-sample-mask-execution -tex')
>> +add_concurrent_test(arb_texture_multisample,
>> 'arb_texture_multisample-texel-fetch-execution vs')
>> +add_concurrent_test(arb_texture_multisample,
>> 'arb_texture_multisample-texel-fetch-execution fs')
>>  textureSize_samplers_atm = ['sampler2DMS', 'isampler2DMS',
>> 'usampler2DMS',
>>
>> 'sampler2DMSArray', 'isampler2DMSArray', 'usampler2DMSArray']
>>  for stage in ['vs', 'fs']:
>> diff --git a/tests/spec/arb_texture_multisample/CMakeLists.gl.txt
>> b/tests/spec/arb_texture_multisample/CMakeLists.gl.txt
>> index f13b062..7bc915f 100644
>> --- a/tests/spec/arb_texture_multisample/CMakeLists.gl.txt
>> +++ b/tests/spec/arb_texture_multisample/CMakeLists.gl.txt
>> @@ -16,5 +16,6 @@ piglit_add_executable (arb_texture_multisample-texstate
>> texstate.c)
>>  piglit_add_executable (arb_texture_multisample-sample-mask sample-mask.c)
>>  piglit_add_executable (arb_texture_multisample-sample-mask-value
>> sample-mask-value.c)
>>  piglit_add_executable (arb_texture_multisample-sample-mask-execution
>> sample-mask-execution.c)
>> +piglit_add_executable (arb_texture_multisample-texel-fetch-execution
>> texel-fetch-execution.c)
>>
>>  # vim: ft=cmake:
>> diff --git a/tests/spec/arb_texture_multisample/texel-fetch-execution.c
>> b/tests/spec/arb_texture_multisample/texel-fetch-execution.c
>> new file mode 100644
>> index 0000000..791643f
>> --- /dev/null
>> +++ b/tests/spec/arb_texture_multisample/texel-fetch-execution.c
>> @@ -0,0 +1,159 @@
>> +#include "piglit-util-gl-common.h"
>> +
>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>> +
>> +    config.supports_gl_compat_version = 30;
>> +
>> +    config.window_width = 64;
>> +    config.window_height = 64;
>> +    config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_ALPHA;
>> +
>> +PIGLIT_GL_TEST_CONFIG_END
>> +
>> +/* test texelFetch() from multisample textures.
>> + * instead of using actual multisample rasterization,
>> + * we'll write the test pattern to a MSAA texture via
>> + * sample masking.
>> + */
>> +
>> +GLuint fbo, tex, shader, prog;
>> +GLint u_sample;
>> +GLuint shader_stage = 0;
>> +
>> +enum piglit_result
>> +piglit_display(void)
>> +{
>> +    float red[] = {1,0,0,1};
>> +    float green[] = {0,1,0,1};
>> +    float blue[] = {0,0,1,1};
>> +    float white[] = {1,1,1,1};
>> +
>> +    bool pass = true;
>> +
>> +    glClearColor(0.2,0.2,0.2,1.0);
>> +    glClear(GL_COLOR_BUFFER_BIT);
>> +
>> +    glUseProgram(prog);
>> +
>> +    glUniform1i(u_sample, 0);
>> +    piglit_draw_rect(-1,-1,1,1);
>> +
>> +    glUniform1i(u_sample, 1);
>> +    piglit_draw_rect(0,-1,1,1);
>> +
>> +    glUniform1i(u_sample, 2);
>> +    piglit_draw_rect(0,0,1,1);
>> +
>> +    glUniform1i(u_sample, 3);
>> +    piglit_draw_rect(-1,0,1,1);
>> +
>> +    pass = piglit_probe_pixel_rgba(16, 16, red) && pass;
>> +    pass = piglit_probe_pixel_rgba(48, 16, green) && pass;
>> +    pass = piglit_probe_pixel_rgba(48, 48, blue) && pass;
>> +    pass = piglit_probe_pixel_rgba(16, 48, white) && pass;
>> +
>> +    piglit_present_results();
>> +
>> +    return pass ? PIGLIT_PASS : PIGLIT_FAIL;
>> +}
>> +
>> +void
>> +piglit_init(int argc, char **argv)
>> +{
>> +    piglit_require_extension("GL_ARB_texture_multisample");
>> +
>> +    while (++argv,--argc) {
>> +        if (!strcmp(*argv, "vs"))
>> +            shader_stage = GL_VERTEX_SHADER;
>> +        else if (!strcmp(*argv, "fs"))
>> +            shader_stage = GL_FRAGMENT_SHADER;
>> +    }
>> +
>> +
>> +    glGenFramebuffers(1, &fbo);
>> +    glGenTextures(1, &tex);
>> +    glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex);
>> +    glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE,
>> +                            4, GL_RGBA, 64, 64, GL_TRUE);
>> +
>> +    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
>> +    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
>> +                           GL_TEXTURE_2D_MULTISAMPLE, tex, 0);
>> +
>> +    glClearColor(0.2,0.2,0.2,1.0);
>> +    glClear(GL_COLOR_BUFFER_BIT);
>> +
>> +    /* write test pattern: red,green,blue,white */
>> +    glEnable(GL_SAMPLE_MASK);
>> +
>> +    glSampleMaski(0, (1<<0));
>> +    glColor4f(1.0,0.0,0.0,1.0);
>> +    piglit_draw_rect(-1,-1,2,2);
>> +
>> +    glSampleMaski(0, (1<<1));
>> +    glColor4f(0.0,1.0,0.0,1.0);
>> +    piglit_draw_rect(-1,-1,2,2);
>> +
>> +    glSampleMaski(0, (1<<2));
>> +    glColor4f(0.0,0.0,1.0,1.0);
>> +    piglit_draw_rect(-1,-1,2,2);
>> +
>> +    glSampleMaski(0, (1<<3));
>> +    glColor4f(1.0,1.0,1.0,1.0);
>> +    piglit_draw_rect(-1,-1,2,2);
>> +
>> +    glDisable(GL_SAMPLE_MASK);
>> +
>> +    if (!piglit_check_gl_error(GL_NO_ERROR))
>> +        piglit_report_result(PIGLIT_FAIL);
>> +
>> +    glBindFramebuffer(GL_FRAMEBUFFER, 0);
>> +
>> +    switch (shader_stage) {
>> +    case GL_VERTEX_SHADER:
>> +        shader = piglit_compile_shader_text(GL_VERTEX_SHADER,
>> +            "#version 130\n"
>> +            "#extension GL_ARB_texture_multisample : require\n"
>> +            "\n"
>> +            "uniform sampler2DMS s;\n"
>> +            "uniform int sample;\n"
>> +            "\n"
>> +            "void main() {\n"
>> +            "   gl_Position = ftransform();\n"
>> +            "   gl_FrontColor = texelFetch(s, ivec2(32, 32), sample); \n"
>> +            "}\n");
>> +
>> +        prog = piglit_link_simple_program(shader, 0);
>> +        break;
>> +
>> +    case GL_FRAGMENT_SHADER:
>> +        shader = piglit_compile_shader_text(GL_FRAGMENT_SHADER,
>> +            "#version 130\n"
>> +            "#extension GL_ARB_texture_multisample : require\n"
>> +            "\n"
>> +            "uniform sampler2DMS s;\n"
>> +            "uniform int sample;\n"
>> +            "\n"
>> +            "void main() {\n"
>> +            "   gl_FragColor = texelFetch(s, ivec2(32,32), sample); \n"
>> +            "}\n");
>> +
>> +        prog = piglit_link_simple_program(0, shader);
>> +        break;
>> +
>> +    default:
>> +        printf("Please provide shader type: `vs` or `fs`\n");
>> +        piglit_report_result(PIGLIT_FAIL);
>> +    }
>> +
>> +    if (!prog || !shader)
>> +        piglit_report_result(PIGLIT_FAIL);
>> +
>> +    u_sample = glGetUniformLocation(prog, "sample");
>> +    printf("sample uniform: %d\n", u_sample);
>> +    if (u_sample == -1)
>> +        piglit_report_result(PIGLIT_FAIL);
>> +
>> +    if (!piglit_check_gl_error(GL_NO_ERROR))
>> +        piglit_report_result(PIGLIT_FAIL);
>> +}
>> --
>> 1.8.1
>>
>> _______________________________________________
>> Piglit mailing list
>> Piglit at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/piglit
>
>


More information about the Piglit mailing list