mesa/glsl/glapi: enable GL_EXT_draw_buffers extension
authorTapani Pälli <tapani.palli@intel.com>
Tue, 25 Nov 2014 11:10:30 +0000 (06:10 -0500)
committerTapani Pälli <tapani.palli@intel.com>
Wed, 14 Jan 2015 05:48:51 +0000 (07:48 +0200)
Patch enables ES2 extension that utilizes existing ES3 functionality.

Changes make all the subtests to run and pass in WebGL conformance
test 'webgl-draw-buffers' when running Chrome on OpenGL ES, also
Piglit test 'draw_buffers_gles2' passes.

v2: remove unused boolean (Ilia Mirkin)
v3: proper error checking for invalid values (Chad Versace)
v4: run error check explicitly for ES2 and ES3 (Kenneth Graunke)

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Chad Versace <chad.versace@intel.com>
src/glsl/glcpp/glcpp-parse.y
src/glsl/glsl_parser_extras.cpp
src/glsl/glsl_parser_extras.h
src/mapi/glapi/gen/es_EXT.xml
src/mesa/main/buffers.c
src/mesa/main/extensions.c

index 9b1a4f40112bb469d67ac4a5356a2268d276f157..9e705ef074107fccb24df3949bd5a07db21e7903 100644 (file)
@@ -2375,6 +2375,7 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t versio
        if (parser->is_gles) {
           add_builtin_define(parser, "GL_ES", 1);
            add_builtin_define(parser, "GL_EXT_separate_shader_objects", 1);
+           add_builtin_define(parser, "GL_EXT_draw_buffers", 1);
 
           if (extensions != NULL) {
              if (extensions->OES_EGL_image_external)
index 27e2eaf372ff988e25b65fa89c8d138fef353c17..6d18cd493cc8a6c27979d1827c72f295b9751a67 100644 (file)
@@ -561,6 +561,7 @@ static const _mesa_glsl_extension _mesa_glsl_supported_extensions[] = {
    EXT(AMD_shader_trinary_minmax,      true,  false,     dummy_true),
    EXT(AMD_vertex_shader_layer,        true,  false,     AMD_vertex_shader_layer),
    EXT(AMD_vertex_shader_viewport_index, true,  false,   AMD_vertex_shader_viewport_index),
+   EXT(EXT_draw_buffers,               false,  true,     dummy_true),
    EXT(EXT_separate_shader_objects,    false, true,      dummy_true),
    EXT(EXT_shader_integer_mix,         true,  true,      EXT_shader_integer_mix),
    EXT(EXT_texture_array,              true,  false,     EXT_texture_array),
index e04f7ced565bf719b67e452e664a7c76318f81aa..4887672233be755ee8af52e88bad81956974e208 100644 (file)
@@ -473,6 +473,8 @@ struct _mesa_glsl_parse_state {
    bool AMD_vertex_shader_layer_warn;
    bool AMD_vertex_shader_viewport_index_enable;
    bool AMD_vertex_shader_viewport_index_warn;
+   bool EXT_draw_buffers_enable;
+   bool EXT_draw_buffers_warn;
    bool EXT_separate_shader_objects_enable;
    bool EXT_separate_shader_objects_warn;
    bool EXT_shader_integer_mix_enable;
index e2dc39021c85bb7c67afb6ae120dd40eeb51a53f..3a2adeb0491631f2133ceac60a9308721bd89289 100644 (file)
     </function>
 </category>
 
+<!-- 151. GL_EXT_draw_buffers -->
+<category name="GL_EXT_draw_buffers" number="151">
+    <function name="DrawBuffersEXT" alias="DrawBuffers"
+              static_dispatch="false" es2="2.0">
+        <param name="n" type="GLsizei" counter="true"/>
+        <param name="bufs" type="const GLenum *" count="n"/>
+    </function>
+</category>
+
 </OpenGLAPI>
index 1ee20098d38cf36e75412e0e5eb80bc96ddd4496..49157f7fdf43fc26a71d018c5b335fc7f915ab14 100644 (file)
@@ -326,8 +326,9 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
    /* From the ES 3.0 specification, page 180:
     * "If the GL is bound to the default framebuffer, then n must be 1
     *  and the constant must be BACK or NONE."
+    * (same restriction applies with GL_EXT_draw_buffers specification)
     */
-   if (_mesa_is_gles3(ctx) && _mesa_is_winsys_fbo(ctx->DrawBuffer) &&
+   if (ctx->API == API_OPENGLES2 && _mesa_is_winsys_fbo(ctx->DrawBuffer) &&
        (n != 1 || (buffers[0] != GL_NONE && buffers[0] != GL_BACK))) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffers(buffer)");
       return;
@@ -399,8 +400,9 @@ _mesa_DrawBuffers(GLsizei n, const GLenum *buffers)
          /* ES 3.0 is even more restrictive.  From the ES 3.0 spec, page 180:
           * "If the GL is bound to a framebuffer object, the ith buffer listed
           *  in bufs must be COLOR_ATTACHMENTi or NONE. [...] INVALID_OPERATION."
+          * (same restriction applies with GL_EXT_draw_buffers specification)
           */
-         if (_mesa_is_gles3(ctx) && _mesa_is_user_fbo(ctx->DrawBuffer) &&
+         if (ctx->API == API_OPENGLES2 && _mesa_is_user_fbo(ctx->DrawBuffer) &&
              buffers[output] != GL_NONE &&
              buffers[output] != GL_COLOR_ATTACHMENT0 + output) {
             _mesa_error(ctx, GL_INVALID_OPERATION, "glDrawBuffers(buffer)");
index 4fa9d1a26b1fe16f81c590406022e7ad7dd07130..e5bac7f894aa42bfe2abe9208dc567a97f2cef00 100644 (file)
@@ -213,6 +213,7 @@ static const struct extension extension_table[] = {
    { "GL_EXT_compiled_vertex_array",               o(dummy_true),                              GLL,            1996 },
    { "GL_EXT_copy_texture",                        o(dummy_true),                              GLL,            1995 },
    { "GL_EXT_depth_bounds_test",                   o(EXT_depth_bounds_test),                   GL,             2002 },
+   { "GL_EXT_draw_buffers",                        o(dummy_true),                                         ES2, 2012 },
    { "GL_EXT_draw_buffers2",                       o(EXT_draw_buffers2),                       GL,             2006 },
    { "GL_EXT_draw_instanced",                      o(ARB_draw_instanced),                      GL,             2006 },
    { "GL_EXT_draw_range_elements",                 o(dummy_true),                              GLL,            1997 },