glsl: use linked_shaders bitmask to iterate stages for subroutine fields
This should be faster than looping over every stage and null checking, but will also make the code a bit cleaner when we switch to getting more fields from gl_program rather than from gl_linked_shader as we can just copy the pointer and not need to worry about null checking then copying. Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
This commit is contained in:
@@ -1140,10 +1140,10 @@ link_setup_uniform_remap_tables(struct gl_context *ctx,
|
|||||||
const unsigned entries =
|
const unsigned entries =
|
||||||
MAX2(1, prog->data->UniformStorage[i].array_elements);
|
MAX2(1, prog->data->UniformStorage[i].array_elements);
|
||||||
|
|
||||||
for (unsigned j = 0; j < MESA_SHADER_STAGES; j++) {
|
unsigned mask = prog->data->linked_stages;
|
||||||
|
while (mask) {
|
||||||
|
const int j = u_bit_scan(&mask);
|
||||||
struct gl_linked_shader *sh = prog->_LinkedShaders[j];
|
struct gl_linked_shader *sh = prog->_LinkedShaders[j];
|
||||||
if (!sh)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!prog->data->UniformStorage[i].opaque[j].active)
|
if (!prog->data->UniformStorage[i].opaque[j].active)
|
||||||
continue;
|
continue;
|
||||||
@@ -1172,10 +1172,10 @@ link_setup_uniform_remap_tables(struct gl_context *ctx,
|
|||||||
const unsigned entries =
|
const unsigned entries =
|
||||||
MAX2(1, prog->data->UniformStorage[i].array_elements);
|
MAX2(1, prog->data->UniformStorage[i].array_elements);
|
||||||
|
|
||||||
for (unsigned j = 0; j < MESA_SHADER_STAGES; j++) {
|
unsigned mask = prog->data->linked_stages;
|
||||||
|
while (mask) {
|
||||||
|
const int j = u_bit_scan(&mask);
|
||||||
struct gl_linked_shader *sh = prog->_LinkedShaders[j];
|
struct gl_linked_shader *sh = prog->_LinkedShaders[j];
|
||||||
if (!sh)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!prog->data->UniformStorage[i].opaque[j].active)
|
if (!prog->data->UniformStorage[i].opaque[j].active)
|
||||||
continue;
|
continue;
|
||||||
|
@@ -3144,11 +3144,10 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||||||
static void
|
static void
|
||||||
link_calculate_subroutine_compat(struct gl_shader_program *prog)
|
link_calculate_subroutine_compat(struct gl_shader_program *prog)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
|
unsigned mask = prog->data->linked_stages;
|
||||||
|
while (mask) {
|
||||||
|
const int i = u_bit_scan(&mask);
|
||||||
struct gl_linked_shader *sh = prog->_LinkedShaders[i];
|
struct gl_linked_shader *sh = prog->_LinkedShaders[i];
|
||||||
int count;
|
|
||||||
if (!sh)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
for (unsigned j = 0; j < sh->NumSubroutineUniformRemapTable; j++) {
|
for (unsigned j = 0; j < sh->NumSubroutineUniformRemapTable; j++) {
|
||||||
if (sh->SubroutineUniformRemapTable[j] == INACTIVE_UNIFORM_EXPLICIT_LOCATION)
|
if (sh->SubroutineUniformRemapTable[j] == INACTIVE_UNIFORM_EXPLICIT_LOCATION)
|
||||||
@@ -3159,7 +3158,7 @@ link_calculate_subroutine_compat(struct gl_shader_program *prog)
|
|||||||
if (!uni)
|
if (!uni)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
count = 0;
|
int count = 0;
|
||||||
if (sh->NumSubroutineFunctions == 0) {
|
if (sh->NumSubroutineFunctions == 0) {
|
||||||
linker_error(prog, "subroutine uniform %s defined but no valid functions found\n", uni->type->name);
|
linker_error(prog, "subroutine uniform %s defined but no valid functions found\n", uni->type->name);
|
||||||
continue;
|
continue;
|
||||||
@@ -3181,16 +3180,16 @@ link_calculate_subroutine_compat(struct gl_shader_program *prog)
|
|||||||
static void
|
static void
|
||||||
check_subroutine_resources(struct gl_shader_program *prog)
|
check_subroutine_resources(struct gl_shader_program *prog)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
|
unsigned mask = prog->data->linked_stages;
|
||||||
|
while (mask) {
|
||||||
|
const int i = u_bit_scan(&mask);
|
||||||
struct gl_linked_shader *sh = prog->_LinkedShaders[i];
|
struct gl_linked_shader *sh = prog->_LinkedShaders[i];
|
||||||
|
|
||||||
if (sh) {
|
|
||||||
if (sh->NumSubroutineUniformRemapTable > MAX_SUBROUTINE_UNIFORM_LOCATIONS)
|
if (sh->NumSubroutineUniformRemapTable > MAX_SUBROUTINE_UNIFORM_LOCATIONS)
|
||||||
linker_error(prog, "Too many %s shader subroutine uniforms\n",
|
linker_error(prog, "Too many %s shader subroutine uniforms\n",
|
||||||
_mesa_shader_stage_to_string(i));
|
_mesa_shader_stage_to_string(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Validate shader image resources.
|
* Validate shader image resources.
|
||||||
*/
|
*/
|
||||||
@@ -3383,12 +3382,11 @@ check_explicit_uniform_locations(struct gl_context *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned entries_total = 0;
|
unsigned entries_total = 0;
|
||||||
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
|
unsigned mask = prog->data->linked_stages;
|
||||||
|
while (mask) {
|
||||||
|
const int i = u_bit_scan(&mask);
|
||||||
struct gl_linked_shader *sh = prog->_LinkedShaders[i];
|
struct gl_linked_shader *sh = prog->_LinkedShaders[i];
|
||||||
|
|
||||||
if (!sh)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
foreach_in_list(ir_instruction, node, sh->ir) {
|
foreach_in_list(ir_instruction, node, sh->ir) {
|
||||||
ir_variable *var = node->as_variable();
|
ir_variable *var = node->as_variable();
|
||||||
if (!var || var->data.mode != ir_var_uniform)
|
if (!var || var->data.mode != ir_var_uniform)
|
||||||
@@ -4317,14 +4315,12 @@ build_program_resource_list(struct gl_context *ctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
|
unsigned mask = shProg->data->linked_stages;
|
||||||
|
while (mask) {
|
||||||
|
const int i = u_bit_scan(&mask);
|
||||||
struct gl_linked_shader *sh = shProg->_LinkedShaders[i];
|
struct gl_linked_shader *sh = shProg->_LinkedShaders[i];
|
||||||
GLuint type;
|
|
||||||
|
|
||||||
if (!sh)
|
GLuint type = _mesa_shader_stage_to_subroutine((gl_shader_stage)i);
|
||||||
continue;
|
|
||||||
|
|
||||||
type = _mesa_shader_stage_to_subroutine((gl_shader_stage)i);
|
|
||||||
for (unsigned j = 0; j < sh->NumSubroutineFunctions; j++) {
|
for (unsigned j = 0; j < sh->NumSubroutineFunctions; j++) {
|
||||||
if (!add_program_resource(shProg, resource_set,
|
if (!add_program_resource(shProg, resource_set,
|
||||||
type, &sh->SubroutineFunctions[j], 0))
|
type, &sh->SubroutineFunctions[j], 0))
|
||||||
@@ -4372,12 +4368,11 @@ validate_sampler_array_indexing(struct gl_context *ctx,
|
|||||||
static void
|
static void
|
||||||
link_assign_subroutine_types(struct gl_shader_program *prog)
|
link_assign_subroutine_types(struct gl_shader_program *prog)
|
||||||
{
|
{
|
||||||
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
|
unsigned mask = prog->data->linked_stages;
|
||||||
|
while (mask) {
|
||||||
|
const int i = u_bit_scan(&mask);
|
||||||
gl_linked_shader *sh = prog->_LinkedShaders[i];
|
gl_linked_shader *sh = prog->_LinkedShaders[i];
|
||||||
|
|
||||||
if (sh == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
sh->MaxSubroutineFunctionIndex = 0;
|
sh->MaxSubroutineFunctionIndex = 0;
|
||||||
foreach_in_list(ir_instruction, node, sh->ir) {
|
foreach_in_list(ir_instruction, node, sh->ir) {
|
||||||
ir_function *fn = node->as_function();
|
ir_function *fn = node->as_function();
|
||||||
|
Reference in New Issue
Block a user