From: Dave Airlie <airl...@redhat.com> If we have hardware like evergreen with limited hw counters, we need to assign each used counter in a series of linked shaders a unique index so the driver can assign them to the hw counters uniquely.
Since I need to know this information at compile time, I would have to introduce shader variants in the backend for it if I can't get it provided from the frontend, so this adds it to the front end to avoid that. Signed-off-by: Dave Airlie <airl...@redhat.com> --- src/compiler/glsl/ir_uniform.h | 6 ++++++ src/compiler/glsl/link_atomics.cpp | 5 +++++ src/compiler/glsl/link_uniforms.cpp | 1 + 3 files changed, 12 insertions(+) diff --git a/src/compiler/glsl/ir_uniform.h b/src/compiler/glsl/ir_uniform.h index 9545c49..bfb7f33 100644 --- a/src/compiler/glsl/ir_uniform.h +++ b/src/compiler/glsl/ir_uniform.h @@ -184,6 +184,12 @@ struct gl_uniform_storage { int atomic_buffer_index; /** + * For drivers with limited shared hw atomic counters, this is the + * the index into the hw counters within all linked shaders. + */ + int atomic_hw_counter_index; + + /** * The 'base location' for this uniform in the uniform remap table. For * arrays this is the first element in the array. * for subroutines this is in shader subroutine uniform remap table. diff --git a/src/compiler/glsl/link_atomics.cpp b/src/compiler/glsl/link_atomics.cpp index d26e62a..dbf7942 100644 --- a/src/compiler/glsl/link_atomics.cpp +++ b/src/compiler/glsl/link_atomics.cpp @@ -212,6 +212,8 @@ link_assign_atomic_counter_resources(struct gl_context *ctx, prog->data->NumAtomicBuffers = num_buffers; unsigned i = 0; + unsigned hw_counter_index = 0; + for (unsigned binding = 0; binding < ctx->Const.MaxAtomicBufferBindings; binding++) { @@ -245,6 +247,9 @@ link_assign_atomic_counter_resources(struct gl_context *ctx, storage->offset = var->data.offset; storage->array_stride = (var->type->is_array() ? var->type->without_array()->atomic_size() : 0); + storage->atomic_hw_counter_index = hw_counter_index; + hw_counter_index += storage->array_elements ? storage->array_elements : 1; + if (!var->type->is_matrix()) storage->matrix_stride = 0; } diff --git a/src/compiler/glsl/link_uniforms.cpp b/src/compiler/glsl/link_uniforms.cpp index 7d14154..6bf7e01 100644 --- a/src/compiler/glsl/link_uniforms.cpp +++ b/src/compiler/glsl/link_uniforms.cpp @@ -824,6 +824,7 @@ private: this->uniforms[id].num_driver_storage = 0; this->uniforms[id].driver_storage = NULL; this->uniforms[id].atomic_buffer_index = -1; + this->uniforms[id].atomic_hw_counter_index = -1; this->uniforms[id].hidden = current_var->data.how_declared == ir_var_hidden; this->uniforms[id].builtin = is_gl_identifier(name); -- 2.9.5 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev