[Piglit] [PATCH] ext_gpu_shader4: test glBindFragDataLocationEXT

Ian Romanick idr at freedesktop.org
Tue Apr 16 00:18:51 UTC 2019


On 4/15/19 5:16 PM, Marek Olšák wrote:
> It's also an execution test for "varying out".

I don't know what that has to do with glBindFragDataLocationEXT vs
glBindFragDataLocation.  Can you please explain?

> Marek
> 
> On Mon, Apr 15, 2019 at 6:28 PM Ian Romanick <idr at freedesktop.org
> <mailto:idr at freedesktop.org>> wrote:
> 
>     On 4/15/19 10:47 AM, Marek Olšák wrote:
>     > From: Marek Olšák <marek.olsak at amd.com <mailto:marek.olsak at amd.com>>
>     >
>     > ---
>     >  tests/opengl.py                         |   7 ++
>     >  tests/spec/gl-3.1/mixed-int-float-fbo.c | 100
>     +++++++++++++++++++-----
>     >  2 files changed, 88 insertions(+), 19 deletions(-)
>     >
>     > diff --git a/tests/opengl.py b/tests/opengl.py
>     > index 40c37a055..666b35200 100644
>     > --- a/tests/opengl.py
>     > +++ b/tests/opengl.py
>     > @@ -3026,20 +3026,27 @@ with profile.test_list.group_manager(
>     >      g(['getteximage-formats', 'init-by-rendering'])
>     >      g(['getteximage-formats', 'init-by-clear-and-render'])
>     >      g(['ext_framebuffer_multisample-fast-clear', 'single-sample'],
>     >        'fbo-fast-clear')
>     >      g(['ext_framebuffer_object-border-texture-finish'])
>     >      add_fbo_stencil_tests(g, 'GL_STENCIL_INDEX1')
>     >      add_fbo_stencil_tests(g, 'GL_STENCIL_INDEX4')
>     >      add_fbo_stencil_tests(g, 'GL_STENCIL_INDEX8')
>     >      add_fbo_stencil_tests(g, 'GL_STENCIL_INDEX16')
>>     > +
>     > +with profile.test_list.group_manager(
>     > +        PiglitGLTest,
>     > +        grouptools.join('spec', 'ext_gpu_shader4')) as g:
>     > +    g(['gl-3.1-mixed-int-float-fbo', 'ext_gpu_shader4'],
>     'bindfragdatalocation mixed-int-float-fbo')
>     > +    g(['gl-3.1-mixed-int-float-fbo', 'ext_gpu_shader4',
>     'int_second'], 'bindfragdatalocation mixed-int-float-fbo int_second')
>     > +
>     >  with profile.test_list.group_manager(
>     >          PiglitGLTest, grouptools.join('spec',
>     'ext_image_dma_buf_import')) as \
>     >          g:
>     >      g(['ext_image_dma_buf_import-invalid_hints'],
>     run_concurrent=False)
>     >      g(['ext_image_dma_buf_import-invalid_attributes'],
>     run_concurrent=False)
>     >      g(['ext_image_dma_buf_import-missing_attributes'],
>     run_concurrent=False)
>     >      g(['ext_image_dma_buf_import-ownership_transfer'],
>     run_concurrent=False)
>     >      g(['ext_image_dma_buf_import-unsupported_format'],
>     run_concurrent=False)
>     >      g(['ext_image_dma_buf_import-intel_external_sampler_only'],
>     >        run_concurrent=False)
>     > diff --git a/tests/spec/gl-3.1/mixed-int-float-fbo.c
>     b/tests/spec/gl-3.1/mixed-int-float-fbo.c
>     > index d2d7aeb65..8dfeccb41 100644
>     > --- a/tests/spec/gl-3.1/mixed-int-float-fbo.c
>     > +++ b/tests/spec/gl-3.1/mixed-int-float-fbo.c
>     > @@ -26,22 +26,36 @@
>     >   * Test mixed integer/float FBO.
>     >   *
>     >   * If the argument 'int_second' is given the 0th color attachment
>     will
>     >   * be a unorm texture and the 1st color attachment will be an
>     integer texture.
>     >   * Otherwise, the 0th color attachment will be integer and the
>     1st color
>     >   * attachment will be unorm.
>     >   */
>>     >  #include "piglit-util-gl.h"
>>     > +static bool ext_gpu_shader4 = false;
>     > +
>     >  PIGLIT_GL_TEST_CONFIG_BEGIN
>     > -     config.supports_gl_core_version = 31;
>     > +     for (int i = 1; i < argc; i++) {
>     > +             if (!strcmp(argv[i], "ext_gpu_shader4")) {
>     > +                     ext_gpu_shader4 = true;
>     > +                     puts("Testing GL_EXT_gpu_shader4.");
>     > +                     break;
>     > +             }
>     > +     }
>     > +
>     > +     if (ext_gpu_shader4)
>     > +             config.supports_gl_compat_version = 10;
>     > +     else
>     > +             config.supports_gl_core_version = 31;
>     > +
>     >       config.window_visual = PIGLIT_GL_VISUAL_RGBA;
>     >       config.khr_no_error_support = PIGLIT_NO_ERRORS;
>     >  PIGLIT_GL_TEST_CONFIG_END
>>     >  static const char *vs_text =
>     >       "#version 150\n"
>     >       "in vec4 vertex;\n"
>     >       "void main() \n"
>     >       "{ \n"
>     >       "   gl_Position = vertex; \n"
>     > @@ -50,35 +64,71 @@ static const char *vs_text =
>     >  static const char *fs_text =
>     >       "#version 150\n"
>     >       "out ivec4 outputInt;\n"
>     >       "out vec4 outputFloat;\n"
>     >       "void main() \n"
>     >       "{ \n"
>     >       "   outputInt = ivec4(1, 2, 3, 4); \n"
>     >       "   outputFloat = vec4(0.25, 0.5, 0.75, 1.0); \n"
>     >       "} \n";
>>     > +static const char *vs_text_gpu_shader4 =
>     > +     "#version 110\n"
>     > +     "attribute vec4 vertex;\n"
>     > +     "void main() \n"
>     > +     "{ \n"
>     > +     "   gl_Position = vertex; \n"
>     > +     "} \n";
>     > +
>     > +static const char *fs_text_gpu_shader4 =
>     > +     "#version 110\n"
>     > +     "#extension GL_EXT_gpu_shader4 : enable\n"
>     > +     "varying out ivec4 outputInt;\n"
>     > +     "varying out vec4 outputFloat;\n"
>     > +     "void main() \n"
>     > +     "{ \n"
>     > +     "   outputInt = ivec4(1, 2, 3, 4); \n"
>     > +     "   outputFloat = vec4(0.25, 0.5, 0.75, 1.0); \n"
>     > +     "} \n";
>     > +
>     >  const int width = 128, height = 128;
>     >  bool int_output_first = true;
>>>     >  static GLuint
>     >  create_program(void)
>     >  {
>     > -     GLuint program = piglit_build_simple_program(vs_text, fs_text);
>     > -     if (int_output_first) {
>     > -             glBindFragDataLocation(program, 0, "outputInt");
>     > -             glBindFragDataLocation(program, 1, "outputFloat");
>     > -     }
>     > -     else {
>     > -             glBindFragDataLocation(program, 0, "outputFloat");
>     > -             glBindFragDataLocation(program, 1, "outputInt");
>     > +     GLuint program;
>     > +
>     > +     if (ext_gpu_shader4) {
>     > +             program =
>     piglit_build_simple_program(vs_text_gpu_shader4,
>     > +                                                 
>      fs_text_gpu_shader4);
>     > +
>     > +             if (int_output_first) {
>     > +                     glBindFragDataLocationEXT(program, 0,
>     "outputInt");
>     > +                     glBindFragDataLocationEXT(program, 1,
>     "outputFloat");
> 
>     I don't know if this separation is strictly necessary.  The Khronos
>     gl.xml /says/ glBindFragDataLocationEXT is an alias of
>     glBindFragDataLocation.  There's no published GLX protocol, so there's
>     nothing that prevents the two from being unaliased in the future.
> 
>     I don't feel very strongly about it either way.  Whichever way you
>     decide to do it, this patch is
> 
>     Reviewed-by: Ian Romanick <ian.d.romanick at intel.com
>     <mailto:ian.d.romanick at intel.com>>
> 
>     > +             }
>     > +             else {
>     > +                     glBindFragDataLocationEXT(program, 0,
>     "outputFloat");
>     > +                     glBindFragDataLocationEXT(program, 1,
>     "outputInt");
>     > +             }
>     > +     } else {
>     > +             program = piglit_build_simple_program(vs_text, fs_text);
>     > +
>     > +             if (int_output_first) {
>     > +                     glBindFragDataLocation(program, 0, "outputInt");
>     > +                     glBindFragDataLocation(program, 1,
>     "outputFloat");
>     > +             }
>     > +             else {
>     > +                     glBindFragDataLocation(program, 0,
>     "outputFloat");
>     > +                     glBindFragDataLocation(program, 1, "outputInt");
>     > +             }
>     >       }
>>     >       glLinkProgram(program);
>     >       if (!piglit_link_check_status(program))
>     >               piglit_report_result(PIGLIT_FAIL);
>>     >       piglit_check_gl_error(GL_NO_ERROR);
>>     >       return program;
>     >  }
>     > @@ -139,30 +189,35 @@ create_fbo(void)
>     >               piglit_report_result(PIGLIT_SKIP);
>     >       }
>>     >       return fbo;
>     >  }
>>>     >  enum piglit_result
>     >  piglit_display(void)
>     >  {
>     > -     const int int_clear[4] = { 99, 99, 99, 99 };
>     > -     const float float_clear[4] = { 0.33, 0.33, 0.33, 0.33 };
>     > -
>     > -     if (int_output_first) {
>     > -             glClearBufferiv(GL_COLOR, 0, int_clear);
>     > -             glClearBufferfv(GL_COLOR, 1, float_clear);
>     > -     }
>     > -     else {
>     > -             glClearBufferfv(GL_COLOR, 0, float_clear);
>     > -             glClearBufferiv(GL_COLOR, 1, int_clear);
>     > +     if (ext_gpu_shader4) {
>     > +             glClearColor(0, 0, 0, 0);
>     > +             glClear(GL_COLOR_BUFFER_BIT);
>     > +     } else {
>     > +             const int int_clear[4] = { 99, 99, 99, 99 };
>     > +             const float float_clear[4] = { 0.33, 0.33, 0.33, 0.33 };
>     > +
>     > +             if (int_output_first) {
>     > +                     glClearBufferiv(GL_COLOR, 0, int_clear);
>     > +                     glClearBufferfv(GL_COLOR, 1, float_clear);
>     > +             }
>     > +             else {
>     > +                     glClearBufferfv(GL_COLOR, 0, float_clear);
>     > +                     glClearBufferiv(GL_COLOR, 1, int_clear);
>     > +             }
>     >       }
>>     >       piglit_draw_rect(-1, -1, 2, 2);
>>     >       bool pass = true;
>>     >       /* check the int target */
>     >       if (int_output_first) {
>     >               glReadBuffer(GL_COLOR_ATTACHMENT0);
>     >       }
>     > @@ -205,20 +260,27 @@ piglit_display(void)
>>     >       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
>>     >       return pass ? PIGLIT_PASS : PIGLIT_FAIL;
>     >  }
>>>     >  void
>     >  piglit_init(int argc, char **argv)
>     >  {
>     > +     if (ext_gpu_shader4) {
>     > +             piglit_require_gl_version(20);
>     > +             piglit_require_extension("GL_ARB_framebuffer_object");
>     > +             piglit_require_extension("GL_EXT_gpu_shader4");
>     > +             piglit_require_extension("GL_EXT_texture_integer");
>     > +     }
>     > +
>     >       if (argc > 1 && strcmp(argv[1], "int_second") == 0) {
>     >               int_output_first = false;
>     >       }
>>     >       GLuint fbo = create_fbo();
>     >       GLuint program = create_program();
>>     >       glBindFramebuffer(GL_FRAMEBUFFER, fbo);
>     >       glUseProgram(program);
>     >  }
>     >
> 



More information about the Piglit mailing list