[Mesa-dev] [PATCH 25/26] mesa: add LOCATION_COMPONENT support to GetProgramResourceiv

Timothy Arceri timothy.arceri at collabora.com
Mon Feb 29 01:18:05 UTC 2016


>From Section 7.3.1.1 (Naming Active Resources) of the OpenGL 4.5 spec:

   "For the property LOCATION_COMPONENT, a single integer indicating the first
   component of the location assigned to an active input or output variable is
   written to params. For input and output variables with a component specified
   by a layout qualifier, the specified component is written. For all other
   input and output variables, the value zero is written."

V2: rebase on 8926dc87

Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
---
 src/compiler/glsl/linker.cpp   | 1 +
 src/mesa/main/mtypes.h         | 6 ++++++
 src/mesa/main/shader_query.cpp | 9 +++++++++
 3 files changed, 16 insertions(+)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index a4d83e1..cd5cf53 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -3491,6 +3491,7 @@ create_shader_variable(struct gl_shader_program *shProg, const ir_variable *in)
       return NULL;
 
    out->location = in->data.location;
+   out->component = in->data.location_frac;
    out->index = in->data.index;
    out->patch = in->data.patch;
    out->mode = in->data.mode;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 12d3863..3200f47 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2582,6 +2582,12 @@ struct gl_shader_variable
    int location;
 
    /**
+    * Specifies the first component the variable is stored in as per
+    * ARB_enhanced_layouts.
+    */
+   unsigned component:2;
+
+   /**
     * Output index for dual source blending.
     *
     * \note
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 4967e4b..f63ffd8 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -1249,6 +1249,15 @@ _mesa_program_resource_prop(struct gl_shader_program *shProg,
       default:
          goto invalid_operation;
       }
+   case GL_LOCATION_COMPONENT:
+      switch (res->Type) {
+      case GL_PROGRAM_INPUT:
+      case GL_PROGRAM_OUTPUT:
+         *val = RESOURCE_VAR(res)->component;
+         return 1;
+      default:
+         goto invalid_operation;
+      }
    case GL_LOCATION_INDEX:
       if (res->Type != GL_PROGRAM_OUTPUT)
          goto invalid_operation;
-- 
2.5.0



More information about the mesa-dev mailing list