diff options
author | Timothy Arceri <[email protected]> | 2015-08-30 12:50:34 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2015-09-17 11:28:14 +1000 |
commit | dcd9cd03837545055ce2a315e7e8840cc3254d1a (patch) | |
tree | eb311b2507fe2eb6428586e6701091eb887f0b66 /src/glsl/link_uniforms.cpp | |
parent | 9788700caf61ff8beee5fd836f5efd98a931a976 (diff) |
glsl: store uniform slot id in var location field
This will allow us to access the uniform later on without resorting to
building a name string and looking it up in UniformHash.
V3: remove line wrap change from this patch
V2: store slot number for all non-UBO uniforms to make code more
consitent, renamed explicit_binding to explicit_location and added
comment about what it does. Store the location at every shader stage.
Updated data.location comments in ir/nir.h.
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/glsl/link_uniforms.cpp')
-rw-r--r-- | src/glsl/link_uniforms.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp index 6d277fa43ca..879c4885384 100644 --- a/src/glsl/link_uniforms.cpp +++ b/src/glsl/link_uniforms.cpp @@ -527,7 +527,13 @@ public: var->get_interface_type()->name); else process(var); - } else + } else { + /* Store any explicit location and reset data location so we can + * reuse this variable for storing the uniform slot number. + */ + this->explicit_location = current_var->data.location; + current_var->data.location = -1; + process(var); } delete this->record_next_sampler; @@ -710,6 +716,13 @@ private: handle_images(base_type, &this->uniforms[id]); handle_subroutines(base_type, &this->uniforms[id]); + /* For array of arrays or struct arrays the base location may have + * already been set so dont set it again. + */ + if (ubo_block_index == -1 && current_var->data.location == -1) { + current_var->data.location = id; + } + /* If there is already storage associated with this uniform or if the * uniform is set as builtin, it means that it was set while processing * an earlier shader stage. For example, we may be processing the @@ -726,10 +739,10 @@ private: if (record_type != NULL) { const unsigned entries = MAX2(1, this->uniforms[id].array_elements); this->uniforms[id].remap_location = - current_var->data.location + field_counter; + this->explicit_location + field_counter; field_counter += entries; } else { - this->uniforms[id].remap_location = current_var->data.location; + this->uniforms[id].remap_location = this->explicit_location; } } else { /* Initialize to to indicate that no location is set */ @@ -795,6 +808,11 @@ private: unsigned next_image; unsigned next_subroutine; + /* Used to store the explicit location from current_var so that we can + * reuse the location field for storing the uniform slot id. + */ + int explicit_location; + /* Stores total struct array elements including nested structs */ unsigned record_array_count; |