[Mesa-dev] [PATCH 3/3] glsl: add gl_BoundingBox and associated varying slots

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


Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
 src/compiler/glsl/builtin_variables.cpp     | 10 ++++++++++
 src/compiler/glsl/ir_set_program_inouts.cpp |  4 +++-
 src/compiler/shader_enums.c                 |  2 ++
 src/compiler/shader_enums.h                 |  4 ++++
 src/mesa/main/mtypes.h                      |  2 ++
 src/mesa/program/prog_print.c               |  4 ++++
 6 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/src/compiler/glsl/builtin_variables.cpp b/src/compiler/glsl/builtin_variables.cpp
index 22d16de..b2c9c63 100644
--- a/src/compiler/glsl/builtin_variables.cpp
+++ b/src/compiler/glsl/builtin_variables.cpp
@@ -1036,6 +1036,16 @@ 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? */
+   if (state->EXT_primitive_bounding_box_enable)
+      add_output(VARYING_SLOT_BOUNDING_BOX0, array(vec4_t, 2),
+                 "gl_BoundingBoxEXT")->data.patch = 1;
+   if (state->OES_primitive_bounding_box_enable)
+      add_output(VARYING_SLOT_BOUNDING_BOX0, array(vec4_t, 2),
+                 "gl_BoundingBoxOES")->data.patch = 1;
+   if (state->is_version(0, 320) || state->ARB_ES3_2_compatibility_enable)
+      add_output(VARYING_SLOT_BOUNDING_BOX0, array(vec4_t, 2),
+                 "gl_BoundingBox")->data.patch = 1;
 }
 
 
diff --git a/src/compiler/glsl/ir_set_program_inouts.cpp b/src/compiler/glsl/ir_set_program_inouts.cpp
index 183b13b..1e2c4b0 100644
--- a/src/compiler/glsl/ir_set_program_inouts.cpp
+++ b/src/compiler/glsl/ir_set_program_inouts.cpp
@@ -99,7 +99,9 @@ mark(struct gl_program *prog, ir_variable *var, int offset, int len,
       int idx = var->data.location + var->data.index + 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) {
diff --git a/src/compiler/shader_enums.c b/src/compiler/shader_enums.c
index ff2f564..f49a862 100644
--- a/src/compiler/shader_enums.c
+++ b/src/compiler/shader_enums.c
@@ -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),
diff --git a/src/compiler/shader_enums.h b/src/compiler/shader_enums.h
index df3124e..48122b5 100644
--- a/src/compiler/shader_enums.h
+++ b/src/compiler/shader_enums.h
@@ -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))
 /*@}*/
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 88438f0..3c6e1f4 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -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;
diff --git a/src/mesa/program/prog_print.c b/src/mesa/program/prog_print.c
index 755d644..4116a6f 100644
--- a/src/mesa/program/prog_print.c
+++ b/src/mesa/program/prog_print.c
@@ -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]",
-- 
2.7.3



More information about the mesa-dev mailing list