glsl: remember which SSBOs are not read-only and pass it to gallium
authorMarek Olšák <marek.olsak@amd.com>
Wed, 3 Apr 2019 18:22:16 +0000 (14:22 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 4 Apr 2019 23:28:52 +0000 (19:28 -0400)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/glsl/link_uniforms.cpp
src/compiler/glsl/serialize.cpp
src/mesa/main/mtypes.h
src/mesa/state_tracker/st_atom_storagebuf.c

index 8ca140dcaa806db0bf2256f4a9b7e3cced96d83f..ef1241119912513803aa27bb374f69c15f83f00e 100644 (file)
@@ -504,6 +504,7 @@ public:
       this->next_bindless_image = 0;
       free(this->bindless_access);
       this->bindless_access = NULL;
+      this->shader_storage_blocks_write_access = 0;
    }
 
    void set_and_process(ir_variable *var)
@@ -542,6 +543,10 @@ public:
          }
          assert(buffer_block_index != -1);
 
+         if (var->is_in_shader_storage_block() &&
+             !var->data.memory_read_only)
+            shader_storage_blocks_write_access |= 1 << buffer_block_index;
+
          /* Uniform blocks that were specified with an instance name must be
           * handled a little bit differently.  The name of the variable is the
           * name used to reference the uniform block instead of being the name
@@ -1021,6 +1026,10 @@ public:
     */
    GLenum *bindless_access;
 
+   /**
+    * Bitmask of shader storage blocks not declared as read-only.
+    */
+   unsigned shader_storage_blocks_write_access;
 };
 
 static bool
@@ -1382,6 +1391,8 @@ link_assign_uniform_storage(struct gl_context *ctx,
 
       shader->Program->SamplersUsed = parcel.shader_samplers_used;
       shader->shadow_samplers = parcel.shader_shadow_samplers;
+      shader->Program->sh.ShaderStorageBlocksWriteAccess =
+         parcel.shader_storage_blocks_write_access;
 
       if (parcel.num_bindless_samplers > 0) {
          shader->Program->sh.NumBindlessSamplers = parcel.num_bindless_samplers;
index ad258f8bcb1b307faf17aa4bcef0eedf7bb410c6..47e535842fab7c65fffe9e3487a7a80fafb081af 100644 (file)
@@ -1065,6 +1065,7 @@ write_shader_metadata(struct blob *metadata, gl_linked_shader *shader)
                     sizeof(glprog->sh.SamplerTargets));
    blob_write_uint32(metadata, glprog->ShadowSamplers);
    blob_write_uint32(metadata, glprog->ExternalSamplersUsed);
+   blob_write_uint32(metadata, glprog->sh.ShaderStorageBlocksWriteAccess);
 
    blob_write_bytes(metadata, glprog->sh.ImageAccess,
                     sizeof(glprog->sh.ImageAccess));
@@ -1119,6 +1120,7 @@ read_shader_metadata(struct blob_reader *metadata,
                    sizeof(glprog->sh.SamplerTargets));
    glprog->ShadowSamplers = blob_read_uint32(metadata);
    glprog->ExternalSamplersUsed = blob_read_uint32(metadata);
+   glprog->sh.ShaderStorageBlocksWriteAccess = blob_read_uint32(metadata);
 
    blob_copy_bytes(metadata, (uint8_t *) glprog->sh.ImageAccess,
                    sizeof(glprog->sh.ImageAccess));
index c1dc52b2ec46a98235f6563bd8f54aae61332cd2..1f70f048bd3a19f9b0b254d98353b7fb65931db6 100644 (file)
@@ -2169,6 +2169,11 @@ struct gl_program
          struct gl_uniform_block **UniformBlocks;
          struct gl_uniform_block **ShaderStorageBlocks;
 
+         /**
+          * Bitmask of shader storage blocks not declared as read-only.
+          */
+         unsigned ShaderStorageBlocksWriteAccess;
+
          /** Which texture target is being sampled
           * (TEXTURE_1D/2D/3D/etc_INDEX)
           */
index a7f3856d29804b49df96e317e5d02c0e472d0807..5ec3175f2c91fe5af891292550c534f8080e7063 100644 (file)
@@ -82,7 +82,8 @@ st_bind_ssbos(struct st_context *st, struct gl_program *prog,
       }
    }
    st->pipe->set_shader_buffers(st->pipe, shader_type, buffer_base,
-                                prog->info.num_ssbos, buffers, ~0);
+                                prog->info.num_ssbos, buffers,
+                                prog->sh.ShaderStorageBlocksWriteAccess);
    /* clear out any stale shader buffers */
    if (prog->info.num_ssbos < c->MaxShaderStorageBlocks)
       st->pipe->set_shader_buffers(