[Mesa-dev] [PATCH 2/3] mesa: add support for GL_PRIMITIVE_BOUNDING_BOX storage and query

Ilia Mirkin imirkin at alum.mit.edu
Mon May 30 18:00:20 UTC 2016


Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
 src/mesa/main/bbox.c             | 19 +++++++++++++++++++
 src/mesa/main/get.c              | 28 ++++++++++++++++++++++++++++
 src/mesa/main/get_hash_params.py |  3 +++
 src/mesa/main/mtypes.h           |  7 +++++++
 4 files changed, 57 insertions(+)

diff --git a/src/mesa/main/bbox.c b/src/mesa/main/bbox.c
index 0ef5705..2184330 100644
--- a/src/mesa/main/bbox.c
+++ b/src/mesa/main/bbox.c
@@ -36,9 +36,28 @@ _mesa_PrimitiveBoundingBox(
       GLfloat minX, GLfloat minY, GLfloat minZ, GLfloat minW,
       GLfloat maxX, GLfloat maxY, GLfloat maxZ, GLfloat maxW)
 {
+   GET_CURRENT_CONTEXT(ctx);
+
+   ctx->PrimitiveBoundingBox[0] = minX;
+   ctx->PrimitiveBoundingBox[1] = minY;
+   ctx->PrimitiveBoundingBox[2] = minZ;
+   ctx->PrimitiveBoundingBox[3] = minW;
+   ctx->PrimitiveBoundingBox[4] = maxX;
+   ctx->PrimitiveBoundingBox[5] = maxY;
+   ctx->PrimitiveBoundingBox[6] = maxZ;
+   ctx->PrimitiveBoundingBox[7] = maxW;
 }
 
 void
 _mesa_init_bbox(struct gl_context *ctx)
 {
+   ctx->PrimitiveBoundingBox[0] =
+   ctx->PrimitiveBoundingBox[1] =
+   ctx->PrimitiveBoundingBox[2] = -1.0f;
+
+   ctx->PrimitiveBoundingBox[3] =
+   ctx->PrimitiveBoundingBox[4] =
+   ctx->PrimitiveBoundingBox[5] =
+   ctx->PrimitiveBoundingBox[6] =
+   ctx->PrimitiveBoundingBox[7] = 1.0f;
 }
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 9f70749..8d74b2e 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -111,6 +111,7 @@ enum value_type {
    TYPE_FLOAT_2,
    TYPE_FLOAT_3,
    TYPE_FLOAT_4,
+   TYPE_FLOAT_8,
    TYPE_FLOATN,
    TYPE_FLOATN_2,
    TYPE_FLOATN_3,
@@ -218,6 +219,7 @@ union value {
 #define CONTEXT_FLOAT2(field) CONTEXT_FIELD(field, TYPE_FLOAT_2)
 #define CONTEXT_FLOAT3(field) CONTEXT_FIELD(field, TYPE_FLOAT_3)
 #define CONTEXT_FLOAT4(field) CONTEXT_FIELD(field, TYPE_FLOAT_4)
+#define CONTEXT_FLOAT8(field) CONTEXT_FIELD(field, TYPE_FLOAT_8)
 #define CONTEXT_MATRIX(field) CONTEXT_FIELD(field, TYPE_MATRIX)
 #define CONTEXT_MATRIX_T(field) CONTEXT_FIELD(field, TYPE_MATRIX_T)
 
@@ -464,6 +466,7 @@ EXTRA_EXT(ARB_indirect_parameters);
 EXTRA_EXT(ATI_meminfo);
 EXTRA_EXT(NVX_gpu_memory_info);
 EXTRA_EXT(ARB_cull_distance);
+EXTRA_EXT(OES_primitive_bounding_box);
 
 static const int
 extra_ARB_color_buffer_float_or_glcore[] = {
@@ -1446,6 +1449,11 @@ _mesa_GetBooleanv(GLenum pname, GLboolean *params)
       params[0] = INT_TO_BOOLEAN(d->offset);
       break;
 
+   case TYPE_FLOAT_8:
+      params[7] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[7]);
+      params[6] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[6]);
+      params[5] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[5]);
+      params[4] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[4]);
    case TYPE_FLOAT_4:
    case TYPE_FLOATN_4:
       params[3] = FLOAT_TO_BOOLEAN(((GLfloat *) p)[3]);
@@ -1534,6 +1542,11 @@ _mesa_GetFloatv(GLenum pname, GLfloat *params)
       params[0] = (GLfloat) d->offset;
       break;
 
+   case TYPE_FLOAT_8:
+      params[7] = ((GLfloat *) p)[7];
+      params[6] = ((GLfloat *) p)[6];
+      params[5] = ((GLfloat *) p)[5];
+      params[4] = ((GLfloat *) p)[4];
    case TYPE_FLOAT_4:
    case TYPE_FLOATN_4:
       params[3] = ((GLfloat *) p)[3];
@@ -1622,6 +1635,11 @@ _mesa_GetIntegerv(GLenum pname, GLint *params)
       params[0] = d->offset;
       break;
 
+   case TYPE_FLOAT_8:
+      params[7] = IROUND(((GLfloat *) p)[7]);
+      params[6] = IROUND(((GLfloat *) p)[6]);
+      params[5] = IROUND(((GLfloat *) p)[5]);
+      params[4] = IROUND(((GLfloat *) p)[4]);
    case TYPE_FLOAT_4:
       params[3] = IROUND(((GLfloat *) p)[3]);
    case TYPE_FLOAT_3:
@@ -1716,6 +1734,11 @@ _mesa_GetInteger64v(GLenum pname, GLint64 *params)
       params[0] = d->offset;
       break;
 
+   case TYPE_FLOAT_8:
+      params[7] = IROUND64(((GLfloat *) p)[7]);
+      params[6] = IROUND64(((GLfloat *) p)[6]);
+      params[5] = IROUND64(((GLfloat *) p)[5]);
+      params[4] = IROUND64(((GLfloat *) p)[4]);
    case TYPE_FLOAT_4:
       params[3] = IROUND64(((GLfloat *) p)[3]);
    case TYPE_FLOAT_3:
@@ -1810,6 +1833,11 @@ _mesa_GetDoublev(GLenum pname, GLdouble *params)
       params[0] = d->offset;
       break;
 
+   case TYPE_FLOAT_8:
+      params[7] = ((GLfloat *) p)[7];
+      params[6] = ((GLfloat *) p)[6];
+      params[5] = ((GLfloat *) p)[5];
+      params[4] = ((GLfloat *) p)[4];
    case TYPE_FLOAT_4:
    case TYPE_FLOATN_4:
       params[3] = ((GLfloat *) p)[3];
diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py
index 2124072..173c076 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -556,6 +556,9 @@ descriptor=[
 
 # GL_ARB_texture_buffer_range
   [ "TEXTURE_BUFFER_OFFSET_ALIGNMENT", "CONTEXT_INT(Const.TextureBufferOffsetAlignment), extra_ARB_texture_buffer_range" ],
+
+# GL_OES_primitive_bounding_box
+  [ "PRIMITIVE_BOUNDING_BOX_ARB", "CONTEXT_FLOAT8(PrimitiveBoundingBox), extra_OES_primitive_bounding_box" ],
 ]},
 
 # Remaining enums are only in OpenGL
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 4fd317d..88438f0 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4632,6 +4632,13 @@ struct gl_context
     * Once this field becomes true, it is never reset to false.
     */
    GLboolean ShareGroupReset;
+
+   /**
+    * \name OES_primitive_bounding_box
+    *
+    * Stores the arguments to glPrimitiveBoundingBox
+    */
+   GLfloat PrimitiveBoundingBox[8];
 };
 
 /**
-- 
2.7.3



More information about the mesa-dev mailing list