glsl: Track whether uniforms are active per stage
authorKenneth Graunke <kenneth@whitecape.org>
Sat, 13 Sep 2014 18:13:26 +0000 (11:13 -0700)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 21 Jun 2017 23:51:02 +0000 (01:51 +0200)
for finer granularity state flagging

v2: Marek - use a bitmask, add shader cache support

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/compiler/glsl/ir_uniform.h
src/compiler/glsl/link_uniforms.cpp
src/compiler/glsl/shader_cache.cpp

index 9841df8cde11e9192daabf3298e99928ba5be231..9545c4930c7fbc637d291eeac4349bea08170bed 100644 (file)
@@ -106,6 +106,11 @@ struct gl_uniform_storage {
 
    struct gl_opaque_uniform_index opaque[MESA_SHADER_STAGES];
 
+   /**
+    * Mask of shader stages (1 << MESA_SHADER_xxx) where this uniform is used.
+    */
+   unsigned active_shader_mask;
+
    /**
     * Storage used by the driver for the uniform
     */
index d2cb22c2066c81b0b4f784f1d709bce1c3848527..1b87c5860b68b0357a62b4a5f978f3ebc95ee8fd 100644 (file)
@@ -766,6 +766,8 @@ private:
       this->uniforms[id].opaque[shader_type].index = ~0;
       this->uniforms[id].opaque[shader_type].active = false;
 
+      this->uniforms[id].active_shader_mask |= 1 << shader_type;
+
       /* This assigns uniform indices to sampler and image uniforms. */
       handle_samplers(base_type, &this->uniforms[id], name);
       handle_images(base_type, &this->uniforms[id], name);
index fdeab8e56c674e62b486a53deb8b4754f8ff1216..cc4d24482d9364dbe9678e5c2702a6fc48425917 100644 (file)
@@ -576,6 +576,7 @@ write_uniforms(struct blob *metadata, struct gl_shader_program *prog)
       blob_write_uint32(metadata, prog->data->UniformStorage[i].array_stride);
       blob_write_uint32(metadata, prog->data->UniformStorage[i].hidden);
       blob_write_uint32(metadata, prog->data->UniformStorage[i].is_shader_storage);
+      blob_write_uint32(metadata, prog->data->UniformStorage[i].active_shader_mask);
       blob_write_uint32(metadata, prog->data->UniformStorage[i].matrix_stride);
       blob_write_uint32(metadata, prog->data->UniformStorage[i].row_major);
       blob_write_uint32(metadata, prog->data->UniformStorage[i].is_bindless);
@@ -641,6 +642,7 @@ read_uniforms(struct blob_reader *metadata, struct gl_shader_program *prog)
       uniforms[i].array_stride = blob_read_uint32(metadata);
       uniforms[i].hidden = blob_read_uint32(metadata);
       uniforms[i].is_shader_storage = blob_read_uint32(metadata);
+      uniforms[i].active_shader_mask = blob_read_uint32(metadata);
       uniforms[i].matrix_stride = blob_read_uint32(metadata);
       uniforms[i].row_major = blob_read_uint32(metadata);
       uniforms[i].is_bindless = blob_read_uint32(metadata);