glsl/linker: get rid of gl_context from uniform assign paths

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14433>
This commit is contained in:
Dave Airlie
2022-01-07 11:00:21 +10:00
committed by Marge Bot
parent adbbee980d
commit e9ec1429ba
6 changed files with 32 additions and 32 deletions

View File

@@ -684,7 +684,7 @@ gl_nir_link_glsl(struct gl_context *ctx, struct gl_shader_program *prog)
return false;
link_util_calculate_subroutine_compat(prog);
link_util_check_uniform_resources(ctx, 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);

View File

@@ -1423,7 +1423,7 @@ assign_hidden_uniform_slot_id(const char *name, unsigned hidden_id,
}
static void
link_setup_uniform_remap_tables(struct gl_context *ctx,
link_setup_uniform_remap_tables(const struct gl_constants *consts,
struct gl_shader_program *prog)
{
unsigned total_entries = prog->NumExplicitUniformLocations;
@@ -1512,10 +1512,10 @@ link_setup_uniform_remap_tables(struct gl_context *ctx,
* is less than MAX_UNIFORM_LOCATIONS.
*/
if (total_entries > ctx->Const.MaxUserAssignableUniformLocations) {
if (total_entries > consts->MaxUserAssignableUniformLocations) {
linker_error(prog, "count of uniform locations > MAX_UNIFORM_LOCATIONS"
"(%u > %u)", total_entries,
ctx->Const.MaxUserAssignableUniformLocations);
consts->MaxUserAssignableUniformLocations);
}
/* Reserve all the explicit locations of the active subroutine uniforms. */
@@ -1588,7 +1588,7 @@ link_setup_uniform_remap_tables(struct gl_context *ctx,
}
static void
link_assign_uniform_storage(struct gl_context *ctx,
link_assign_uniform_storage(const struct gl_constants *consts,
struct gl_shader_program *prog,
const unsigned num_data_slots)
{
@@ -1597,7 +1597,7 @@ link_assign_uniform_storage(struct gl_context *ctx,
if (prog->data->NumUniformStorage == 0)
return;
unsigned int boolean_true = ctx->Const.UniformBooleanTrue;
unsigned int boolean_true = consts->UniformBooleanTrue;
union gl_constant_value *data;
if (prog->data->UniformStorage == NULL) {
@@ -1619,7 +1619,7 @@ link_assign_uniform_storage(struct gl_context *ctx,
parcel_out_uniform_storage parcel(prog, prog->UniformHash,
prog->data->UniformStorage, data,
ctx->Const.UseSTD430AsDefaultPacking);
consts->UseSTD430AsDefaultPacking);
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
struct gl_linked_shader *shader = prog->_LinkedShaders[i];
@@ -1683,7 +1683,7 @@ link_assign_uniform_storage(struct gl_context *ctx,
assert(parcel.values == data_end);
#endif
link_setup_uniform_remap_tables(ctx, prog);
link_setup_uniform_remap_tables(consts, prog);
/* Set shader cache fields */
prog->data->NumUniformDataSlots = num_data_slots;
@@ -1694,7 +1694,7 @@ link_assign_uniform_storage(struct gl_context *ctx,
void
link_assign_uniform_locations(struct gl_shader_program *prog,
struct gl_context *ctx)
const struct gl_constants *consts)
{
ralloc_free(prog->data->UniformStorage);
prog->data->UniformStorage = NULL;
@@ -1715,7 +1715,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
*/
struct string_to_uint_map *hiddenUniforms = new string_to_uint_map;
count_uniform_size uniform_size(prog->UniformHash, hiddenUniforms,
ctx->Const.UseSTD430AsDefaultPacking);
consts->UseSTD430AsDefaultPacking);
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
struct gl_linked_shader *sh = prog->_LinkedShaders[i];
@@ -1739,18 +1739,18 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
}
if (uniform_size.num_shader_samplers >
ctx->Const.Program[i].MaxTextureImageUnits) {
consts->Program[i].MaxTextureImageUnits) {
linker_error(prog, "Too many %s shader texture samplers\n",
_mesa_shader_stage_to_string(i));
continue;
}
if (uniform_size.num_shader_images >
ctx->Const.Program[i].MaxImageUniforms) {
consts->Program[i].MaxImageUniforms) {
linker_error(prog, "Too many %s shader image uniforms (%u > %u)\n",
_mesa_shader_stage_to_string(i),
sh->Program->info.num_images,
ctx->Const.Program[i].MaxImageUniforms);
consts->Program[i].MaxImageUniforms);
continue;
}
@@ -1777,5 +1777,5 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
hiddenUniforms->iterate(assign_hidden_uniform_slot_id, &uniform_size);
delete hiddenUniforms;
link_assign_uniform_storage(ctx, prog, uniform_size.num_values);
link_assign_uniform_storage(consts, prog, uniform_size.num_values);
}

View File

@@ -4505,13 +4505,13 @@ link_and_validate_uniforms(struct gl_context *ctx,
assert(!ctx->Const.UseNIRGLSLLinker);
update_array_sizes(prog);
link_assign_uniform_locations(prog, ctx);
link_assign_uniform_locations(prog, &ctx->Const);
if (prog->data->LinkStatus == LINKING_FAILURE)
return;
link_util_calculate_subroutine_compat(prog);
link_util_check_uniform_resources(ctx, prog);
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);

View File

@@ -40,7 +40,7 @@ link_invalidate_variable_locations(exec_list *ir);
extern void
link_assign_uniform_locations(struct gl_shader_program *prog,
struct gl_context *ctx);
const struct gl_constants *consts);
extern void
link_set_uniform_initializers(struct gl_shader_program *prog,

View File

@@ -176,7 +176,7 @@ link_util_check_subroutine_resources(struct gl_shader_program *prog)
* Validate uniform resources used by a program versus the implementation limits
*/
void
link_util_check_uniform_resources(struct gl_context *ctx,
link_util_check_uniform_resources(const struct gl_constants *consts,
struct gl_shader_program *prog)
{
unsigned total_uniform_blocks = 0;
@@ -189,8 +189,8 @@ link_util_check_uniform_resources(struct gl_context *ctx,
continue;
if (sh->num_uniform_components >
ctx->Const.Program[i].MaxUniformComponents) {
if (ctx->Const.GLSLSkipStrictMaxUniformLimitCheck) {
consts->Program[i].MaxUniformComponents) {
if (consts->GLSLSkipStrictMaxUniformLimitCheck) {
linker_warning(prog, "Too many %s shader default uniform block "
"components, but the driver will try to optimize "
"them out; this is non-portable out-of-spec "
@@ -204,8 +204,8 @@ link_util_check_uniform_resources(struct gl_context *ctx,
}
if (sh->num_combined_uniform_components >
ctx->Const.Program[i].MaxCombinedUniformComponents) {
if (ctx->Const.GLSLSkipStrictMaxUniformLimitCheck) {
consts->Program[i].MaxCombinedUniformComponents) {
if (consts->GLSLSkipStrictMaxUniformLimitCheck) {
linker_warning(prog, "Too many %s shader uniform components, "
"but the driver will try to optimize them out; "
"this is non-portable out-of-spec behavior\n",
@@ -220,34 +220,34 @@ link_util_check_uniform_resources(struct gl_context *ctx,
total_uniform_blocks += sh->Program->info.num_ubos;
}
if (total_uniform_blocks > ctx->Const.MaxCombinedUniformBlocks) {
if (total_uniform_blocks > consts->MaxCombinedUniformBlocks) {
linker_error(prog, "Too many combined uniform blocks (%d/%d)\n",
total_uniform_blocks, ctx->Const.MaxCombinedUniformBlocks);
total_uniform_blocks, consts->MaxCombinedUniformBlocks);
}
if (total_shader_storage_blocks > ctx->Const.MaxCombinedShaderStorageBlocks) {
if (total_shader_storage_blocks > consts->MaxCombinedShaderStorageBlocks) {
linker_error(prog, "Too many combined shader storage blocks (%d/%d)\n",
total_shader_storage_blocks,
ctx->Const.MaxCombinedShaderStorageBlocks);
consts->MaxCombinedShaderStorageBlocks);
}
for (unsigned i = 0; i < prog->data->NumUniformBlocks; i++) {
if (prog->data->UniformBlocks[i].UniformBufferSize >
ctx->Const.MaxUniformBlockSize) {
consts->MaxUniformBlockSize) {
linker_error(prog, "Uniform block %s too big (%d/%d)\n",
prog->data->UniformBlocks[i].name.string,
prog->data->UniformBlocks[i].UniformBufferSize,
ctx->Const.MaxUniformBlockSize);
consts->MaxUniformBlockSize);
}
}
for (unsigned i = 0; i < prog->data->NumShaderStorageBlocks; i++) {
if (prog->data->ShaderStorageBlocks[i].UniformBufferSize >
ctx->Const.MaxShaderStorageBlockSize) {
consts->MaxShaderStorageBlockSize) {
linker_error(prog, "Shader storage block %s too big (%d/%d)\n",
prog->data->ShaderStorageBlocks[i].name.string,
prog->data->ShaderStorageBlocks[i].UniformBufferSize,
ctx->Const.MaxShaderStorageBlockSize);
consts->MaxShaderStorageBlockSize);
}
}
}

View File

@@ -26,7 +26,7 @@
#include "util/bitset.h"
struct gl_context;
struct gl_constants;
struct gl_shader_program;
struct gl_uniform_storage;
@@ -94,7 +94,7 @@ void
link_util_check_subroutine_resources(struct gl_shader_program *prog);
void
link_util_check_uniform_resources(struct gl_context *ctx,
link_util_check_uniform_resources(const struct gl_constants *consts,
struct gl_shader_program *prog);
void