* with an array of size N, all elements of the array from binding
* through binding + N - 1 must be within this range."
*/
- unsigned limit = 0;
- switch (state->stage) {
- case MESA_SHADER_VERTEX:
- limit = ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits;
- break;
- case MESA_SHADER_GEOMETRY:
- limit = ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits;
- break;
- case MESA_SHADER_FRAGMENT:
- limit = ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits;
- break;
- }
+ unsigned limit = ctx->Const.Program[state->stage].MaxTextureImageUnits;
if (max_index >= limit) {
_mesa_glsl_error(loc, state, "layout(binding = %d) for %d samplers "
link_check_atomic_counter_resources(struct gl_context *ctx,
struct gl_shader_program *prog)
{
- const unsigned max_atomic_counters[] = {
- ctx->Const.Program[MESA_SHADER_VERTEX].MaxAtomicCounters,
- ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxAtomicCounters,
- ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxAtomicCounters
- };
- STATIC_ASSERT(Elements(max_atomic_counters) == MESA_SHADER_STAGES);
- const unsigned max_atomic_buffers[] = {
- ctx->Const.Program[MESA_SHADER_VERTEX].MaxAtomicBuffers,
- ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxAtomicBuffers,
- ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxAtomicBuffers
- };
- STATIC_ASSERT(Elements(max_atomic_buffers) == MESA_SHADER_STAGES);
unsigned num_buffers;
active_atomic_buffer *const abs =
find_active_atomic_counters(ctx, prog, &num_buffers);
/* Check that they are within the supported limits. */
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- if (atomic_counters[i] > max_atomic_counters[i])
+ if (atomic_counters[i] > ctx->Const.Program[i].MaxAtomicCounters)
linker_error(prog, "Too many %s shader atomic counters",
_mesa_shader_stage_to_string(i));
- if (atomic_buffers[i] > max_atomic_buffers[i])
+ if (atomic_buffers[i] > ctx->Const.Program[i].MaxAtomicBuffers)
linker_error(prog, "Too many %s shader atomic counter buffers",
_mesa_shader_stage_to_string(i));
}
}
}
- unsigned max_output_components;
- switch (producer->Stage) {
- case MESA_SHADER_VERTEX:
- max_output_components = ctx->Const.Program[MESA_SHADER_VERTEX].MaxOutputComponents;
- break;
- case MESA_SHADER_GEOMETRY:
- max_output_components = ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxOutputComponents;
- break;
- case MESA_SHADER_FRAGMENT:
- default:
- assert(!"Should not get here.");
- return false;
- }
+ assert(producer->Stage != MESA_SHADER_FRAGMENT);
+ unsigned max_output_components =
+ ctx->Const.Program[producer->Stage].MaxOutputComponents;
const unsigned output_components = output_vectors * 4;
if (output_components > max_output_components) {
}
}
- unsigned max_input_components;
- switch (consumer->Stage) {
- case MESA_SHADER_GEOMETRY:
- max_input_components = ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxInputComponents;
- break;
- case MESA_SHADER_FRAGMENT:
- max_input_components = ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxInputComponents;
- break;
- case MESA_SHADER_VERTEX:
- default:
- assert(!"Should not get here.");
- return false;
- }
+ assert(consumer->Stage != MESA_SHADER_VERTEX);
+ unsigned max_input_components =
+ ctx->Const.Program[consumer->Stage].MaxInputComponents;
const unsigned input_components = input_vectors * 4;
if (input_components > max_input_components) {
static void
check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
{
- const unsigned max_samplers[] = {
- ctx->Const.Program[MESA_SHADER_VERTEX].MaxTextureImageUnits,
- ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxTextureImageUnits,
- ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits
- };
- STATIC_ASSERT(Elements(max_samplers) == MESA_SHADER_STAGES);
-
- const unsigned max_default_uniform_components[] = {
- ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformComponents,
- ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxUniformComponents,
- ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformComponents
- };
- STATIC_ASSERT(Elements(max_default_uniform_components) ==
- MESA_SHADER_STAGES);
-
- const unsigned max_combined_uniform_components[] = {
- ctx->Const.Program[MESA_SHADER_VERTEX].MaxCombinedUniformComponents,
- ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxCombinedUniformComponents,
- ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxCombinedUniformComponents
- };
- STATIC_ASSERT(Elements(max_combined_uniform_components) ==
- MESA_SHADER_STAGES);
-
- const unsigned max_uniform_blocks[] = {
- ctx->Const.Program[MESA_SHADER_VERTEX].MaxUniformBlocks,
- ctx->Const.Program[MESA_SHADER_GEOMETRY].MaxUniformBlocks,
- ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxUniformBlocks
- };
- STATIC_ASSERT(Elements(max_uniform_blocks) == MESA_SHADER_STAGES);
-
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
struct gl_shader *sh = prog->_LinkedShaders[i];
if (sh == NULL)
continue;
- if (sh->num_samplers > max_samplers[i]) {
+ if (sh->num_samplers > ctx->Const.Program[i].MaxTextureImageUnits) {
linker_error(prog, "Too many %s shader texture samplers",
_mesa_shader_stage_to_string(i));
}
- if (sh->num_uniform_components > max_default_uniform_components[i]) {
+ if (sh->num_uniform_components >
+ ctx->Const.Program[i].MaxUniformComponents) {
if (ctx->Const.GLSLSkipStrictMaxUniformLimitCheck) {
linker_warning(prog, "Too many %s shader default uniform block "
"components, but the driver will try to optimize "
}
if (sh->num_combined_uniform_components >
- max_combined_uniform_components[i]) {
+ ctx->Const.Program[i].MaxCombinedUniformComponents) {
if (ctx->Const.GLSLSkipStrictMaxUniformLimitCheck) {
linker_warning(prog, "Too many %s shader uniform components, "
"but the driver will try to optimize them out; "
ctx->Const.MaxCombinedUniformBlocks);
} else {
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- if (blocks[i] > max_uniform_blocks[i]) {
+ const unsigned max_uniform_blocks =
+ ctx->Const.Program[i].MaxUniformBlocks;
+ if (blocks[i] > max_uniform_blocks) {
linker_error(prog, "Too many %s uniform blocks (%d/%d)",
_mesa_shader_stage_to_string(i),
blocks[i],
- max_uniform_blocks[i]);
+ max_uniform_blocks);
break;
}
}