mesa: replace gl_framebuffer::_IntegerColor wih _IntegerBuffers
authorBrian Paul <brianp@vmware.com>
Mon, 10 Oct 2016 17:29:14 +0000 (11:29 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 13 Oct 2016 23:38:49 +0000 (17:38 -0600)
Use a bitmask to indicate which color buffers are integer-valued, rather
than a bool.  Also, the old field was mis-computed.  If an integer buffer
was followed by a non-integer buffer, the _IntegerColor field was wrongly
set to false.

This fixes the new piglit gl-3.1-mixed-int-float-fbo test.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/drivers/common/meta.c
src/mesa/main/api_validate.c
src/mesa/main/blend.c
src/mesa/main/fbobject.c
src/mesa/main/get.c
src/mesa/main/get_hash_params.py
src/mesa/main/mtypes.h

index fdc4748602f62d934382300092266a775ff011cf..890e98a06b61011e92cadffb39306b1ab5f4718d 100644 (file)
@@ -1750,7 +1750,7 @@ meta_clear(struct gl_context *ctx, GLbitfield buffers, bool glsl)
       z = invert_z(ctx->Depth.Clear);
    }
 
-   if (fb->_IntegerColor) {
+   if (fb->_IntegerBuffers) {
       assert(glsl);
       _mesa_meta_use_program(ctx, clear->IntegerShaderProg);
       _mesa_Uniform4iv(0, 1, ctx->Color.ClearColor.i);
index c3c5a696928a0baed02e7e74659bccec84944979..d3b4cab7d5b3fd4c018067d1ee4e640c2408c1aa 100644 (file)
@@ -152,7 +152,7 @@ _mesa_valid_to_render(struct gl_context *ctx, const char *where)
          /* If drawing to integer-valued color buffers, there must be an
           * active fragment shader (GL_EXT_texture_integer).
           */
-         if (ctx->DrawBuffer && ctx->DrawBuffer->_IntegerColor) {
+         if (ctx->DrawBuffer && ctx->DrawBuffer->_IntegerBuffers) {
             _mesa_error(ctx, GL_INVALID_OPERATION,
                         "%s(integer format but no fragment shader)", where);
             return GL_FALSE;
index ad79ee011d29b58b2e4df0cb804931dea4fe4ce5..0322799af54f254f9d8b5952d3c0d627441c500b 100644 (file)
@@ -945,7 +945,7 @@ _mesa_update_clamp_fragment_color(struct gl_context *ctx,
     * - there is an integer colorbuffer
     */
    if (!drawFb || !drawFb->_HasSNormOrFloatColorBuffer ||
-       drawFb->_IntegerColor)
+       drawFb->_IntegerBuffers)
       ctx->Color._ClampFragmentColor = GL_FALSE;
    else
       ctx->Color._ClampFragmentColor =
index 3b55e79f4a02ef05f40899f682b10c8462e740cd..9204606c6700fc22574c01098565570b69d49275 100644 (file)
@@ -970,6 +970,7 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
    fb->_AllColorBuffersFixedPoint = GL_TRUE;
    fb->_HasSNormOrFloatColorBuffer = GL_FALSE;
    fb->_HasAttachments = true;
+   fb->_IntegerBuffers = 0;
 
    /* Start at -2 to more easily loop over all attachment points.
     *  -2: depth buffer
@@ -1090,13 +1091,14 @@ _mesa_test_framebuffer_completeness(struct gl_context *ctx,
          continue;
       }
 
-      /* check if integer color */
-      fb->_IntegerColor = _mesa_is_format_integer_color(attFormat);
-
-      /* Update _AllColorBuffersFixedPoint and _HasSNormOrFloatColorBuffer. */
+      /* Update flags describing color buffer datatypes */
       if (i >= 0) {
          GLenum type = _mesa_get_format_datatype(attFormat);
 
+         /* check if integer color */
+         if (_mesa_is_format_integer_color(attFormat))
+            fb->_IntegerBuffers |= (1 << i);
+
          fb->_AllColorBuffersFixedPoint =
             fb->_AllColorBuffersFixedPoint &&
             (type == GL_UNSIGNED_NORMALIZED || type == GL_SIGNED_NORMALIZED);
index bd85befa12550fc17c6486a4805fcdbb6deb2624..c11bcde207a244856d261d8f8f634e218fb35dd2 100644 (file)
@@ -1076,6 +1076,10 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu
    case GL_SAMPLE_BUFFERS:
       v->value_int = _mesa_geometric_samples(ctx->DrawBuffer) > 0;
       break;
+   /* GL_EXT_textrue_integer */
+   case GL_RGBA_INTEGER_MODE_EXT:
+      v->value_int = (ctx->DrawBuffer->_IntegerBuffers != 0);
+      break;
    /* GL_ATI_meminfo & GL_NVX_gpu_memory_info */
    case GL_VBO_FREE_MEMORY_ATI:
    case GL_TEXTURE_FREE_MEMORY_ATI:
index 6849b5b7d5828bcfd5ff01853c8b0076b40ac521..3c6b7129afb6b38dfa5becd2c3486c03505bc2d5 100644 (file)
@@ -890,7 +890,7 @@ descriptor=[
   [ "TEXTURE_CUBE_MAP_SEAMLESS", "CONTEXT_BOOL(Texture.CubeMapSeamless), extra_ARB_seamless_cube_map" ],
 
 # GL_EXT_texture_integer
-  [ "RGBA_INTEGER_MODE_EXT", "BUFFER_BOOL(_IntegerColor), extra_EXT_texture_integer_and_new_buffers" ],
+  [ "RGBA_INTEGER_MODE_EXT", "LOC_CUSTOM, TYPE_INT, 0, extra_EXT_texture_integer_and_new_buffers" ],
 
 # GL_ARB_transform_feedback3
   [ "MAX_TRANSFORM_FEEDBACK_BUFFERS", "CONTEXT_INT(Const.MaxTransformFeedbackBuffers), extra_ARB_transform_feedback3" ],
index ab9839c75163db815fdb2c45d9274d42ab61e35a..61d6bf1a6e9bbcfdf4b45fd6f8c9c4fd7fdf5a41 100644 (file)
@@ -3334,8 +3334,7 @@ struct gl_framebuffer
     */
    bool _HasAttachments;
 
-   /** Integer color values */
-   GLboolean _IntegerColor;
+   GLbitfield _IntegerBuffers;  /**< Which color buffers are integer valued */
 
    /* ARB_color_buffer_float */
    GLboolean _AllColorBuffersFixedPoint; /* no integer, no float */