Looks fine :

Reviewed-by: Lionel Landwerlin <lionel.g.landwer...@intel.com>

On 09/01/17 05:13, Timothy Arceri wrote:
We also move NumProgramResourceList at the same time.

GLES does interface validation on SSO at runtime so we need to move
this to be able to switch to storing gl_program pointers in
CurrentProgram.
---
  src/compiler/glsl/linker.cpp     | 20 +++++++++----------
  src/mesa/main/mtypes.h           |  8 ++++----
  src/mesa/main/program_resource.c | 40 ++++++++++++++++++-------------------
  src/mesa/main/shader_query.cpp   | 43 +++++++++++++++++++++++-----------------
  src/mesa/main/shaderobj.c        |  8 ++++----
  5 files changed, 63 insertions(+), 56 deletions(-)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index d187b66..dfee70a 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -3534,25 +3534,25 @@ add_program_resource(struct gl_shader_program *prog,
     if (_mesa_set_search(resource_set, data))
        return true;
- prog->ProgramResourceList =
+   prog->data->ProgramResourceList =
        reralloc(prog,
-               prog->ProgramResourceList,
+               prog->data->ProgramResourceList,
                 gl_program_resource,
-               prog->NumProgramResourceList + 1);
+               prog->data->NumProgramResourceList + 1);
- if (!prog->ProgramResourceList) {
+   if (!prog->data->ProgramResourceList) {
        linker_error(prog, "Out of memory during linking.\n");
        return false;
     }
struct gl_program_resource *res =
-      &prog->ProgramResourceList[prog->NumProgramResourceList];
+      &prog->data->ProgramResourceList[prog->data->NumProgramResourceList];
res->Type = type;
     res->Data = data;
     res->StageReferences = stages;
- prog->NumProgramResourceList++;
+   prog->data->NumProgramResourceList++;
_mesa_set_add(resource_set, data); @@ -4196,10 +4196,10 @@ build_program_resource_list(struct gl_context *ctx,
                              struct gl_shader_program *shProg)
  {
     /* Rebuild resource list. */
-   if (shProg->ProgramResourceList) {
-      ralloc_free(shProg->ProgramResourceList);
-      shProg->ProgramResourceList = NULL;
-      shProg->NumProgramResourceList = 0;
+   if (shProg->data->ProgramResourceList) {
+      ralloc_free(shProg->data->ProgramResourceList);
+      shProg->data->ProgramResourceList = NULL;
+      shProg->data->NumProgramResourceList = 0;
     }
int input_stage = MESA_SHADER_STAGES, output_stage = 0;
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 793a527..8608b66 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2668,6 +2668,10 @@ struct gl_shader_program_data
     struct gl_active_atomic_buffer *AtomicBuffers;
     unsigned NumAtomicBuffers;
+ /** List of all active resources after linking. */
+   struct gl_program_resource *ProgramResourceList;
+   unsigned NumProgramResourceList;
+
     GLboolean LinkStatus;   /**< GL_LINK_STATUS */
     GLboolean Validated;
     GLchar *InfoLog;
@@ -2857,10 +2861,6 @@ struct gl_shader_program
      */
     struct gl_linked_shader *_LinkedShaders[MESA_SHADER_STAGES];
- /** List of all active resources after linking. */
-   struct gl_program_resource *ProgramResourceList;
-   unsigned NumProgramResourceList;
-
     /* True if any of the fragment shaders attached to this program use:
      * #extension ARB_fragment_coord_conventions: enable
      */
diff --git a/src/mesa/main/program_resource.c b/src/mesa/main/program_resource.c
index 5461c4e..4b5be6f 100644
--- a/src/mesa/main/program_resource.c
+++ b/src/mesa/main/program_resource.c
@@ -119,8 +119,8 @@ _mesa_GetProgramInterfaceiv(GLuint program, GLenum 
programInterface,
     /* Validate pname against interface. */
     switch(pname) {
     case GL_ACTIVE_RESOURCES:
-      for (i = 0, *params = 0; i < shProg->NumProgramResourceList; i++)
-         if (shProg->ProgramResourceList[i].Type == programInterface)
+      for (i = 0, *params = 0; i < shProg->data->NumProgramResourceList; i++)
+         if (shProg->data->ProgramResourceList[i].Type == programInterface)
              (*params)++;
        break;
     case GL_MAX_NAME_LENGTH:
@@ -135,32 +135,32 @@ _mesa_GetProgramInterfaceiv(GLuint program, GLenum 
programInterface,
        /* Name length consists of base name, 3 additional chars '[0]' if
         * resource is an array and finally 1 char for string terminator.
         */
-      for (i = 0, *params = 0; i < shProg->NumProgramResourceList; i++) {
-         if (shProg->ProgramResourceList[i].Type != programInterface)
+      for (i = 0, *params = 0; i < shProg->data->NumProgramResourceList; i++) {
+         if (shProg->data->ProgramResourceList[i].Type != programInterface)
              continue;
           unsigned len =
-            _mesa_program_resource_name_len(&shProg->ProgramResourceList[i]);
+            
_mesa_program_resource_name_len(&shProg->data->ProgramResourceList[i]);
           *params = MAX2(*params, len + 1);
        }
        break;
     case GL_MAX_NUM_ACTIVE_VARIABLES:
        switch (programInterface) {
        case GL_UNIFORM_BLOCK:
-         for (i = 0, *params = 0; i < shProg->NumProgramResourceList; i++) {
-            if (shProg->ProgramResourceList[i].Type == programInterface) {
+         for (i = 0, *params = 0; i < shProg->data->NumProgramResourceList; 
i++) {
+            if (shProg->data->ProgramResourceList[i].Type == programInterface) 
{
                 struct gl_uniform_block *block =
                    (struct gl_uniform_block *)
-                  shProg->ProgramResourceList[i].Data;
+                  shProg->data->ProgramResourceList[i].Data;
                 *params = MAX2(*params, block->NumUniforms);
              }
           }
           break;
        case GL_SHADER_STORAGE_BLOCK:
-         for (i = 0, *params = 0; i < shProg->NumProgramResourceList; i++) {
-            if (shProg->ProgramResourceList[i].Type == programInterface) {
+         for (i = 0, *params = 0; i < shProg->data->NumProgramResourceList; 
i++) {
+            if (shProg->data->ProgramResourceList[i].Type == programInterface) 
{
                 struct gl_uniform_block *block =
                    (struct gl_uniform_block *)
-                  shProg->ProgramResourceList[i].Data;
+                  shProg->data->ProgramResourceList[i].Data;
                 GLint block_params = 0;
                 for (unsigned j = 0; j < block->NumUniforms; j++) {
                    const char *iname = block->Uniforms[j].IndexName;
@@ -176,21 +176,21 @@ _mesa_GetProgramInterfaceiv(GLuint program, GLenum 
programInterface,
           }
           break;
        case GL_ATOMIC_COUNTER_BUFFER:
-         for (i = 0, *params = 0; i < shProg->NumProgramResourceList; i++) {
-            if (shProg->ProgramResourceList[i].Type == programInterface) {
+         for (i = 0, *params = 0; i < shProg->data->NumProgramResourceList; 
i++) {
+            if (shProg->data->ProgramResourceList[i].Type == programInterface) 
{
                 struct gl_active_atomic_buffer *buffer =
                    (struct gl_active_atomic_buffer *)
-                  shProg->ProgramResourceList[i].Data;
+                  shProg->data->ProgramResourceList[i].Data;
                 *params = MAX2(*params, buffer->NumUniforms);
              }
           }
           break;
        case GL_TRANSFORM_FEEDBACK_BUFFER:
-         for (i = 0, *params = 0; i < shProg->NumProgramResourceList; i++) {
-            if (shProg->ProgramResourceList[i].Type == programInterface) {
+         for (i = 0, *params = 0; i < shProg->data->NumProgramResourceList; 
i++) {
+            if (shProg->data->ProgramResourceList[i].Type == programInterface) 
{
                 struct gl_transform_feedback_buffer *buffer =
                    (struct gl_transform_feedback_buffer *)
-                  shProg->ProgramResourceList[i].Data;
+                  shProg->data->ProgramResourceList[i].Data;
                 *params = MAX2(*params, buffer->NumVaryings);
              }
           }
@@ -210,11 +210,11 @@ _mesa_GetProgramInterfaceiv(GLuint program, GLenum 
programInterface,
        case GL_COMPUTE_SUBROUTINE_UNIFORM:
        case GL_TESS_CONTROL_SUBROUTINE_UNIFORM:
        case GL_TESS_EVALUATION_SUBROUTINE_UNIFORM: {
-         for (i = 0, *params = 0; i < shProg->NumProgramResourceList; i++) {
-            if (shProg->ProgramResourceList[i].Type == programInterface) {
+         for (i = 0, *params = 0; i < shProg->data->NumProgramResourceList; 
i++) {
+            if (shProg->data->ProgramResourceList[i].Type == programInterface) 
{
                 struct gl_uniform_storage *uni =
                    (struct gl_uniform_storage *)
-                  shProg->ProgramResourceList[i].Data;
+                  shProg->data->ProgramResourceList[i].Data;
                 *params = MAX2(*params, uni->num_compatible_subroutines);
              }
           }
diff --git a/src/mesa/main/shader_query.cpp b/src/mesa/main/shader_query.cpp
index 0f4b282..4010737 100644
--- a/src/mesa/main/shader_query.cpp
+++ b/src/mesa/main/shader_query.cpp
@@ -198,9 +198,10 @@ _mesa_count_active_attribs(struct gl_shader_program 
*shProg)
        return 0;
     }
- struct gl_program_resource *res = shProg->ProgramResourceList;
+   struct gl_program_resource *res = shProg->data->ProgramResourceList;
     unsigned count = 0;
-   for (unsigned j = 0; j < shProg->NumProgramResourceList; j++, res++) {
+   for (unsigned j = 0; j < shProg->data->NumProgramResourceList;
+        j++, res++) {
        if (res->Type == GL_PROGRAM_INPUT &&
            res->StageReferences & (1 << MESA_SHADER_VERTEX))
           count++;
@@ -217,9 +218,10 @@ _mesa_longest_attribute_name_length(struct 
gl_shader_program *shProg)
        return 0;
     }
- struct gl_program_resource *res = shProg->ProgramResourceList;
+   struct gl_program_resource *res = shProg->data->ProgramResourceList;
     size_t longest = 0;
-   for (unsigned j = 0; j < shProg->NumProgramResourceList; j++, res++) {
+   for (unsigned j = 0; j < shProg->data->NumProgramResourceList;
+        j++, res++) {
        if (res->Type == GL_PROGRAM_INPUT &&
            res->StageReferences & (1 << MESA_SHADER_VERTEX)) {
@@ -466,8 +468,9 @@ _mesa_program_resource_find_name(struct gl_shader_program *shProg,
                                   GLenum programInterface, const char *name,
                                   unsigned *array_index)
  {
-   struct gl_program_resource *res = shProg->ProgramResourceList;
-   for (unsigned i = 0; i < shProg->NumProgramResourceList; i++, res++) {
+   struct gl_program_resource *res = shProg->data->ProgramResourceList;
+   for (unsigned i = 0; i < shProg->data->NumProgramResourceList;
+        i++, res++) {
        if (res->Type != programInterface)
           continue;
@@ -570,10 +573,10 @@ calc_resource_index(struct gl_shader_program *shProg,
  {
     unsigned i;
     GLuint index = 0;
-   for (i = 0; i < shProg->NumProgramResourceList; i++) {
-      if (&shProg->ProgramResourceList[i] == res)
+   for (i = 0; i < shProg->data->NumProgramResourceList; i++) {
+      if (&shProg->data->ProgramResourceList[i] == res)
           return index;
-      if (shProg->ProgramResourceList[i].Type == res->Type)
+      if (shProg->data->ProgramResourceList[i].Type == res->Type)
           index++;
     }
     return GL_INVALID_INDEX;
@@ -614,8 +617,9 @@ _mesa_program_resource_index(struct gl_shader_program 
*shProg,
  static struct gl_program_resource*
  program_resource_find_data(struct gl_shader_program *shProg, void *data)
  {
-   struct gl_program_resource *res = shProg->ProgramResourceList;
-   for (unsigned i = 0; i < shProg->NumProgramResourceList; i++, res++) {
+   struct gl_program_resource *res = shProg->data->ProgramResourceList;
+   for (unsigned i = 0; i < shProg->data->NumProgramResourceList;
+        i++, res++) {
        if (res->Data == data)
           return res;
     }
@@ -628,10 +632,11 @@ struct gl_program_resource *
  _mesa_program_resource_find_index(struct gl_shader_program *shProg,
                                    GLenum programInterface, GLuint index)
  {
-   struct gl_program_resource *res = shProg->ProgramResourceList;
+   struct gl_program_resource *res = shProg->data->ProgramResourceList;
     int idx = -1;
- for (unsigned i = 0; i < shProg->NumProgramResourceList; i++, res++) {
+   for (unsigned i = 0; i < shProg->data->NumProgramResourceList;
+        i++, res++) {
        if (res->Type != programInterface)
           continue;
@@ -1385,7 +1390,7 @@ validate_io(struct gl_shader_program *producer,
     bool valid = true;
gl_shader_variable const **outputs =
-      (gl_shader_variable const **) calloc(producer->NumProgramResourceList,
+      (gl_shader_variable const **) 
calloc(producer->data->NumProgramResourceList,
                                             sizeof(gl_shader_variable *));
     if (outputs == NULL)
        return false;
@@ -1408,8 +1413,9 @@ validate_io(struct gl_shader_program *producer,
      * some output that did not have an input.
      */
     unsigned num_outputs = 0;
-   for (unsigned i = 0; i < producer->NumProgramResourceList; i++) {
-      struct gl_program_resource *res = &producer->ProgramResourceList[i];
+   for (unsigned i = 0; i < producer->data->NumProgramResourceList; i++) {
+      struct gl_program_resource *res =
+         &producer->data->ProgramResourceList[i];
if (res->Type != GL_PROGRAM_OUTPUT)
           continue;
@@ -1428,8 +1434,9 @@ validate_io(struct gl_shader_program *producer,
     }
unsigned match_index = 0;
-   for (unsigned i = 0; i < consumer->NumProgramResourceList; i++) {
-      struct gl_program_resource *res = &consumer->ProgramResourceList[i];
+   for (unsigned i = 0; i < consumer->data->NumProgramResourceList; i++) {
+      struct gl_program_resource *res =
+         &consumer->data->ProgramResourceList[i];
if (res->Type != GL_PROGRAM_INPUT)
           continue;
diff --git a/src/mesa/main/shaderobj.c b/src/mesa/main/shaderobj.c
index 7b73f56..4e514a3 100644
--- a/src/mesa/main/shaderobj.c
+++ b/src/mesa/main/shaderobj.c
@@ -364,10 +364,10 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
     shProg->data->AtomicBuffers = NULL;
     shProg->data->NumAtomicBuffers = 0;
- if (shProg->ProgramResourceList) {
-      ralloc_free(shProg->ProgramResourceList);
-      shProg->ProgramResourceList = NULL;
-      shProg->NumProgramResourceList = 0;
+   if (shProg->data->ProgramResourceList) {
+      ralloc_free(shProg->data->ProgramResourceList);
+      shProg->data->ProgramResourceList = NULL;
+      shProg->data->NumProgramResourceList = 0;
     }
  }


_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to