static bool
interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog)
{
+ int *InterfaceBlockStageIndex[MESA_SHADER_STAGES];
+
unsigned max_num_uniform_blocks = 0;
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
if (prog->_LinkedShaders[i])
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
struct gl_shader *sh = prog->_LinkedShaders[i];
- prog->InterfaceBlockStageIndex[i] = ralloc_array(prog, int,
- max_num_uniform_blocks);
+ InterfaceBlockStageIndex[i] = new int[max_num_uniform_blocks];
for (unsigned int j = 0; j < max_num_uniform_blocks; j++)
- prog->InterfaceBlockStageIndex[i][j] = -1;
+ InterfaceBlockStageIndex[i][j] = -1;
if (sh == NULL)
continue;
&prog->NumBufferInterfaceBlocks,
sh->BufferInterfaceBlocks[j]);
- if (index == -1) {
- linker_error(prog, "uniform block `%s' has mismatching definitions\n",
- sh->BufferInterfaceBlocks[j]->Name);
- return false;
- }
+ if (index == -1) {
+ linker_error(prog, "uniform block `%s' has mismatching definitions\n",
+ sh->BufferInterfaceBlocks[j]->Name);
+
+ for (unsigned k = 0; k <= i; k++) {
+ delete[] InterfaceBlockStageIndex[k];
+ }
+ return false;
+ }
- prog->InterfaceBlockStageIndex[i][index] = j;
+ InterfaceBlockStageIndex[i][index] = j;
}
}
*/
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
for (unsigned j = 0; j < prog->NumBufferInterfaceBlocks; j++) {
- int stage_index =
- prog->InterfaceBlockStageIndex[i][j];
+ int stage_index = InterfaceBlockStageIndex[i][j];
if (stage_index != -1) {
struct gl_shader *sh = prog->_LinkedShaders[i];
+ prog->BufferInterfaceBlocks[j].stageref |= (1 << i);
+
sh->BufferInterfaceBlocks[stage_index] =
&prog->BufferInterfaceBlocks[j];
}
}
}
+ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+ delete[] InterfaceBlockStageIndex[i];
+ }
+
return true;
}
/* Add stagereferences for uniforms in a uniform block. */
int block_index = shProg->UniformStorage[i].block_index;
if (block_index != -1) {
- for (unsigned j = 0; j < MESA_SHADER_STAGES; j++) {
- if (shProg->InterfaceBlockStageIndex[j][block_index] != -1)
- stageref |= (1 << j);
- }
+ stageref |= shProg->BufferInterfaceBlocks[block_index].stageref;
}
bool is_shader_storage = shProg->UniformStorage[i].is_shader_storage;
void
_mesa_clear_shader_program_data(struct gl_shader_program *shProg)
{
- unsigned i;
-
shProg->NumUniformStorage = 0;
shProg->UniformStorage = NULL;
shProg->NumUniformRemapTable = 0;
shProg->ShaderStorageBlocks = NULL;
shProg->NumShaderStorageBlocks = 0;
- for (i = 0; i < MESA_SHADER_STAGES; i++) {
- ralloc_free(shProg->InterfaceBlockStageIndex[i]);
- shProg->InterfaceBlockStageIndex[i] = NULL;
- }
-
ralloc_free(shProg->AtomicBuffers);
shProg->AtomicBuffers = NULL;
shProg->NumAtomicBuffers = 0;
*/
bool IsShaderStorage;
+ /** Stages that reference this block */
+ uint8_t stageref;
+
/**
* Layout specified in the shader
*
unsigned NumShaderStorageBlocks;
struct gl_uniform_block **ShaderStorageBlocks;
- /**
- * Indices into the BufferInterfaceBlocks[] array for each stage they're
- * used in, or -1.
- *
- * This is used to maintain the Binding values of the stage's
- * BufferInterfaceBlocks[] and to answer the
- * GL_UNIFORM_BLOCK_REFERENCED_BY_*_SHADER queries.
- */
- int *InterfaceBlockStageIndex[MESA_SHADER_STAGES];
-
/**
* Map of active uniform names to locations
*