mesa: add LOCATION_COMPONENT support to GetProgramResourceiv
authorTimothy Arceri <timothy.arceri@collabora.com>
Fri, 27 Nov 2015 22:16:45 +0000 (09:16 +1100)
committerTimothy Arceri <timothy.arceri@collabora.com>
Sun, 1 May 2016 13:13:36 +0000 (23:13 +1000)
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."

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
src/compiler/glsl/linker.cpp
src/mesa/main/mtypes.h
src/mesa/main/shader_query.cpp

index f7b884e0173eb671a37e85b6ee1bfc1804a4da78..9c724782e4d960ff09679554abfe0b3db0a6bc68 100644 (file)
@@ -3570,6 +3570,7 @@ create_shader_variable(struct gl_shader_program *shProg,
    }
 
    out->type = type;
+   out->component = in->data.location_frac;
    out->index = in->data.index;
    out->patch = in->data.patch;
    out->mode = in->data.mode;
index 46b1543b56c752a4566c99588c4b58c5cebeb165..628385429205296709e4a14f23ae0db3684e6a2e 100644 (file)
@@ -2570,6 +2570,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.
     *
index 2c1a6ee35051ff3e1ac0fe1ab799c38b17425e2f..020990ae9bf395686dd41ba73c0133266cb2ee74 100644 (file)
@@ -1216,6 +1216,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;