Mesa (main): glsl/linker: get rid of gl_context from atomic counters paths
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Jan 7 06:54:16 UTC 2022
Module: Mesa
Branch: main
Commit: 4d6e866b7b685ef6c37ba9bc2789ecadc5d6c2f7
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4d6e866b7b685ef6c37ba9bc2789ecadc5d6c2f7
Author: Dave Airlie <airlied at redhat.com>
Date: Fri Jan 7 11:08:33 2022 +1000
glsl/linker: get rid of gl_context from atomic counters paths
Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14433>
---
src/compiler/glsl/gl_nir_link_atomics.c | 24 ++++++++++++------------
src/compiler/glsl/gl_nir_linker.c | 6 +++---
src/compiler/glsl/gl_nir_linker.h | 5 +++--
src/compiler/glsl/link_atomics.cpp | 26 +++++++++++++-------------
src/compiler/glsl/linker.cpp | 4 ++--
src/compiler/glsl/linker.h | 4 ++--
6 files changed, 35 insertions(+), 34 deletions(-)
diff --git a/src/compiler/glsl/gl_nir_link_atomics.c b/src/compiler/glsl/gl_nir_link_atomics.c
index 5a1a7899cc9..38846c7f4d7 100644
--- a/src/compiler/glsl/gl_nir_link_atomics.c
+++ b/src/compiler/glsl/gl_nir_link_atomics.c
@@ -131,14 +131,14 @@ process_atomic_variable(const struct glsl_type *t,
}
static struct active_atomic_buffer *
-find_active_atomic_counters(struct gl_context *ctx,
+find_active_atomic_counters(const struct gl_constants *consts,
struct gl_shader_program *prog,
unsigned *num_buffers)
{
struct active_atomic_buffer *buffers =
rzalloc_array(NULL, /* ctx */
struct active_atomic_buffer,
- ctx->Const.MaxAtomicBufferBindings);
+ consts->MaxAtomicBufferBindings);
*num_buffers = 0;
for (unsigned i = 0; i < MESA_SHADER_STAGES; ++i) {
@@ -190,13 +190,13 @@ cmp_active_counter_offsets(const void *a, const void *b)
}
void
-gl_nir_link_assign_atomic_counter_resources(struct gl_context *ctx,
+gl_nir_link_assign_atomic_counter_resources(const struct gl_constants *consts,
struct gl_shader_program *prog)
{
unsigned num_buffers;
unsigned num_atomic_buffers[MESA_SHADER_STAGES] = {0};
struct active_atomic_buffer *abs =
- find_active_atomic_counters(ctx, prog, &num_buffers);
+ find_active_atomic_counters(consts, prog, &num_buffers);
prog->data->AtomicBuffers =
rzalloc_array(prog->data, struct gl_active_atomic_buffer, num_buffers);
@@ -204,7 +204,7 @@ gl_nir_link_assign_atomic_counter_resources(struct gl_context *ctx,
unsigned buffer_idx = 0;
for (unsigned binding = 0;
- binding < ctx->Const.MaxAtomicBufferBindings;
+ binding < consts->MaxAtomicBufferBindings;
binding++) {
/* If the binding was not used, skip.
@@ -301,12 +301,12 @@ gl_nir_link_assign_atomic_counter_resources(struct gl_context *ctx,
}
void
-gl_nir_link_check_atomic_counter_resources(struct gl_context *ctx,
+gl_nir_link_check_atomic_counter_resources(const struct gl_constants *consts,
struct gl_shader_program *prog)
{
unsigned num_buffers;
struct active_atomic_buffer *abs =
- find_active_atomic_counters(ctx, prog, &num_buffers);
+ find_active_atomic_counters(consts, prog, &num_buffers);
unsigned atomic_counters[MESA_SHADER_STAGES] = {0};
unsigned atomic_buffers[MESA_SHADER_STAGES] = {0};
unsigned total_atomic_counters = 0;
@@ -317,7 +317,7 @@ gl_nir_link_check_atomic_counter_resources(struct gl_context *ctx,
* against the combined limit -- That's the behavior the spec
* requires.
*/
- for (unsigned i = 0; i < ctx->Const.MaxAtomicBufferBindings; i++) {
+ for (unsigned i = 0; i < consts->MaxAtomicBufferBindings; i++) {
if (abs[i].size == 0)
continue;
@@ -354,19 +354,19 @@ gl_nir_link_check_atomic_counter_resources(struct gl_context *ctx,
/* Check that they are within the supported limits. */
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- if (atomic_counters[i] > ctx->Const.Program[i].MaxAtomicCounters)
+ if (atomic_counters[i] > consts->Program[i].MaxAtomicCounters)
linker_error(prog, "Too many %s shader atomic counters",
_mesa_shader_stage_to_string(i));
- if (atomic_buffers[i] > ctx->Const.Program[i].MaxAtomicBuffers)
+ if (atomic_buffers[i] > consts->Program[i].MaxAtomicBuffers)
linker_error(prog, "Too many %s shader atomic counter buffers",
_mesa_shader_stage_to_string(i));
}
- if (total_atomic_counters > ctx->Const.MaxCombinedAtomicCounters)
+ if (total_atomic_counters > consts->MaxCombinedAtomicCounters)
linker_error(prog, "Too many combined atomic counters");
- if (total_atomic_buffers > ctx->Const.MaxCombinedAtomicBuffers)
+ if (total_atomic_buffers > consts->MaxCombinedAtomicBuffers)
linker_error(prog, "Too many combined atomic buffers");
ralloc_free(abs);
diff --git a/src/compiler/glsl/gl_nir_linker.c b/src/compiler/glsl/gl_nir_linker.c
index 78f7007cc23..44273c1ca2f 100644
--- a/src/compiler/glsl/gl_nir_linker.c
+++ b/src/compiler/glsl/gl_nir_linker.c
@@ -621,7 +621,7 @@ gl_nir_link_spirv(struct gl_context *ctx, struct gl_shader_program *prog,
if (!gl_nir_link_uniforms(ctx, prog, options->fill_parameters))
return false;
- gl_nir_link_assign_atomic_counter_resources(ctx, prog);
+ gl_nir_link_assign_atomic_counter_resources(&ctx->Const, prog);
gl_nir_link_assign_xfb_resources(ctx, prog);
return true;
@@ -687,8 +687,8 @@ gl_nir_link_glsl(struct gl_context *ctx, struct gl_shader_program *prog)
link_util_check_uniform_resources(&ctx->Const, prog);
link_util_check_subroutine_resources(prog);
check_image_resources(ctx, prog);
- gl_nir_link_assign_atomic_counter_resources(ctx, prog);
- gl_nir_link_check_atomic_counter_resources(ctx, prog);
+ gl_nir_link_assign_atomic_counter_resources(&ctx->Const, prog);
+ gl_nir_link_check_atomic_counter_resources(&ctx->Const, prog);
if (prog->data->LinkStatus == LINKING_FAILURE)
return false;
diff --git a/src/compiler/glsl/gl_nir_linker.h b/src/compiler/glsl/gl_nir_linker.h
index 5b9e9de2379..b652ebc696b 100644
--- a/src/compiler/glsl/gl_nir_linker.h
+++ b/src/compiler/glsl/gl_nir_linker.h
@@ -29,6 +29,7 @@ extern "C" {
#endif
struct gl_context;
+struct gl_constants;
struct gl_shader_program;
struct gl_nir_linker_options {
@@ -58,10 +59,10 @@ void nir_build_program_resource_list(struct gl_context *ctx,
struct gl_shader_program *prog,
bool rebuild_resourse_list);
-void gl_nir_link_assign_atomic_counter_resources(struct gl_context *ctx,
+void gl_nir_link_assign_atomic_counter_resources(const struct gl_constants *consts,
struct gl_shader_program *prog);
-void gl_nir_link_check_atomic_counter_resources(struct gl_context *ctx,
+void gl_nir_link_check_atomic_counter_resources(const struct gl_constants *consts,
struct gl_shader_program *prog);
void gl_nir_link_assign_xfb_resources(struct gl_context *ctx,
diff --git a/src/compiler/glsl/link_atomics.cpp b/src/compiler/glsl/link_atomics.cpp
index bc03d64633b..d98edcc18e2 100644
--- a/src/compiler/glsl/link_atomics.cpp
+++ b/src/compiler/glsl/link_atomics.cpp
@@ -147,12 +147,12 @@ namespace {
}
active_atomic_buffer *
- find_active_atomic_counters(struct gl_context *ctx,
+ find_active_atomic_counters(const struct gl_constants *consts,
struct gl_shader_program *prog,
unsigned *num_buffers)
{
active_atomic_buffer *const buffers =
- new active_atomic_buffer[ctx->Const.MaxAtomicBufferBindings];
+ new active_atomic_buffer[consts->MaxAtomicBufferBindings];
*num_buffers = 0;
@@ -173,7 +173,7 @@ namespace {
}
}
- for (unsigned i = 0; i < ctx->Const.MaxAtomicBufferBindings; i++) {
+ for (unsigned i = 0; i < consts->MaxAtomicBufferBindings; i++) {
if (buffers[i].size == 0)
continue;
@@ -201,13 +201,13 @@ namespace {
}
void
-link_assign_atomic_counter_resources(struct gl_context *ctx,
+link_assign_atomic_counter_resources(const struct gl_constants *consts,
struct gl_shader_program *prog)
{
unsigned num_buffers;
unsigned num_atomic_buffers[MESA_SHADER_STAGES] = {};
active_atomic_buffer *abs =
- find_active_atomic_counters(ctx, prog, &num_buffers);
+ find_active_atomic_counters(consts, prog, &num_buffers);
prog->data->AtomicBuffers = rzalloc_array(prog->data, gl_active_atomic_buffer,
num_buffers);
@@ -215,7 +215,7 @@ link_assign_atomic_counter_resources(struct gl_context *ctx,
unsigned i = 0;
for (unsigned binding = 0;
- binding < ctx->Const.MaxAtomicBufferBindings;
+ binding < consts->MaxAtomicBufferBindings;
binding++) {
/* If the binding was not used, skip.
@@ -300,12 +300,12 @@ link_assign_atomic_counter_resources(struct gl_context *ctx,
}
void
-link_check_atomic_counter_resources(struct gl_context *ctx,
+link_check_atomic_counter_resources(const struct gl_constants *consts,
struct gl_shader_program *prog)
{
unsigned num_buffers;
active_atomic_buffer *const abs =
- find_active_atomic_counters(ctx, prog, &num_buffers);
+ find_active_atomic_counters(consts, prog, &num_buffers);
unsigned atomic_counters[MESA_SHADER_STAGES] = {};
unsigned atomic_buffers[MESA_SHADER_STAGES] = {};
unsigned total_atomic_counters = 0;
@@ -316,7 +316,7 @@ link_check_atomic_counter_resources(struct gl_context *ctx,
* against the combined limit -- That's the behavior the spec
* requires.
*/
- for (unsigned i = 0; i < ctx->Const.MaxAtomicBufferBindings; i++) {
+ for (unsigned i = 0; i < consts->MaxAtomicBufferBindings; i++) {
if (abs[i].size == 0)
continue;
@@ -334,19 +334,19 @@ link_check_atomic_counter_resources(struct gl_context *ctx,
/* Check that they are within the supported limits. */
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- if (atomic_counters[i] > ctx->Const.Program[i].MaxAtomicCounters)
+ if (atomic_counters[i] > consts->Program[i].MaxAtomicCounters)
linker_error(prog, "Too many %s shader atomic counters",
_mesa_shader_stage_to_string(i));
- if (atomic_buffers[i] > ctx->Const.Program[i].MaxAtomicBuffers)
+ if (atomic_buffers[i] > consts->Program[i].MaxAtomicBuffers)
linker_error(prog, "Too many %s shader atomic counter buffers",
_mesa_shader_stage_to_string(i));
}
- if (total_atomic_counters > ctx->Const.MaxCombinedAtomicCounters)
+ if (total_atomic_counters > consts->MaxCombinedAtomicCounters)
linker_error(prog, "Too many combined atomic counters");
- if (total_atomic_buffers > ctx->Const.MaxCombinedAtomicBuffers)
+ if (total_atomic_buffers > consts->MaxCombinedAtomicBuffers)
linker_error(prog, "Too many combined atomic buffers");
delete [] abs;
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index f2668f5849a..57d63912d35 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4514,8 +4514,8 @@ link_and_validate_uniforms(struct gl_context *ctx,
link_util_check_uniform_resources(&ctx->Const, prog);
link_util_check_subroutine_resources(prog);
check_image_resources(ctx, prog);
- link_assign_atomic_counter_resources(ctx, prog);
- link_check_atomic_counter_resources(ctx, prog);
+ link_assign_atomic_counter_resources(&ctx->Const, prog);
+ link_check_atomic_counter_resources(&ctx->Const, prog);
}
static bool
diff --git a/src/compiler/glsl/linker.h b/src/compiler/glsl/linker.h
index 98c82634db1..fd7fb1b8f4c 100644
--- a/src/compiler/glsl/linker.h
+++ b/src/compiler/glsl/linker.h
@@ -83,11 +83,11 @@ validate_interstage_uniform_blocks(struct gl_shader_program *prog,
gl_linked_shader **stages);
extern void
-link_assign_atomic_counter_resources(struct gl_context *ctx,
+link_assign_atomic_counter_resources(const struct gl_constants *consts,
struct gl_shader_program *prog);
extern void
-link_check_atomic_counter_resources(struct gl_context *ctx,
+link_check_atomic_counter_resources(const struct gl_constants *consts,
struct gl_shader_program *prog);
More information about the mesa-commit
mailing list