static void
link_setup_uniform_remap_tables(struct gl_context *ctx,
- struct gl_shader_program *prog,
- unsigned num_explicit_uniform_locs)
+ struct gl_shader_program *prog)
{
- unsigned total_entries = num_explicit_uniform_locs;
- unsigned empty_locs =
- prog->NumUniformRemapTable - num_explicit_uniform_locs;
+ unsigned total_entries = prog->NumExplicitUniformLocations;
+ unsigned empty_locs = prog->NumUniformRemapTable - total_entries;
/* Reserve all the explicit locations of the active uniforms. */
for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
static void
link_assign_uniform_storage(struct gl_context *ctx,
struct gl_shader_program *prog,
- const unsigned num_data_slots,
- unsigned num_explicit_uniform_locs)
+ const unsigned num_data_slots)
{
/* On the outside chance that there were no uniforms, bail out.
*/
assert(parcel.values == data_end);
#endif
- link_setup_uniform_remap_tables(ctx, prog, num_explicit_uniform_locs);
+ link_setup_uniform_remap_tables(ctx, prog);
link_set_uniform_initializers(prog, boolean_true);
}
void
link_assign_uniform_locations(struct gl_shader_program *prog,
- struct gl_context *ctx,
- unsigned int num_explicit_uniform_locs)
+ struct gl_context *ctx)
{
ralloc_free(prog->data->UniformStorage);
prog->data->UniformStorage = NULL;
hiddenUniforms->iterate(assign_hidden_uniform_slot_id, &uniform_size);
delete hiddenUniforms;
- link_assign_uniform_storage(ctx, prog, uniform_size.num_values,
- num_explicit_uniform_locs);
+ link_assign_uniform_storage(ctx, prog, uniform_size.num_values);
}
* any optimizations happen to handle also inactive uniforms and
* inactive array elements that may get trimmed away.
*/
-static unsigned
+static void
check_explicit_uniform_locations(struct gl_context *ctx,
struct gl_shader_program *prog)
{
+ prog->NumExplicitUniformLocations = 0;
+
if (!ctx->Extensions.ARB_explicit_uniform_location)
- return 0;
+ return;
/* This map is used to detect if overlapping explicit locations
* occur with the same uniform (from different stage) or a different one.
if (!uniform_map) {
linker_error(prog, "Out of memory during linking.\n");
- return 0;
+ return;
}
unsigned entries_total = 0;
}
if (!ret) {
delete uniform_map;
- return 0;
+ return;
}
}
}
}
delete uniform_map;
- return entries_total;
+ prog->NumExplicitUniformLocations = entries_total;
}
static bool
static void
link_and_validate_uniforms(struct gl_context *ctx,
- struct gl_shader_program *prog,
- unsigned num_explicit_uniform_locs)
+ struct gl_shader_program *prog)
{
update_array_sizes(prog);
- link_assign_uniform_locations(prog, ctx, num_explicit_uniform_locs);
+ link_assign_uniform_locations(prog, ctx);
link_assign_atomic_counter_resources(ctx, prog);
link_calculate_subroutine_compat(prog);
static bool
link_varyings_and_uniforms(unsigned first, unsigned last,
- unsigned num_explicit_uniform_locs,
struct gl_context *ctx,
struct gl_shader_program *prog, void *mem_ctx)
{
if (!link_varyings(prog, first, last, ctx, mem_ctx))
return false;
- link_and_validate_uniforms(ctx, prog, num_explicit_uniform_locs);
+ link_and_validate_uniforms(ctx, prog);
if (!prog->data->LinkStatus)
return false;
return;
}
- unsigned int num_explicit_uniform_locs = 0;
-
void *mem_ctx = ralloc_context(NULL); // temporary linker context
prog->ARB_fragment_coord_conventions_enable = false;
last = i;
}
- num_explicit_uniform_locs = check_explicit_uniform_locations(ctx, prog);
+ check_explicit_uniform_locations(ctx, prog);
link_assign_subroutine_types(prog);
if (!prog->data->LinkStatus)
store_fragdepth_layout(prog);
- if(!link_varyings_and_uniforms(first, last, num_explicit_uniform_locs, ctx,
- prog, mem_ctx))
+ if(!link_varyings_and_uniforms(first, last, ctx, prog, mem_ctx))
goto done;
/* OpenGL ES < 3.1 requires that a vertex shader and a fragment shader both