glsl: add gl_resource_name to precompute "name" properties later
This just adds the structure with a name and its update function. strlen and others will be added in the following commits. The idea is to parse and analyze the name in advance to make glGetUniformLocation faster. Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13507>
This commit is contained in:
@@ -134,8 +134,8 @@ link_blocks_are_compatible(const struct gl_uniform_block *a,
|
||||
/* We are explicitly ignoring the names, so it would be good to check that
|
||||
* this is happening.
|
||||
*/
|
||||
assert(a->Name == NULL);
|
||||
assert(b->Name == NULL);
|
||||
assert(a->name.string == NULL);
|
||||
assert(b->name.string == NULL);
|
||||
|
||||
if (a->NumUniforms != b->NumUniforms)
|
||||
return false;
|
||||
@@ -468,7 +468,8 @@ fill_block(struct gl_uniform_block *block,
|
||||
{
|
||||
const struct glsl_type *type = glsl_without_array(var->type);
|
||||
|
||||
block->Name = NULL; /* ARB_gl_spirv: allowed to ignore names */
|
||||
block->name.string = NULL; /* ARB_gl_spirv: allowed to ignore names */
|
||||
resource_name_updated(&block->name);
|
||||
/* From ARB_gl_spirv spec:
|
||||
* "Vulkan uses only one binding point for a resource array,
|
||||
* while OpenGL still uses multiple binding points, so binding
|
||||
|
@@ -677,12 +677,12 @@ add_parameter(struct gl_uniform_storage *uniform,
|
||||
if (glsl_type_is_16bit(glsl_without_array(type)))
|
||||
comps = DIV_ROUND_UP(comps, 2);
|
||||
|
||||
_mesa_add_parameter(params, PROGRAM_UNIFORM, uniform->name, comps,
|
||||
_mesa_add_parameter(params, PROGRAM_UNIFORM, uniform->name.string, comps,
|
||||
glsl_get_gl_type(type), NULL, NULL, false);
|
||||
}
|
||||
} else {
|
||||
for (unsigned i = 0; i < num_params; i++) {
|
||||
_mesa_add_parameter(params, PROGRAM_UNIFORM, uniform->name, 4,
|
||||
_mesa_add_parameter(params, PROGRAM_UNIFORM, uniform->name.string, 4,
|
||||
glsl_get_gl_type(type), NULL, NULL, true);
|
||||
}
|
||||
}
|
||||
@@ -1313,8 +1313,9 @@ nir_link_uniform(struct gl_context *ctx,
|
||||
/* Initialize its members */
|
||||
memset(uniform, 0x00, sizeof(struct gl_uniform_storage));
|
||||
|
||||
uniform->name =
|
||||
uniform->name.string =
|
||||
name ? ralloc_strdup(prog->data->UniformStorage, *name) : NULL;
|
||||
resource_name_updated(&uniform->name);
|
||||
|
||||
const struct glsl_type *type_no_array = glsl_without_array(type);
|
||||
if (glsl_type_is_array(type)) {
|
||||
@@ -1423,15 +1424,15 @@ nir_link_uniform(struct gl_context *ctx,
|
||||
if (is_interface_array) {
|
||||
unsigned l = strlen(ifc_name);
|
||||
for (unsigned i = 0; i < num_blocks; i++) {
|
||||
if (strncmp(ifc_name, blocks[i].Name, l) == 0 &&
|
||||
blocks[i].Name[l] == '[') {
|
||||
if (strncmp(ifc_name, blocks[i].name.string, l) == 0 &&
|
||||
blocks[i].name.string[l] == '[') {
|
||||
buffer_block_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (unsigned i = 0; i < num_blocks; i++) {
|
||||
if (strcmp(ifc_name, blocks[i].Name) == 0) {
|
||||
if (strcmp(ifc_name, blocks[i].name.string) == 0) {
|
||||
buffer_block_index = i;
|
||||
break;
|
||||
}
|
||||
@@ -1462,7 +1463,7 @@ nir_link_uniform(struct gl_context *ctx,
|
||||
}
|
||||
|
||||
uniform->block_index = buffer_block_index;
|
||||
uniform->builtin = is_gl_identifier(uniform->name);
|
||||
uniform->builtin = is_gl_identifier(uniform->name.string);
|
||||
uniform->atomic_buffer_index = -1;
|
||||
|
||||
/* The following are not for features not supported by ARB_gl_spirv */
|
||||
@@ -1486,7 +1487,7 @@ nir_link_uniform(struct gl_context *ctx,
|
||||
(prog->data->NumUniformStorage - 1));
|
||||
}
|
||||
|
||||
if (!is_gl_identifier(uniform->name) && !uniform->is_shader_storage &&
|
||||
if (!is_gl_identifier(uniform->name.string) && !uniform->is_shader_storage &&
|
||||
!state->var_is_in_block)
|
||||
state->num_values += values;
|
||||
|
||||
@@ -1683,8 +1684,8 @@ gl_nir_link_uniforms(struct gl_context *ctx,
|
||||
* marked as referenced.
|
||||
*/
|
||||
for (unsigned i = 0; i < num_blocks; i++) {
|
||||
if (strncmp(ifc_name, blocks[i].Name, l) == 0 &&
|
||||
blocks[i].Name[l] == '[') {
|
||||
if (strncmp(ifc_name, blocks[i].name.string, l) == 0 &&
|
||||
blocks[i].name.string[l] == '[') {
|
||||
if (buffer_block_index == -1)
|
||||
buffer_block_index = i;
|
||||
|
||||
@@ -1701,7 +1702,7 @@ gl_nir_link_uniforms(struct gl_context *ctx,
|
||||
}
|
||||
} else {
|
||||
for (unsigned i = 0; i < num_blocks; i++) {
|
||||
if (strcmp(ifc_name, blocks[i].Name) == 0) {
|
||||
if (strcmp(ifc_name, blocks[i].name.string) == 0) {
|
||||
buffer_block_index = i;
|
||||
|
||||
struct hash_entry *entry =
|
||||
|
@@ -151,7 +151,8 @@ gl_nir_link_assign_xfb_resources(struct gl_context *ctx,
|
||||
linked_xfb->Varyings + i;
|
||||
|
||||
/* ARB_gl_spirv: see above. */
|
||||
varying->Name = NULL;
|
||||
varying->name.string = NULL;
|
||||
resource_name_updated(&varying->name);
|
||||
varying->Type = glsl_get_gl_type(xfb_varying->type);
|
||||
varying->BufferIndex = buffer_index;
|
||||
varying->Size = glsl_type_is_array(xfb_varying->type) ?
|
||||
|
@@ -113,24 +113,26 @@ create_shader_variable(struct gl_shader_program *shProg,
|
||||
*/
|
||||
if (in->data.mode == nir_var_system_value &&
|
||||
in->data.location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) {
|
||||
out->name = ralloc_strdup(shProg, "gl_VertexID");
|
||||
out->name.string = ralloc_strdup(shProg, "gl_VertexID");
|
||||
} else if ((in->data.mode == nir_var_shader_out &&
|
||||
in->data.location == VARYING_SLOT_TESS_LEVEL_OUTER) ||
|
||||
(in->data.mode == nir_var_system_value &&
|
||||
in->data.location == SYSTEM_VALUE_TESS_LEVEL_OUTER)) {
|
||||
out->name = ralloc_strdup(shProg, "gl_TessLevelOuter");
|
||||
out->name.string = ralloc_strdup(shProg, "gl_TessLevelOuter");
|
||||
type = glsl_array_type(glsl_float_type(), 4, 0);
|
||||
} else if ((in->data.mode == nir_var_shader_out &&
|
||||
in->data.location == VARYING_SLOT_TESS_LEVEL_INNER) ||
|
||||
(in->data.mode == nir_var_system_value &&
|
||||
in->data.location == SYSTEM_VALUE_TESS_LEVEL_INNER)) {
|
||||
out->name = ralloc_strdup(shProg, "gl_TessLevelInner");
|
||||
out->name.string = ralloc_strdup(shProg, "gl_TessLevelInner");
|
||||
type = glsl_array_type(glsl_float_type(), 2, 0);
|
||||
} else {
|
||||
out->name = ralloc_strdup(shProg, name);
|
||||
out->name.string = ralloc_strdup(shProg, name);
|
||||
}
|
||||
|
||||
if (!out->name)
|
||||
resource_name_updated(&out->name);
|
||||
|
||||
if (!out->name.string)
|
||||
return NULL;
|
||||
|
||||
/* The ARB_program_interface_query spec says:
|
||||
@@ -350,7 +352,8 @@ add_vars_with_modes(const struct gl_context *ctx,
|
||||
* the linker needs to work without them. Returning them is optional.
|
||||
* For simplicity, we ignore names.
|
||||
*/
|
||||
sh_var->name = NULL;
|
||||
sh_var->name.string = NULL;
|
||||
resource_name_updated(&sh_var->name);
|
||||
sh_var->type = var->type;
|
||||
sh_var->location = var->data.location - loc_bias;
|
||||
sh_var->index = var->data.index;
|
||||
|
@@ -97,7 +97,7 @@ get_block_array_index(nir_builder *b, nir_deref_instr *deref,
|
||||
|
||||
for (unsigned i = 0; i < num_blocks; i++) {
|
||||
if (( use_bindings && binding == blocks[i]->Binding) ||
|
||||
(!use_bindings && strcmp(block_name, blocks[i]->Name) == 0)) {
|
||||
(!use_bindings && strcmp(block_name, blocks[i]->name.string) == 0)) {
|
||||
deref->var->data.driver_location = i - const_array_offset;
|
||||
if (nonconst_index)
|
||||
return nir_iadd_imm(b, nonconst_index, i);
|
||||
@@ -144,7 +144,7 @@ get_block_index_offset(nir_variable *var,
|
||||
for (unsigned i = 0; i < num_blocks; i++) {
|
||||
const char *block_name = glsl_get_type_name(var->interface_type);
|
||||
if (( use_bindings && blocks[i]->Binding == var->data.binding) ||
|
||||
(!use_bindings && strcmp(block_name, blocks[i]->Name) == 0)) {
|
||||
(!use_bindings && strcmp(block_name, blocks[i]->name.string) == 0)) {
|
||||
var->data.driver_location = i;
|
||||
*index = i;
|
||||
*offset = blocks[i]->Uniforms[var->data.location].Offset;
|
||||
|
@@ -88,8 +88,14 @@ struct gl_opaque_uniform_index {
|
||||
bool active;
|
||||
};
|
||||
|
||||
struct gl_resource_name
|
||||
{
|
||||
char *string;
|
||||
};
|
||||
|
||||
struct gl_uniform_storage {
|
||||
char *name;
|
||||
struct gl_resource_name name;
|
||||
|
||||
/** Type of this uniform data stored.
|
||||
*
|
||||
* In the case of an array, it's the type of a single array element.
|
||||
@@ -214,6 +220,9 @@ struct gl_uniform_storage {
|
||||
bool is_bindless;
|
||||
};
|
||||
|
||||
void
|
||||
resource_name_updated(struct gl_resource_name *name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -275,7 +275,8 @@ process_block_array_leaf(const char *name,
|
||||
unsigned i = *block_index;
|
||||
const glsl_type *type = b->type->without_array();
|
||||
|
||||
blocks[i].Name = ralloc_strdup(blocks, name);
|
||||
blocks[i].name.string = ralloc_strdup(blocks, name);
|
||||
resource_name_updated(&blocks[i].name);
|
||||
blocks[i].Uniforms = &variables[(*parcel).index];
|
||||
|
||||
/* The ARB_shading_language_420pack spec says:
|
||||
@@ -292,7 +293,7 @@ process_block_array_leaf(const char *name,
|
||||
blocks[i]._RowMajor = type->get_interface_row_major();
|
||||
blocks[i].linearized_array_index = linearized_index;
|
||||
|
||||
parcel->process(type, b->has_instance_name ? blocks[i].Name : "");
|
||||
parcel->process(type, b->has_instance_name ? blocks[i].name.string : "");
|
||||
|
||||
blocks[i].UniformBufferSize = parcel->buffer_size;
|
||||
|
||||
@@ -480,7 +481,7 @@ static bool
|
||||
link_uniform_blocks_are_compatible(const gl_uniform_block *a,
|
||||
const gl_uniform_block *b)
|
||||
{
|
||||
assert(strcmp(a->Name, b->Name) == 0);
|
||||
assert(strcmp(a->name.string, b->name.string) == 0);
|
||||
|
||||
/* Page 35 (page 42 of the PDF) in section 4.3.7 of the GLSL 1.50 spec says:
|
||||
*
|
||||
@@ -534,7 +535,7 @@ link_cross_validate_uniform_block(void *mem_ctx,
|
||||
for (unsigned int i = 0; i < *num_linked_blocks; i++) {
|
||||
struct gl_uniform_block *old_block = &(*linked_blocks)[i];
|
||||
|
||||
if (strcmp(old_block->Name, new_block->Name) == 0)
|
||||
if (strcmp(old_block->name.string, new_block->name.string) == 0)
|
||||
return link_uniform_blocks_are_compatible(old_block, new_block)
|
||||
? i : -1;
|
||||
}
|
||||
@@ -554,7 +555,8 @@ link_cross_validate_uniform_block(void *mem_ctx,
|
||||
new_block->Uniforms,
|
||||
sizeof(*linked_block->Uniforms) * linked_block->NumUniforms);
|
||||
|
||||
linked_block->Name = ralloc_strdup(*linked_blocks, linked_block->Name);
|
||||
linked_block->name.string = ralloc_strdup(*linked_blocks, linked_block->name.string);
|
||||
resource_name_updated(&linked_block->name);
|
||||
|
||||
for (unsigned int i = 0; i < linked_block->NumUniforms; i++) {
|
||||
struct gl_uniform_buffer_variable *ubo_var =
|
||||
|
@@ -139,7 +139,7 @@ get_array_size(struct gl_uniform_storage *uni, const glsl_struct_field *field,
|
||||
* member is an array with no declared size, the value zero is written
|
||||
* to <params>."
|
||||
*/
|
||||
if (is_top_level_shader_storage_block_member(uni->name,
|
||||
if (is_top_level_shader_storage_block_member(uni->name.string,
|
||||
interface_name,
|
||||
var_name))
|
||||
return 1;
|
||||
@@ -171,7 +171,7 @@ get_array_stride(struct gl_uniform_storage *uni, const glsl_type *iface,
|
||||
bool row_major = matrix_layout == GLSL_MATRIX_LAYOUT_ROW_MAJOR;
|
||||
const glsl_type *array_type = field->type->fields.array;
|
||||
|
||||
if (is_top_level_shader_storage_block_member(uni->name,
|
||||
if (is_top_level_shader_storage_block_member(uni->name.string,
|
||||
interface_name,
|
||||
var_name))
|
||||
return 0;
|
||||
@@ -200,15 +200,15 @@ calculate_array_size_and_stride(struct gl_shader_program *shProg,
|
||||
int block_index = uni->block_index;
|
||||
int array_size = -1;
|
||||
int array_stride = -1;
|
||||
char *var_name = get_top_level_name(uni->name);
|
||||
char *var_name = get_top_level_name(uni->name.string);
|
||||
char *interface_name =
|
||||
get_top_level_name(uni->is_shader_storage ?
|
||||
shProg->data->ShaderStorageBlocks[block_index].Name :
|
||||
shProg->data->UniformBlocks[block_index].Name);
|
||||
shProg->data->ShaderStorageBlocks[block_index].name.string :
|
||||
shProg->data->UniformBlocks[block_index].name.string);
|
||||
|
||||
if (strcmp(var_name, interface_name) == 0) {
|
||||
/* Deal with instanced array of SSBOs */
|
||||
char *temp_name = get_var_name(uni->name);
|
||||
char *temp_name = get_var_name(uni->name.string);
|
||||
if (!temp_name) {
|
||||
linker_error(shProg, "Out of memory during linking.\n");
|
||||
goto write_top_level_array_size_and_stride;
|
||||
@@ -758,15 +758,15 @@ public:
|
||||
unsigned l = strlen(var->get_interface_type()->name);
|
||||
|
||||
for (unsigned i = 0; i < num_blks; i++) {
|
||||
if (strncmp(var->get_interface_type()->name, blks[i].Name, l)
|
||||
== 0 && blks[i].Name[l] == '[') {
|
||||
if (strncmp(var->get_interface_type()->name, blks[i].name.string, l)
|
||||
== 0 && blks[i].name.string[l] == '[') {
|
||||
buffer_block_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (unsigned i = 0; i < num_blks; i++) {
|
||||
if (strcmp(var->get_interface_type()->name, blks[i].Name) == 0) {
|
||||
if (strcmp(var->get_interface_type()->name, blks[i].name.string) == 0) {
|
||||
buffer_block_index = i;
|
||||
break;
|
||||
}
|
||||
@@ -1114,7 +1114,8 @@ private:
|
||||
this->uniforms[id].remap_location = UNMAPPED_UNIFORM_LOC;
|
||||
}
|
||||
|
||||
this->uniforms[id].name = ralloc_strdup(this->uniforms, name);
|
||||
this->uniforms[id].name.string = ralloc_strdup(this->uniforms, name);
|
||||
resource_name_updated(&this->uniforms[id].name);
|
||||
this->uniforms[id].type = base_type;
|
||||
this->uniforms[id].num_driver_storage = 0;
|
||||
this->uniforms[id].driver_storage = NULL;
|
||||
@@ -1335,7 +1336,7 @@ link_update_uniform_buffer_variables(struct gl_linked_shader *shader,
|
||||
|
||||
const ptrdiff_t len = strlen(var->get_interface_type()->name);
|
||||
for (unsigned i = 0; i < num_blocks; i++) {
|
||||
const char *const begin = blks[i]->Name;
|
||||
const char *const begin = blks[i]->name.string;
|
||||
const char *const end = strchr(begin, sentinel);
|
||||
|
||||
if (end == NULL)
|
||||
|
@@ -1424,8 +1424,9 @@ tfeedback_decl::store(struct gl_context *ctx, struct gl_shader_program *prog,
|
||||
}
|
||||
|
||||
store_varying:
|
||||
info->Varyings[info->NumVarying].Name = ralloc_strdup(prog,
|
||||
this->orig_name);
|
||||
info->Varyings[info->NumVarying].name.string = ralloc_strdup(prog,
|
||||
this->orig_name);
|
||||
resource_name_updated(&info->Varyings[info->NumVarying].name);
|
||||
info->Varyings[info->NumVarying].Type = this->type;
|
||||
info->Varyings[info->NumVarying].Size = size;
|
||||
info->Varyings[info->NumVarying].BufferIndex = buffer_index;
|
||||
|
@@ -1287,7 +1287,7 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog,
|
||||
|
||||
if (index == -1) {
|
||||
linker_error(prog, "buffer block `%s' has mismatching "
|
||||
"definitions\n", sh_blks[j]->Name);
|
||||
"definitions\n", sh_blks[j]->name.string);
|
||||
|
||||
for (unsigned k = 0; k <= i; k++) {
|
||||
free(ifc_blk_stage_idx[k]);
|
||||
@@ -3744,24 +3744,26 @@ create_shader_variable(struct gl_shader_program *shProg,
|
||||
*/
|
||||
if (in->data.mode == ir_var_system_value &&
|
||||
in->data.location == SYSTEM_VALUE_VERTEX_ID_ZERO_BASE) {
|
||||
out->name = ralloc_strdup(shProg, "gl_VertexID");
|
||||
out->name.string = ralloc_strdup(shProg, "gl_VertexID");
|
||||
} else if ((in->data.mode == ir_var_shader_out &&
|
||||
in->data.location == VARYING_SLOT_TESS_LEVEL_OUTER) ||
|
||||
(in->data.mode == ir_var_system_value &&
|
||||
in->data.location == SYSTEM_VALUE_TESS_LEVEL_OUTER)) {
|
||||
out->name = ralloc_strdup(shProg, "gl_TessLevelOuter");
|
||||
out->name.string = ralloc_strdup(shProg, "gl_TessLevelOuter");
|
||||
type = glsl_type::get_array_instance(glsl_type::float_type, 4);
|
||||
} else if ((in->data.mode == ir_var_shader_out &&
|
||||
in->data.location == VARYING_SLOT_TESS_LEVEL_INNER) ||
|
||||
(in->data.mode == ir_var_system_value &&
|
||||
in->data.location == SYSTEM_VALUE_TESS_LEVEL_INNER)) {
|
||||
out->name = ralloc_strdup(shProg, "gl_TessLevelInner");
|
||||
out->name.string = ralloc_strdup(shProg, "gl_TessLevelInner");
|
||||
type = glsl_type::get_array_instance(glsl_type::float_type, 2);
|
||||
} else {
|
||||
out->name = ralloc_strdup(shProg, name);
|
||||
out->name.string = ralloc_strdup(shProg, name);
|
||||
}
|
||||
|
||||
if (!out->name)
|
||||
resource_name_updated(&out->name);
|
||||
|
||||
if (!out->name.string)
|
||||
return NULL;
|
||||
|
||||
/* The ARB_program_interface_query spec says:
|
||||
@@ -4351,7 +4353,8 @@ link_assign_subroutine_types(struct gl_shader_program *prog)
|
||||
p->sh.SubroutineFunctions = reralloc(p, p->sh.SubroutineFunctions,
|
||||
struct gl_subroutine_function,
|
||||
p->sh.NumSubroutineFunctions + 1);
|
||||
p->sh.SubroutineFunctions[p->sh.NumSubroutineFunctions].name = ralloc_strdup(p, fn->name);
|
||||
p->sh.SubroutineFunctions[p->sh.NumSubroutineFunctions].name.string = ralloc_strdup(p, fn->name);
|
||||
resource_name_updated(&p->sh.SubroutineFunctions[p->sh.NumSubroutineFunctions].name);
|
||||
p->sh.SubroutineFunctions[p->sh.NumSubroutineFunctions].num_compat_types = fn->num_subroutine_types;
|
||||
p->sh.SubroutineFunctions[p->sh.NumSubroutineFunctions].types =
|
||||
ralloc_array(p, const struct glsl_type *,
|
||||
@@ -4402,7 +4405,7 @@ verify_subroutine_associated_funcs(struct gl_shader_program *prog)
|
||||
*/
|
||||
for (unsigned j = 0; j < p->sh.NumSubroutineFunctions; j++) {
|
||||
unsigned definitions = 0;
|
||||
char *name = p->sh.SubroutineFunctions[j].name;
|
||||
char *name = p->sh.SubroutineFunctions[j].name.string;
|
||||
ir_function *fn = symbols->get_function(name);
|
||||
|
||||
/* Calculate number of function definitions with the same name */
|
||||
@@ -5034,3 +5037,8 @@ done:
|
||||
|
||||
ralloc_free(mem_ctx);
|
||||
}
|
||||
|
||||
void
|
||||
resource_name_updated(struct gl_resource_name *name)
|
||||
{
|
||||
}
|
||||
|
@@ -235,7 +235,7 @@ link_util_check_uniform_resources(struct gl_context *ctx,
|
||||
if (prog->data->UniformBlocks[i].UniformBufferSize >
|
||||
ctx->Const.MaxUniformBlockSize) {
|
||||
linker_error(prog, "Uniform block %s too big (%d/%d)\n",
|
||||
prog->data->UniformBlocks[i].Name,
|
||||
prog->data->UniformBlocks[i].name.string,
|
||||
prog->data->UniformBlocks[i].UniformBufferSize,
|
||||
ctx->Const.MaxUniformBlockSize);
|
||||
}
|
||||
@@ -245,7 +245,7 @@ link_util_check_uniform_resources(struct gl_context *ctx,
|
||||
if (prog->data->ShaderStorageBlocks[i].UniformBufferSize >
|
||||
ctx->Const.MaxShaderStorageBlockSize) {
|
||||
linker_error(prog, "Shader storage block %s too big (%d/%d)\n",
|
||||
prog->data->ShaderStorageBlocks[i].Name,
|
||||
prog->data->ShaderStorageBlocks[i].name.string,
|
||||
prog->data->ShaderStorageBlocks[i].UniformBufferSize,
|
||||
ctx->Const.MaxShaderStorageBlockSize);
|
||||
}
|
||||
|
@@ -303,7 +303,7 @@ lower_ubo_reference_visitor::setup_for_load_or_store(void *mem_ctx,
|
||||
}
|
||||
this->uniform_block = NULL;
|
||||
for (unsigned i = 0; i < num_blocks; i++) {
|
||||
if (strcmp(field_name, blocks[i]->Name) == 0) {
|
||||
if (strcmp(field_name, blocks[i]->name.string) == 0) {
|
||||
|
||||
ir_constant *index = new(mem_ctx) ir_constant(i);
|
||||
|
||||
|
@@ -55,7 +55,7 @@ write_subroutines(struct blob *metadata, struct gl_shader_program *prog)
|
||||
for (unsigned j = 0; j < glprog->sh.NumSubroutineFunctions; j++) {
|
||||
int num_types = glprog->sh.SubroutineFunctions[j].num_compat_types;
|
||||
|
||||
blob_write_string(metadata, glprog->sh.SubroutineFunctions[j].name);
|
||||
blob_write_string(metadata, glprog->sh.SubroutineFunctions[j].name.string);
|
||||
blob_write_uint32(metadata, glprog->sh.SubroutineFunctions[j].index);
|
||||
blob_write_uint32(metadata, num_types);
|
||||
|
||||
@@ -88,7 +88,8 @@ read_subroutines(struct blob_reader *metadata, struct gl_shader_program *prog)
|
||||
glprog->sh.SubroutineFunctions = subs;
|
||||
|
||||
for (unsigned j = 0; j < glprog->sh.NumSubroutineFunctions; j++) {
|
||||
subs[j].name = ralloc_strdup(prog, blob_read_string (metadata));
|
||||
subs[j].name.string = ralloc_strdup(prog, blob_read_string (metadata));
|
||||
resource_name_updated(&subs[j].name);
|
||||
subs[j].index = (int) blob_read_uint32(metadata);
|
||||
subs[j].num_compat_types = (int) blob_read_uint32(metadata);
|
||||
|
||||
@@ -104,7 +105,7 @@ read_subroutines(struct blob_reader *metadata, struct gl_shader_program *prog)
|
||||
static void
|
||||
write_buffer_block(struct blob *metadata, struct gl_uniform_block *b)
|
||||
{
|
||||
blob_write_string(metadata, b->Name);
|
||||
blob_write_string(metadata, b->name.string);
|
||||
blob_write_uint32(metadata, b->NumUniforms);
|
||||
blob_write_uint32(metadata, b->Binding);
|
||||
blob_write_uint32(metadata, b->UniformBufferSize);
|
||||
@@ -160,7 +161,8 @@ static void
|
||||
read_buffer_block(struct blob_reader *metadata, struct gl_uniform_block *b,
|
||||
struct gl_shader_program *prog)
|
||||
{
|
||||
b->Name = ralloc_strdup(prog->data, blob_read_string (metadata));
|
||||
b->name.string = ralloc_strdup(prog->data, blob_read_string (metadata));
|
||||
resource_name_updated(&b->name);
|
||||
b->NumUniforms = blob_read_uint32(metadata);
|
||||
b->Binding = blob_read_uint32(metadata);
|
||||
b->UniformBufferSize = blob_read_uint32(metadata);
|
||||
@@ -340,7 +342,7 @@ write_xfb(struct blob *metadata, struct gl_shader_program *shProg)
|
||||
ltf->NumOutputs);
|
||||
|
||||
for (int i = 0; i < ltf->NumVarying; i++) {
|
||||
blob_write_string(metadata, ltf->Varyings[i].Name);
|
||||
blob_write_string(metadata, ltf->Varyings[i].name.string);
|
||||
blob_write_uint32(metadata, ltf->Varyings[i].Type);
|
||||
blob_write_uint32(metadata, ltf->Varyings[i].BufferIndex);
|
||||
blob_write_uint32(metadata, ltf->Varyings[i].Size);
|
||||
@@ -402,7 +404,8 @@ read_xfb(struct blob_reader *metadata, struct gl_shader_program *shProg)
|
||||
ltf->NumVarying);
|
||||
|
||||
for (int i = 0; i < ltf->NumVarying; i++) {
|
||||
ltf->Varyings[i].Name = ralloc_strdup(prog, blob_read_string(metadata));
|
||||
ltf->Varyings[i].name.string = ralloc_strdup(prog, blob_read_string(metadata));
|
||||
resource_name_updated(<f->Varyings[i].name);
|
||||
ltf->Varyings[i].Type = blob_read_uint32(metadata);
|
||||
ltf->Varyings[i].BufferIndex = blob_read_uint32(metadata);
|
||||
ltf->Varyings[i].Size = blob_read_uint32(metadata);
|
||||
@@ -435,8 +438,8 @@ write_uniforms(struct blob *metadata, struct gl_shader_program *prog)
|
||||
for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
|
||||
encode_type_to_blob(metadata, prog->data->UniformStorage[i].type);
|
||||
blob_write_uint32(metadata, prog->data->UniformStorage[i].array_elements);
|
||||
if (prog->data->UniformStorage[i].name) {
|
||||
blob_write_string(metadata, prog->data->UniformStorage[i].name);
|
||||
if (prog->data->UniformStorage[i].name.string) {
|
||||
blob_write_string(metadata, prog->data->UniformStorage[i].name.string);
|
||||
} else {
|
||||
blob_write_string(metadata, "");
|
||||
}
|
||||
@@ -514,7 +517,8 @@ read_uniforms(struct blob_reader *metadata, struct gl_shader_program *prog)
|
||||
for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
|
||||
uniforms[i].type = decode_type_from_blob(metadata);
|
||||
uniforms[i].array_elements = blob_read_uint32(metadata);
|
||||
uniforms[i].name = ralloc_strdup(prog, blob_read_string (metadata));
|
||||
uniforms[i].name.string = ralloc_strdup(prog, blob_read_string (metadata));
|
||||
resource_name_updated(&uniforms[i].name);
|
||||
uniforms[i].builtin = blob_read_uint32(metadata);
|
||||
uniforms[i].remap_location = blob_read_uint32(metadata);
|
||||
uniforms[i].block_index = blob_read_uint32(metadata);
|
||||
@@ -530,7 +534,7 @@ read_uniforms(struct blob_reader *metadata, struct gl_shader_program *prog)
|
||||
uniforms[i].num_compatible_subroutines = blob_read_uint32(metadata);
|
||||
uniforms[i].top_level_array_size = blob_read_uint32(metadata);
|
||||
uniforms[i].top_level_array_stride = blob_read_uint32(metadata);
|
||||
prog->UniformHash->put(i, uniforms[i].name);
|
||||
prog->UniformHash->put(i, uniforms[i].name.string);
|
||||
|
||||
if (has_uniform_storage(prog, i)) {
|
||||
uniforms[i].storage = data + blob_read_uint32(metadata);
|
||||
@@ -767,8 +771,8 @@ write_shader_subroutine_index(struct blob *metadata,
|
||||
assert(sh);
|
||||
|
||||
for (unsigned j = 0; j < sh->Program->sh.NumSubroutineFunctions; j++) {
|
||||
if (strcmp(((gl_subroutine_function *)res->Data)->name,
|
||||
sh->Program->sh.SubroutineFunctions[j].name) == 0) {
|
||||
if (strcmp(((gl_subroutine_function *)res->Data)->name.string,
|
||||
sh->Program->sh.SubroutineFunctions[j].name.string) == 0) {
|
||||
blob_write_uint32(metadata, j);
|
||||
break;
|
||||
}
|
||||
@@ -809,8 +813,8 @@ write_program_resource_data(struct blob *metadata,
|
||||
encode_type_to_blob(metadata, var->interface_type);
|
||||
encode_type_to_blob(metadata, var->outermost_struct_type);
|
||||
|
||||
if (var->name) {
|
||||
blob_write_string(metadata, var->name);
|
||||
if (var->name.string) {
|
||||
blob_write_string(metadata, var->name.string);
|
||||
} else {
|
||||
blob_write_string(metadata, "");
|
||||
}
|
||||
@@ -825,8 +829,8 @@ write_program_resource_data(struct blob *metadata,
|
||||
}
|
||||
case GL_UNIFORM_BLOCK:
|
||||
for (unsigned i = 0; i < prog->data->NumUniformBlocks; i++) {
|
||||
if (strcmp(((gl_uniform_block *)res->Data)->Name,
|
||||
prog->data->UniformBlocks[i].Name) == 0) {
|
||||
if (strcmp(((gl_uniform_block *)res->Data)->name.string,
|
||||
prog->data->UniformBlocks[i].name.string) == 0) {
|
||||
blob_write_uint32(metadata, i);
|
||||
break;
|
||||
}
|
||||
@@ -834,8 +838,8 @@ write_program_resource_data(struct blob *metadata,
|
||||
break;
|
||||
case GL_SHADER_STORAGE_BLOCK:
|
||||
for (unsigned i = 0; i < prog->data->NumShaderStorageBlocks; i++) {
|
||||
if (strcmp(((gl_uniform_block *)res->Data)->Name,
|
||||
prog->data->ShaderStorageBlocks[i].Name) == 0) {
|
||||
if (strcmp(((gl_uniform_block *)res->Data)->name.string,
|
||||
prog->data->ShaderStorageBlocks[i].name.string) == 0) {
|
||||
blob_write_uint32(metadata, i);
|
||||
break;
|
||||
}
|
||||
@@ -853,8 +857,8 @@ write_program_resource_data(struct blob *metadata,
|
||||
res->Type != GL_UNIFORM) {
|
||||
blob_write_uint32(metadata, uniform_not_remapped);
|
||||
for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
|
||||
if (strcmp(((gl_uniform_storage *)res->Data)->name,
|
||||
prog->data->UniformStorage[i].name) == 0) {
|
||||
if (strcmp(((gl_uniform_storage *)res->Data)->name.string,
|
||||
prog->data->UniformStorage[i].name.string) == 0) {
|
||||
blob_write_uint32(metadata, i);
|
||||
break;
|
||||
}
|
||||
@@ -884,8 +888,8 @@ write_program_resource_data(struct blob *metadata,
|
||||
break;
|
||||
case GL_TRANSFORM_FEEDBACK_VARYING:
|
||||
for (int i = 0; i < prog->last_vert_prog->sh.LinkedTransformFeedback->NumVarying; i++) {
|
||||
if (strcmp(((gl_transform_feedback_varying_info *)res->Data)->Name,
|
||||
prog->last_vert_prog->sh.LinkedTransformFeedback->Varyings[i].Name) == 0) {
|
||||
if (strcmp(((gl_transform_feedback_varying_info *)res->Data)->name.string,
|
||||
prog->last_vert_prog->sh.LinkedTransformFeedback->Varyings[i].name.string) == 0) {
|
||||
blob_write_uint32(metadata, i);
|
||||
break;
|
||||
}
|
||||
@@ -922,7 +926,8 @@ read_program_resource_data(struct blob_reader *metadata,
|
||||
var->interface_type = decode_type_from_blob(metadata);
|
||||
var->outermost_struct_type = decode_type_from_blob(metadata);
|
||||
|
||||
var->name = ralloc_strdup(prog, blob_read_string(metadata));
|
||||
var->name.string = ralloc_strdup(prog, blob_read_string(metadata));
|
||||
resource_name_updated(&var->name);
|
||||
|
||||
size_t s_var_size, s_var_ptrs;
|
||||
get_shader_var_and_pointer_sizes(&s_var_size, &s_var_ptrs, var);
|
||||
|
@@ -122,7 +122,7 @@ establish_uniform_storage(struct gl_shader_program *prog, unsigned num_storage,
|
||||
num_storage);
|
||||
prog->data->NumUniformStorage = num_storage;
|
||||
|
||||
prog->data->UniformStorage[index_to_set].name = (char *) name;
|
||||
prog->data->UniformStorage[index_to_set].name.string = (char *) name;
|
||||
prog->data->UniformStorage[index_to_set].type = type;
|
||||
prog->data->UniformStorage[index_to_set].array_elements = array_size;
|
||||
for (int sh = 0; sh < MESA_SHADER_STAGES; sh++) {
|
||||
@@ -139,13 +139,13 @@ establish_uniform_storage(struct gl_shader_program *prog, unsigned num_storage,
|
||||
red_zone_components);
|
||||
|
||||
prog->UniformHash->put(index_to_set,
|
||||
prog->data->UniformStorage[index_to_set].name);
|
||||
prog->data->UniformStorage[index_to_set].name.string);
|
||||
|
||||
for (unsigned i = 0; i < num_storage; i++) {
|
||||
if (i == index_to_set)
|
||||
continue;
|
||||
|
||||
prog->data->UniformStorage[i].name = (char *) "invalid slot";
|
||||
prog->data->UniformStorage[i].name.string = (char *) "invalid slot";
|
||||
prog->data->UniformStorage[i].type = glsl_type::void_type;
|
||||
prog->data->UniformStorage[i].array_elements = 0;
|
||||
for (int sh = 0; sh < MESA_SHADER_STAGES; sh++) {
|
||||
|
Reference in New Issue
Block a user