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

Ilia Mirkin imirkin at alum.mit.edu
Sun Aug 28 18:32:19 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 0aa9065..fb9a86f 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)
 
@@ -466,6 +468,7 @@ EXTRA_EXT(NVX_gpu_memory_info);
 EXTRA_EXT(ARB_cull_distance);
 EXTRA_EXT(EXT_window_rectangles);
 EXTRA_EXT(KHR_blend_equation_advanced_coherent);
+EXTRA_EXT(OES_primitive_bounding_box);
 
 static const int
 extra_ARB_color_buffer_float_or_glcore[] = {
@@ -1390,6 +1393,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]);
@@ -1478,6 +1486,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];
@@ -1566,6 +1579,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:
@@ -1660,6 +1678,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:
@@ -1754,6 +1777,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 35af48b..a206c85 100644
--- a/src/mesa/main/get_hash_params.py
+++ b/src/mesa/main/get_hash_params.py
@@ -607,6 +607,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 5729059..f8f9c46 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -4672,6 +4672,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