[Mesa-dev] [PATCH 30/65] mesa/formatquery: handle unmodified buffer for SAMPLES on the 64-bit query

Eduardo Lima Mitev elima at igalia.com
Wed Feb 3 15:45:15 UTC 2016


From: Alejandro PiƱeiro <apinheiro at igalia.com>

>From arb_internalformat_query2 spec:

" If <internalformat> is not color-renderable, depth-renderable, or
  stencil-renderable (as defined in section 4.4.4), or if <target>
  does not support multiple samples (ie other than
  TEXTURE_2D_MULTISAMPLE, TEXTURE_2D_MULTISAMPLE_ARRAY, or
  RENDERBUFFER), <params> is not modified."

So there are cases where the buffer should not be modified. As the
64-bit query is a wrapper over the 32-bit query, we can't just copy
the values to the equivalent 32-bit buffer, as that would fail if the
original params contained values greater that INT_MAX. So we need to
copy-back only the values that got modified by the 32-bit query. We do
that by filling the temporal buffer by negatives, as the 32-bit query
should not return negative values ever.
---
 src/mesa/main/formatquery.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index ce384a0..a67c9da 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -1017,6 +1017,7 @@ _mesa_GetInternalformati64v(GLenum target, GLenum internalformat,
 {
    GLint params32[16];
    unsigned i;
+   GLsizei realSize = MIN2(bufSize, 16);
 
    GET_CURRENT_CONTEXT(ctx);
 
@@ -1027,8 +1028,18 @@ _mesa_GetInternalformati64v(GLenum target, GLenum internalformat,
       return;
    }
 
-   _mesa_GetInternalformativ(target, internalformat, pname, bufSize, params32);
+   /* For SAMPLES there are cases where params needs to remain unmodified. As
+    * no pname can return a negative value, we fill params32 with negative
+    * values as reference values, that can be used to know what copy-back to
+    * params */
+   memset(params32, -1, 16);
 
-   for (i = 0; i < bufSize; i++)
-      params[i] = params32[i];
+   _mesa_GetInternalformativ(target, internalformat, pname, realSize, params32);
+
+   for (i = 0; i < realSize; i++) {
+      /* We only copy back the values that changed */
+      if (params32[i] < 0)
+         break;
+      params[i] = (GLint64) params32[i];
+   }
 }
-- 
2.5.3



More information about the mesa-dev mailing list