glsl/linker: get rid of gl_context from atomic counters paths
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14433>
This commit is contained in:
@@ -131,14 +131,14 @@ process_atomic_variable(const struct glsl_type *t,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct active_atomic_buffer *
|
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,
|
struct gl_shader_program *prog,
|
||||||
unsigned *num_buffers)
|
unsigned *num_buffers)
|
||||||
{
|
{
|
||||||
struct active_atomic_buffer *buffers =
|
struct active_atomic_buffer *buffers =
|
||||||
rzalloc_array(NULL, /* ctx */
|
rzalloc_array(NULL, /* ctx */
|
||||||
struct active_atomic_buffer,
|
struct active_atomic_buffer,
|
||||||
ctx->Const.MaxAtomicBufferBindings);
|
consts->MaxAtomicBufferBindings);
|
||||||
*num_buffers = 0;
|
*num_buffers = 0;
|
||||||
|
|
||||||
for (unsigned i = 0; i < MESA_SHADER_STAGES; ++i) {
|
for (unsigned i = 0; i < MESA_SHADER_STAGES; ++i) {
|
||||||
@@ -190,13 +190,13 @@ cmp_active_counter_offsets(const void *a, const void *b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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)
|
struct gl_shader_program *prog)
|
||||||
{
|
{
|
||||||
unsigned num_buffers;
|
unsigned num_buffers;
|
||||||
unsigned num_atomic_buffers[MESA_SHADER_STAGES] = {0};
|
unsigned num_atomic_buffers[MESA_SHADER_STAGES] = {0};
|
||||||
struct active_atomic_buffer *abs =
|
struct active_atomic_buffer *abs =
|
||||||
find_active_atomic_counters(ctx, prog, &num_buffers);
|
find_active_atomic_counters(consts, prog, &num_buffers);
|
||||||
|
|
||||||
prog->data->AtomicBuffers =
|
prog->data->AtomicBuffers =
|
||||||
rzalloc_array(prog->data, struct gl_active_atomic_buffer, num_buffers);
|
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;
|
unsigned buffer_idx = 0;
|
||||||
for (unsigned binding = 0;
|
for (unsigned binding = 0;
|
||||||
binding < ctx->Const.MaxAtomicBufferBindings;
|
binding < consts->MaxAtomicBufferBindings;
|
||||||
binding++) {
|
binding++) {
|
||||||
|
|
||||||
/* If the binding was not used, skip.
|
/* If the binding was not used, skip.
|
||||||
@@ -301,12 +301,12 @@ gl_nir_link_assign_atomic_counter_resources(struct gl_context *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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)
|
struct gl_shader_program *prog)
|
||||||
{
|
{
|
||||||
unsigned num_buffers;
|
unsigned num_buffers;
|
||||||
struct active_atomic_buffer *abs =
|
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_counters[MESA_SHADER_STAGES] = {0};
|
||||||
unsigned atomic_buffers[MESA_SHADER_STAGES] = {0};
|
unsigned atomic_buffers[MESA_SHADER_STAGES] = {0};
|
||||||
unsigned total_atomic_counters = 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
|
* against the combined limit -- That's the behavior the spec
|
||||||
* requires.
|
* requires.
|
||||||
*/
|
*/
|
||||||
for (unsigned i = 0; i < ctx->Const.MaxAtomicBufferBindings; i++) {
|
for (unsigned i = 0; i < consts->MaxAtomicBufferBindings; i++) {
|
||||||
if (abs[i].size == 0)
|
if (abs[i].size == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -354,19 +354,19 @@ gl_nir_link_check_atomic_counter_resources(struct gl_context *ctx,
|
|||||||
|
|
||||||
/* Check that they are within the supported limits. */
|
/* Check that they are within the supported limits. */
|
||||||
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
|
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",
|
linker_error(prog, "Too many %s shader atomic counters",
|
||||||
_mesa_shader_stage_to_string(i));
|
_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",
|
linker_error(prog, "Too many %s shader atomic counter buffers",
|
||||||
_mesa_shader_stage_to_string(i));
|
_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");
|
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");
|
linker_error(prog, "Too many combined atomic buffers");
|
||||||
|
|
||||||
ralloc_free(abs);
|
ralloc_free(abs);
|
||||||
|
@@ -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))
|
if (!gl_nir_link_uniforms(ctx, prog, options->fill_parameters))
|
||||||
return false;
|
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);
|
gl_nir_link_assign_xfb_resources(ctx, prog);
|
||||||
|
|
||||||
return true;
|
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_uniform_resources(&ctx->Const, prog);
|
||||||
link_util_check_subroutine_resources(prog);
|
link_util_check_subroutine_resources(prog);
|
||||||
check_image_resources(ctx, prog);
|
check_image_resources(ctx, prog);
|
||||||
gl_nir_link_assign_atomic_counter_resources(ctx, prog);
|
gl_nir_link_assign_atomic_counter_resources(&ctx->Const, prog);
|
||||||
gl_nir_link_check_atomic_counter_resources(ctx, prog);
|
gl_nir_link_check_atomic_counter_resources(&ctx->Const, prog);
|
||||||
|
|
||||||
if (prog->data->LinkStatus == LINKING_FAILURE)
|
if (prog->data->LinkStatus == LINKING_FAILURE)
|
||||||
return false;
|
return false;
|
||||||
|
@@ -29,6 +29,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct gl_context;
|
struct gl_context;
|
||||||
|
struct gl_constants;
|
||||||
struct gl_shader_program;
|
struct gl_shader_program;
|
||||||
|
|
||||||
struct gl_nir_linker_options {
|
struct gl_nir_linker_options {
|
||||||
@@ -58,10 +59,10 @@ void nir_build_program_resource_list(struct gl_context *ctx,
|
|||||||
struct gl_shader_program *prog,
|
struct gl_shader_program *prog,
|
||||||
bool rebuild_resourse_list);
|
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);
|
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);
|
struct gl_shader_program *prog);
|
||||||
|
|
||||||
void gl_nir_link_assign_xfb_resources(struct gl_context *ctx,
|
void gl_nir_link_assign_xfb_resources(struct gl_context *ctx,
|
||||||
|
@@ -147,12 +147,12 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
active_atomic_buffer *
|
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,
|
struct gl_shader_program *prog,
|
||||||
unsigned *num_buffers)
|
unsigned *num_buffers)
|
||||||
{
|
{
|
||||||
active_atomic_buffer *const buffers =
|
active_atomic_buffer *const buffers =
|
||||||
new active_atomic_buffer[ctx->Const.MaxAtomicBufferBindings];
|
new active_atomic_buffer[consts->MaxAtomicBufferBindings];
|
||||||
|
|
||||||
*num_buffers = 0;
|
*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)
|
if (buffers[i].size == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -201,13 +201,13 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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)
|
struct gl_shader_program *prog)
|
||||||
{
|
{
|
||||||
unsigned num_buffers;
|
unsigned num_buffers;
|
||||||
unsigned num_atomic_buffers[MESA_SHADER_STAGES] = {};
|
unsigned num_atomic_buffers[MESA_SHADER_STAGES] = {};
|
||||||
active_atomic_buffer *abs =
|
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,
|
prog->data->AtomicBuffers = rzalloc_array(prog->data, gl_active_atomic_buffer,
|
||||||
num_buffers);
|
num_buffers);
|
||||||
@@ -215,7 +215,7 @@ link_assign_atomic_counter_resources(struct gl_context *ctx,
|
|||||||
|
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
for (unsigned binding = 0;
|
for (unsigned binding = 0;
|
||||||
binding < ctx->Const.MaxAtomicBufferBindings;
|
binding < consts->MaxAtomicBufferBindings;
|
||||||
binding++) {
|
binding++) {
|
||||||
|
|
||||||
/* If the binding was not used, skip.
|
/* If the binding was not used, skip.
|
||||||
@@ -300,12 +300,12 @@ link_assign_atomic_counter_resources(struct gl_context *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
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)
|
struct gl_shader_program *prog)
|
||||||
{
|
{
|
||||||
unsigned num_buffers;
|
unsigned num_buffers;
|
||||||
active_atomic_buffer *const abs =
|
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_counters[MESA_SHADER_STAGES] = {};
|
||||||
unsigned atomic_buffers[MESA_SHADER_STAGES] = {};
|
unsigned atomic_buffers[MESA_SHADER_STAGES] = {};
|
||||||
unsigned total_atomic_counters = 0;
|
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
|
* against the combined limit -- That's the behavior the spec
|
||||||
* requires.
|
* requires.
|
||||||
*/
|
*/
|
||||||
for (unsigned i = 0; i < ctx->Const.MaxAtomicBufferBindings; i++) {
|
for (unsigned i = 0; i < consts->MaxAtomicBufferBindings; i++) {
|
||||||
if (abs[i].size == 0)
|
if (abs[i].size == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -334,19 +334,19 @@ link_check_atomic_counter_resources(struct gl_context *ctx,
|
|||||||
|
|
||||||
/* Check that they are within the supported limits. */
|
/* Check that they are within the supported limits. */
|
||||||
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
|
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",
|
linker_error(prog, "Too many %s shader atomic counters",
|
||||||
_mesa_shader_stage_to_string(i));
|
_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",
|
linker_error(prog, "Too many %s shader atomic counter buffers",
|
||||||
_mesa_shader_stage_to_string(i));
|
_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");
|
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");
|
linker_error(prog, "Too many combined atomic buffers");
|
||||||
|
|
||||||
delete [] abs;
|
delete [] abs;
|
||||||
|
@@ -4514,8 +4514,8 @@ link_and_validate_uniforms(struct gl_context *ctx,
|
|||||||
link_util_check_uniform_resources(&ctx->Const, prog);
|
link_util_check_uniform_resources(&ctx->Const, prog);
|
||||||
link_util_check_subroutine_resources(prog);
|
link_util_check_subroutine_resources(prog);
|
||||||
check_image_resources(ctx, prog);
|
check_image_resources(ctx, prog);
|
||||||
link_assign_atomic_counter_resources(ctx, prog);
|
link_assign_atomic_counter_resources(&ctx->Const, prog);
|
||||||
link_check_atomic_counter_resources(ctx, prog);
|
link_check_atomic_counter_resources(&ctx->Const, prog);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@@ -83,11 +83,11 @@ validate_interstage_uniform_blocks(struct gl_shader_program *prog,
|
|||||||
gl_linked_shader **stages);
|
gl_linked_shader **stages);
|
||||||
|
|
||||||
extern void
|
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);
|
struct gl_shader_program *prog);
|
||||||
|
|
||||||
extern void
|
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);
|
struct gl_shader_program *prog);
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user