glsl: add gl_BoundingBox and associated varying slots
authorIlia Mirkin <imirkin@alum.mit.edu>
Mon, 30 May 2016 15:50:07 +0000 (11:50 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Wed, 31 Aug 2016 00:25:15 +0000 (20:25 -0400)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/compiler/glsl/builtin_variables.cpp
src/compiler/glsl/ir_set_program_inouts.cpp
src/compiler/shader_enums.c
src/compiler/shader_enums.h
src/mesa/main/mtypes.h
src/mesa/program/prog_print.c

index f4ddeb99cde99c5a61e309a94d7174ac68f1c816..90278d635c68c32f13ef74b0825e65d0457b5006 100644 (file)
@@ -1045,6 +1045,18 @@ builtin_variable_generator::generate_tcs_special_vars()
               "gl_TessLevelOuter")->data.patch = 1;
    add_output(VARYING_SLOT_TESS_LEVEL_INNER, array(float_t, 2),
               "gl_TessLevelInner")->data.patch = 1;
+   /* XXX What to do if multiple are flipped on? */
+   int bbox_slot = state->ctx->Const.NoPrimitiveBoundingBoxOutput ? -1 :
+      VARYING_SLOT_BOUNDING_BOX0;
+   if (state->EXT_primitive_bounding_box_enable)
+      add_output(bbox_slot, array(vec4_t, 2), "gl_BoundingBoxEXT")
+         ->data.patch = 1;
+   if (state->OES_primitive_bounding_box_enable)
+      add_output(bbox_slot, array(vec4_t, 2), "gl_BoundingBoxOES")
+         ->data.patch = 1;
+   if (state->is_version(0, 320) || state->ARB_ES3_2_compatibility_enable)
+      add_output(bbox_slot, array(vec4_t, 2), "gl_BoundingBox")
+         ->data.patch = 1;
 }
 
 
index 4f6c886b6b3f56a0a59237e2b6c5a7dc90484632..48ed3c5c9e28e44fca24b127aab1ea4e8d48e636 100644 (file)
@@ -99,7 +99,9 @@ mark(struct gl_program *prog, ir_variable *var, int offset, int len,
       int idx = var->data.location + offset + i;
       bool is_patch_generic = var->data.patch &&
                               idx != VARYING_SLOT_TESS_LEVEL_INNER &&
-                              idx != VARYING_SLOT_TESS_LEVEL_OUTER;
+                              idx != VARYING_SLOT_TESS_LEVEL_OUTER &&
+                              idx != VARYING_SLOT_BOUNDING_BOX0 &&
+                              idx != VARYING_SLOT_BOUNDING_BOX1;
       GLbitfield64 bitfield;
 
       if (is_patch_generic) {
index 00261d1988c5bea23cc732e0371a7f660496972b..729a3583b1bcd4fc4ed08552e9c18119ad462d29 100644 (file)
@@ -158,6 +158,8 @@ gl_varying_slot_name(gl_varying_slot slot)
       ENUM(VARYING_SLOT_PNTC),
       ENUM(VARYING_SLOT_TESS_LEVEL_OUTER),
       ENUM(VARYING_SLOT_TESS_LEVEL_INNER),
+      ENUM(VARYING_SLOT_BOUNDING_BOX0),
+      ENUM(VARYING_SLOT_BOUNDING_BOX1),
       ENUM(VARYING_SLOT_VAR0),
       ENUM(VARYING_SLOT_VAR1),
       ENUM(VARYING_SLOT_VAR2),
index e128b172c20bc03aee6ccdbbac9c1a4449f703db..c3a62e09dbeb7180af84b4586181d79dc88581d0 100644 (file)
@@ -214,6 +214,8 @@ typedef enum
    VARYING_SLOT_PNTC, /* FS only */
    VARYING_SLOT_TESS_LEVEL_OUTER, /* Only appears as TCS output. */
    VARYING_SLOT_TESS_LEVEL_INNER, /* Only appears as TCS output. */
+   VARYING_SLOT_BOUNDING_BOX0, /* Only appears as TCS output. */
+   VARYING_SLOT_BOUNDING_BOX1, /* Only appears as TCS output. */
    VARYING_SLOT_VAR0, /* First generic varying slot */
    /* the remaining are simply for the benefit of gl_varying_slot_name()
     * and not to be construed as an upper bound:
@@ -294,6 +296,8 @@ const char *gl_varying_slot_name(gl_varying_slot slot);
 #define VARYING_BIT_PNTC BITFIELD64_BIT(VARYING_SLOT_PNTC)
 #define VARYING_BIT_TESS_LEVEL_OUTER BITFIELD64_BIT(VARYING_SLOT_TESS_LEVEL_OUTER)
 #define VARYING_BIT_TESS_LEVEL_INNER BITFIELD64_BIT(VARYING_SLOT_TESS_LEVEL_INNER)
+#define VARYING_BIT_BOUNDING_BOX0 BITFIELD64_BIT(VARYING_SLOT_BOUNDING_BOX0)
+#define VARYING_BIT_BOUNDING_BOX1 BITFIELD64_BIT(VARYING_SLOT_BOUNDING_BOX1)
 #define VARYING_BIT_VAR(V) BITFIELD64_BIT(VARYING_SLOT_VAR0 + (V))
 /*@}*/
 
index d2bc0b5fa900410472bc2eec26e655f20864e349..df934469d05f08e84bef063490eef60802863626 100644 (file)
@@ -110,6 +110,8 @@ _mesa_varying_slot_in_fs(gl_varying_slot slot)
    case VARYING_SLOT_LAYER:
    case VARYING_SLOT_TESS_LEVEL_OUTER:
    case VARYING_SLOT_TESS_LEVEL_INNER:
+   case VARYING_SLOT_BOUNDING_BOX0:
+   case VARYING_SLOT_BOUNDING_BOX1:
       return GL_FALSE;
    default:
       return GL_TRUE;
@@ -3789,6 +3791,9 @@ struct gl_constants
    bool LowerCsDerivedVariables;    /**< Lower gl_GlobalInvocationID and
                                      *   gl_LocalInvocationIndex based on
                                      *   other builtin variables. */
+
+   /** GL_OES_primitive_bounding_box */
+   bool NoPrimitiveBoundingBoxOutput;
 };
 
 
index b8d7cca2f3b46066262b43f820515e905c688a47..7a7d27454604c878152c78d7f721e0bc86dfc0dd 100644 (file)
@@ -151,6 +151,8 @@ arb_input_attrib_string(GLuint index, GLenum progType)
       "fragment.(twenty-five)", /* VARYING_SLOT_TESS_LEVEL_INNER */
       "fragment.(twenty-six)", /* VARYING_SLOT_CULL_DIST0 */
       "fragment.(twenty-seven)", /* VARYING_SLOT_CULL_DIST1 */
+      "fragment.(twenty-eight)", /* VARYING_SLOT_BOUNDING_BOX0 */
+      "fragment.(twenty-nine)", /* VARYING_SLOT_BOUNDING_BOX1 */
       "fragment.varying[0]",
       "fragment.varying[1]",
       "fragment.varying[2]",
@@ -280,6 +282,8 @@ arb_output_attrib_string(GLuint index, GLenum progType)
       "result.(twenty-five)", /* VARYING_SLOT_TESS_LEVEL_INNER */
       "result.(twenty-six)", /* VARYING_SLOT_CULL_DIST0 */
       "result.(twenty-seven)", /* VARYING_SLOT_CULL_DIST1 */
+      "result.(twenty-eight)", /* VARYING_SLOT_BOUNDING_BOX0 */
+      "result.(twenty-nine)", /* VARYING_SLOT_BOUNDING_BOX1 */
       "result.varying[0]",
       "result.varying[1]",
       "result.varying[2]",