summaryrefslogtreecommitdiffstats
path: root/src/compiler
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2016-11-07 14:47:18 +1100
committerTimothy Arceri <[email protected]>2016-11-19 15:45:46 +1100
commit203c8794a1debc0e45019fe945d1cc55459e6c6f (patch)
tree29eafc191c0fb98ebc28673e95d3d1918f883bb0 /src/compiler
parent65cd0a0d7f411eefac81408ebf7b704ccd1c9bf7 (diff)
st/mesa/glsl/nir/i965: make use of new gl_shader_program_data in gl_shader_program
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl/link_atomics.cpp20
-rw-r--r--src/compiler/glsl/link_uniform_initializers.cpp9
-rw-r--r--src/compiler/glsl/link_uniforms.cpp100
-rw-r--r--src/compiler/glsl/linker.cpp116
-rw-r--r--src/compiler/glsl/standalone.cpp14
-rw-r--r--src/compiler/glsl/standalone_scaffolding.cpp26
-rw-r--r--src/compiler/glsl/tests/set_uniform_initializer_tests.cpp47
-rw-r--r--src/compiler/nir/nir_lower_atomics.c2
-rw-r--r--src/compiler/nir/nir_lower_samplers.c6
9 files changed, 176 insertions, 164 deletions
diff --git a/src/compiler/glsl/link_atomics.cpp b/src/compiler/glsl/link_atomics.cpp
index 46a8843d2cb..d26e62a35b3 100644
--- a/src/compiler/glsl/link_atomics.cpp
+++ b/src/compiler/glsl/link_atomics.cpp
@@ -118,7 +118,7 @@ namespace {
} else {
active_atomic_buffer *buf = &buffers[var->data.binding];
gl_uniform_storage *const storage =
- &prog->UniformStorage[*uniform_loc];
+ &prog->data->UniformStorage[*uniform_loc];
/* If this is the first time the buffer is used, increment
* the counter of buffers used.
@@ -207,9 +207,9 @@ link_assign_atomic_counter_resources(struct gl_context *ctx,
active_atomic_buffer *abs =
find_active_atomic_counters(ctx, prog, &num_buffers);
- prog->AtomicBuffers = rzalloc_array(prog, gl_active_atomic_buffer,
- num_buffers);
- prog->NumAtomicBuffers = num_buffers;
+ prog->data->AtomicBuffers = rzalloc_array(prog, gl_active_atomic_buffer,
+ num_buffers);
+ prog->data->NumAtomicBuffers = num_buffers;
unsigned i = 0;
for (unsigned binding = 0;
@@ -222,12 +222,12 @@ link_assign_atomic_counter_resources(struct gl_context *ctx,
continue;
active_atomic_buffer &ab = abs[binding];
- gl_active_atomic_buffer &mab = prog->AtomicBuffers[i];
+ gl_active_atomic_buffer &mab = prog->data->AtomicBuffers[i];
/* Assign buffer-specific fields. */
mab.Binding = binding;
mab.MinimumSize = ab.size;
- mab.Uniforms = rzalloc_array(prog->AtomicBuffers, GLuint,
+ mab.Uniforms = rzalloc_array(prog->data->AtomicBuffers, GLuint,
ab.num_uniforms);
mab.NumUniforms = ab.num_uniforms;
@@ -235,7 +235,7 @@ link_assign_atomic_counter_resources(struct gl_context *ctx,
for (unsigned j = 0; j < ab.num_uniforms; j++) {
ir_variable *const var = ab.uniforms[j].var;
gl_uniform_storage *const storage =
- &prog->UniformStorage[ab.uniforms[j].uniform_loc];
+ &prog->data->UniformStorage[ab.uniforms[j].uniform_loc];
mab.Uniforms[j] = ab.uniforms[j].uniform_loc;
if (!var->data.explicit_binding)
@@ -276,14 +276,14 @@ link_assign_atomic_counter_resources(struct gl_context *ctx,
unsigned intra_stage_idx = 0;
for (unsigned i = 0; i < num_buffers; i++) {
struct gl_active_atomic_buffer *atomic_buffer =
- &prog->AtomicBuffers[i];
+ &prog->data->AtomicBuffers[i];
if (atomic_buffer->StageReferences[j]) {
gl_prog->sh.AtomicBuffers[intra_stage_idx] = atomic_buffer;
for (unsigned u = 0; u < atomic_buffer->NumUniforms; u++) {
- prog->UniformStorage[atomic_buffer->Uniforms[u]].opaque[j].index =
+ prog->data->UniformStorage[atomic_buffer->Uniforms[u]].opaque[j].index =
intra_stage_idx;
- prog->UniformStorage[atomic_buffer->Uniforms[u]].opaque[j].active =
+ prog->data->UniformStorage[atomic_buffer->Uniforms[u]].opaque[j].active =
true;
}
diff --git a/src/compiler/glsl/link_uniform_initializers.cpp b/src/compiler/glsl/link_uniform_initializers.cpp
index 68ba167e478..93340baf61f 100644
--- a/src/compiler/glsl/link_uniform_initializers.cpp
+++ b/src/compiler/glsl/link_uniform_initializers.cpp
@@ -38,7 +38,7 @@ get_storage(struct gl_shader_program *prog, const char *name)
{
unsigned id;
if (prog->UniformHash->get(id, name))
- return &prog->UniformStorage[id];
+ return &prog->data->UniformStorage[id];
assert(!"No uniform storage found!");
return NULL;
@@ -155,10 +155,11 @@ void
set_block_binding(gl_shader_program *prog, const char *block_name,
unsigned mode, int binding)
{
- unsigned num_blocks = mode == ir_var_uniform ? prog->NumUniformBlocks :
- prog->NumShaderStorageBlocks;
+ unsigned num_blocks = mode == ir_var_uniform ?
+ prog->data->NumUniformBlocks :
+ prog->data->NumShaderStorageBlocks;
struct gl_uniform_block *blks = mode == ir_var_uniform ?
- prog->UniformBlocks : prog->ShaderStorageBlocks;
+ prog->data->UniformBlocks : prog->data->ShaderStorageBlocks;
for (unsigned i = 0; i < num_blocks; i++) {
if (!strcmp(blks[i].Name, block_name)) {
diff --git a/src/compiler/glsl/link_uniforms.cpp b/src/compiler/glsl/link_uniforms.cpp
index 8e411f7d58f..f27109398ed 100644
--- a/src/compiler/glsl/link_uniforms.cpp
+++ b/src/compiler/glsl/link_uniforms.cpp
@@ -454,9 +454,9 @@ public:
buffer_block_index = -1;
if (var->is_in_buffer_block()) {
struct gl_uniform_block *blks = var->is_in_shader_storage_block() ?
- prog->ShaderStorageBlocks : prog->UniformBlocks;
+ prog->data->ShaderStorageBlocks : prog->data->UniformBlocks;
unsigned num_blks = var->is_in_shader_storage_block() ?
- prog->NumShaderStorageBlocks : prog->NumUniformBlocks;
+ prog->data->NumShaderStorageBlocks : prog->data->NumUniformBlocks;
if (var->is_interface_instance() && var->type->is_array()) {
unsigned l = strlen(var->get_interface_type()->name);
@@ -1042,49 +1042,53 @@ link_setup_uniform_remap_tables(struct gl_context *ctx,
prog->NumUniformRemapTable - num_explicit_uniform_locs;
/* Reserve all the explicit locations of the active uniforms. */
- for (unsigned i = 0; i < prog->NumUniformStorage; i++) {
- if (prog->UniformStorage[i].type->is_subroutine() ||
- prog->UniformStorage[i].is_shader_storage)
+ for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
+ if (prog->data->UniformStorage[i].type->is_subroutine() ||
+ prog->data->UniformStorage[i].is_shader_storage)
continue;
- if (prog->UniformStorage[i].remap_location != UNMAPPED_UNIFORM_LOC) {
+ if (prog->data->UniformStorage[i].remap_location !=
+ UNMAPPED_UNIFORM_LOC) {
/* How many new entries for this uniform? */
const unsigned entries =
- MAX2(1, prog->UniformStorage[i].array_elements);
+ MAX2(1, prog->data->UniformStorage[i].array_elements);
/* Set remap table entries point to correct gl_uniform_storage. */
for (unsigned j = 0; j < entries; j++) {
- unsigned element_loc = prog->UniformStorage[i].remap_location + j;
+ unsigned element_loc =
+ prog->data->UniformStorage[i].remap_location + j;
assert(prog->UniformRemapTable[element_loc] ==
INACTIVE_UNIFORM_EXPLICIT_LOCATION);
- prog->UniformRemapTable[element_loc] = &prog->UniformStorage[i];
+ prog->UniformRemapTable[element_loc] =
+ &prog->data->UniformStorage[i];
}
}
}
/* Reserve locations for rest of the uniforms. */
- for (unsigned i = 0; i < prog->NumUniformStorage; i++) {
+ for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
- if (prog->UniformStorage[i].type->is_subroutine() ||
- prog->UniformStorage[i].is_shader_storage)
+ if (prog->data->UniformStorage[i].type->is_subroutine() ||
+ prog->data->UniformStorage[i].is_shader_storage)
continue;
/* Built-in uniforms should not get any location. */
- if (prog->UniformStorage[i].builtin)
+ if (prog->data->UniformStorage[i].builtin)
continue;
/* Explicit ones have been set already. */
- if (prog->UniformStorage[i].remap_location != UNMAPPED_UNIFORM_LOC)
+ if (prog->data->UniformStorage[i].remap_location != UNMAPPED_UNIFORM_LOC)
continue;
/* how many new entries for this uniform? */
- const unsigned entries = MAX2(1, prog->UniformStorage[i].array_elements);
+ const unsigned entries =
+ MAX2(1, prog->data->UniformStorage[i].array_elements);
/* Find UniformRemapTable for empty blocks where we can fit this uniform. */
int chosen_location = -1;
if (empty_locs)
- chosen_location = find_empty_block(prog, &prog->UniformStorage[i]);
+ chosen_location = find_empty_block(prog, &prog->data->UniformStorage[i]);
/* Add new entries to the total amount of entries. */
total_entries += entries;
@@ -1106,10 +1110,10 @@ link_setup_uniform_remap_tables(struct gl_context *ctx,
/* set pointers for this uniform */
for (unsigned j = 0; j < entries; j++)
prog->UniformRemapTable[chosen_location + j] =
- &prog->UniformStorage[i];
+ &prog->data->UniformStorage[i];
/* set the base location in remap table for the uniform */
- prog->UniformStorage[i].remap_location = chosen_location;
+ prog->data->UniformStorage[i].remap_location = chosen_location;
}
/* Verify that total amount of entries for explicit and implicit locations
@@ -1123,53 +1127,55 @@ link_setup_uniform_remap_tables(struct gl_context *ctx,
}
/* Reserve all the explicit locations of the active subroutine uniforms. */
- for (unsigned i = 0; i < prog->NumUniformStorage; i++) {
- if (!prog->UniformStorage[i].type->is_subroutine())
+ for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
+ if (!prog->data->UniformStorage[i].type->is_subroutine())
continue;
- if (prog->UniformStorage[i].remap_location == UNMAPPED_UNIFORM_LOC)
+ if (prog->data->UniformStorage[i].remap_location == UNMAPPED_UNIFORM_LOC)
continue;
/* How many new entries for this uniform? */
const unsigned entries =
- MAX2(1, prog->UniformStorage[i].array_elements);
+ MAX2(1, prog->data->UniformStorage[i].array_elements);
for (unsigned j = 0; j < MESA_SHADER_STAGES; j++) {
struct gl_linked_shader *sh = prog->_LinkedShaders[j];
if (!sh)
continue;
- if (!prog->UniformStorage[i].opaque[j].active)
+ if (!prog->data->UniformStorage[i].opaque[j].active)
continue;
/* Set remap table entries point to correct gl_uniform_storage. */
for (unsigned k = 0; k < entries; k++) {
- unsigned element_loc = prog->UniformStorage[i].remap_location + k;
+ unsigned element_loc =
+ prog->data->UniformStorage[i].remap_location + k;
assert(sh->SubroutineUniformRemapTable[element_loc] ==
INACTIVE_UNIFORM_EXPLICIT_LOCATION);
sh->SubroutineUniformRemapTable[element_loc] =
- &prog->UniformStorage[i];
+ &prog->data->UniformStorage[i];
}
}
}
/* reserve subroutine locations */
- for (unsigned i = 0; i < prog->NumUniformStorage; i++) {
- if (!prog->UniformStorage[i].type->is_subroutine())
+ for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
+ if (!prog->data->UniformStorage[i].type->is_subroutine())
continue;
- if (prog->UniformStorage[i].remap_location != UNMAPPED_UNIFORM_LOC)
+ if (prog->data->UniformStorage[i].remap_location !=
+ UNMAPPED_UNIFORM_LOC)
continue;
const unsigned entries =
- MAX2(1, prog->UniformStorage[i].array_elements);
+ MAX2(1, prog->data->UniformStorage[i].array_elements);
for (unsigned j = 0; j < MESA_SHADER_STAGES; j++) {
struct gl_linked_shader *sh = prog->_LinkedShaders[j];
if (!sh)
continue;
- if (!prog->UniformStorage[i].opaque[j].active)
+ if (!prog->data->UniformStorage[i].opaque[j].active)
continue;
sh->SubroutineUniformRemapTable =
@@ -1180,9 +1186,9 @@ link_setup_uniform_remap_tables(struct gl_context *ctx,
for (unsigned k = 0; k < entries; k++) {
sh->SubroutineUniformRemapTable[sh->NumSubroutineUniformRemapTable + k] =
- &prog->UniformStorage[i];
+ &prog->data->UniformStorage[i];
}
- prog->UniformStorage[i].remap_location =
+ prog->data->UniformStorage[i].remap_location =
sh->NumSubroutineUniformRemapTable;
sh->NumSubroutineUniformRemapTable += entries;
}
@@ -1197,14 +1203,14 @@ link_assign_uniform_storage(struct gl_context *ctx,
{
/* On the outside chance that there were no uniforms, bail out.
*/
- if (prog->NumUniformStorage == 0)
+ if (prog->data->NumUniformStorage == 0)
return;
unsigned int boolean_true = ctx->Const.UniformBooleanTrue;
- prog->UniformStorage = rzalloc_array(prog, struct gl_uniform_storage,
- prog->NumUniformStorage);
- union gl_constant_value *data = rzalloc_array(prog->UniformStorage,
+ prog->data->UniformStorage = rzalloc_array(prog, struct gl_uniform_storage,
+ prog->data->NumUniformStorage);
+ union gl_constant_value *data = rzalloc_array(prog->data->UniformStorage,
union gl_constant_value,
num_data_slots);
#ifndef NDEBUG
@@ -1212,7 +1218,7 @@ link_assign_uniform_storage(struct gl_context *ctx,
#endif
parcel_out_uniform_storage parcel(prog, prog->UniformHash,
- prog->UniformStorage, data);
+ prog->data->UniformStorage, data);
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
if (prog->_LinkedShaders[i] == NULL)
@@ -1240,11 +1246,11 @@ link_assign_uniform_storage(struct gl_context *ctx,
}
#ifndef NDEBUG
- for (unsigned i = 0; i < prog->NumUniformStorage; i++) {
- assert(prog->UniformStorage[i].storage != NULL ||
- prog->UniformStorage[i].builtin ||
- prog->UniformStorage[i].is_shader_storage ||
- prog->UniformStorage[i].block_index != -1);
+ for (unsigned i = 0; i < prog->data->NumUniformStorage; i++) {
+ assert(prog->data->UniformStorage[i].storage != NULL ||
+ prog->data->UniformStorage[i].builtin ||
+ prog->data->UniformStorage[i].is_shader_storage ||
+ prog->data->UniformStorage[i].block_index != -1);
}
assert(parcel.values == data_end);
@@ -1260,9 +1266,9 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
struct gl_context *ctx,
unsigned int num_explicit_uniform_locs)
{
- ralloc_free(prog->UniformStorage);
- prog->UniformStorage = NULL;
- prog->NumUniformStorage = 0;
+ ralloc_free(prog->data->UniformStorage);
+ prog->data->UniformStorage = NULL;
+ prog->data->NumUniformStorage = 0;
if (prog->UniformHash != NULL) {
prog->UniformHash->clear();
@@ -1324,8 +1330,8 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
}
}
- prog->NumUniformStorage = uniform_size.num_active_uniforms;
- prog->NumHiddenUniforms = uniform_size.num_hidden_uniforms;
+ prog->data->NumUniformStorage = uniform_size.num_active_uniforms;
+ prog->data->NumHiddenUniforms = uniform_size.num_hidden_uniforms;
/* assign hidden uniforms a slot id */
hiddenUniforms->iterate(assign_hidden_uniform_slot_id, &uniform_size);
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index e34cf286b54..61a029c6c56 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -415,12 +415,12 @@ linker_error(gl_shader_program *prog, const char *fmt, ...)
{
va_list ap;
- ralloc_strcat(&prog->InfoLog, "error: ");
+ ralloc_strcat(&prog->data->InfoLog, "error: ");
va_start(ap, fmt);
- ralloc_vasprintf_append(&prog->InfoLog, fmt, ap);
+ ralloc_vasprintf_append(&prog->data->InfoLog, fmt, ap);
va_end(ap);
- prog->LinkStatus = false;
+ prog->data->LinkStatus = false;
}
@@ -429,9 +429,9 @@ linker_warning(gl_shader_program *prog, const char *fmt, ...)
{
va_list ap;
- ralloc_strcat(&prog->InfoLog, "warning: ");
+ ralloc_strcat(&prog->data->InfoLog, "warning: ");
va_start(ap, fmt);
- ralloc_vasprintf_append(&prog->InfoLog, fmt, ap);
+ ralloc_vasprintf_append(&prog->data->InfoLog, fmt, ap);
va_end(ap);
}
@@ -1128,8 +1128,8 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog,
{
int *InterfaceBlockStageIndex[MESA_SHADER_STAGES];
struct gl_uniform_block *blks = NULL;
- unsigned *num_blks = validate_ssbo ? &prog->NumShaderStorageBlocks :
- &prog->NumUniformBlocks;
+ unsigned *num_blks = validate_ssbo ? &prog->data->NumShaderStorageBlocks :
+ &prog->data->NumUniformBlocks;
unsigned max_num_buffer_blocks = 0;
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
@@ -1206,9 +1206,9 @@ interstage_cross_validate_uniform_blocks(struct gl_shader_program *prog,
}
if (validate_ssbo)
- prog->ShaderStorageBlocks = blks;
+ prog->data->ShaderStorageBlocks = blks;
else
- prog->UniformBlocks = blks;
+ prog->data->UniformBlocks = blks;
return true;
}
@@ -2116,14 +2116,14 @@ link_intrastage_shaders(void *mem_ctx,
cross_validate_globals(prog, shader_list[i]->ir, &variables, false);
}
- if (!prog->LinkStatus)
+ if (!prog->data->LinkStatus)
return NULL;
/* Check that interface blocks defined in multiple shaders are consistent.
*/
validate_intrastage_interface_blocks(prog, (const gl_shader **)shader_list,
num_shaders);
- if (!prog->LinkStatus)
+ if (!prog->data->LinkStatus)
return NULL;
/* Check that there is only a single definition of each function signature
@@ -2195,7 +2195,7 @@ link_intrastage_shaders(void *mem_ctx,
_mesa_shader_stage_to_program(shader_list[0]->Stage),
prog->Name);
if (!prog) {
- prog->LinkStatus = false;
+ prog->data->LinkStatus = false;
_mesa_delete_linked_shader(ctx, linked);
return NULL;
}
@@ -2256,7 +2256,7 @@ link_intrastage_shaders(void *mem_ctx,
link_uniform_blocks(mem_ctx, ctx, prog, linked, &ubo_blocks,
&num_ubo_blocks, &ssbo_blocks, &num_ssbo_blocks);
- if (!prog->LinkStatus) {
+ if (!prog->data->LinkStatus) {
_mesa_delete_linked_shader(ctx, linked);
return NULL;
}
@@ -3110,22 +3110,22 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
ctx->Const.MaxCombinedShaderStorageBlocks);
}
- for (unsigned i = 0; i < prog->NumUniformBlocks; i++) {
- if (prog->UniformBlocks[i].UniformBufferSize >
+ for (unsigned i = 0; i < prog->data->NumUniformBlocks; i++) {
+ if (prog->data->UniformBlocks[i].UniformBufferSize >
ctx->Const.MaxUniformBlockSize) {
linker_error(prog, "Uniform block %s too big (%d/%d)\n",
- prog->UniformBlocks[i].Name,
- prog->UniformBlocks[i].UniformBufferSize,
+ prog->data->UniformBlocks[i].Name,
+ prog->data->UniformBlocks[i].UniformBufferSize,
ctx->Const.MaxUniformBlockSize);
}
}
- for (unsigned i = 0; i < prog->NumShaderStorageBlocks; i++) {
- if (prog->ShaderStorageBlocks[i].UniformBufferSize >
+ for (unsigned i = 0; i < prog->data->NumShaderStorageBlocks; i++) {
+ if (prog->data->ShaderStorageBlocks[i].UniformBufferSize >
ctx->Const.MaxShaderStorageBlockSize) {
linker_error(prog, "Shader storage block %s too big (%d/%d)\n",
- prog->ShaderStorageBlocks[i].Name,
- prog->ShaderStorageBlocks[i].UniformBufferSize,
+ prog->data->ShaderStorageBlocks[i].Name,
+ prog->data->ShaderStorageBlocks[i].UniformBufferSize,
ctx->Const.MaxShaderStorageBlockSize);
}
}
@@ -3441,8 +3441,8 @@ should_add_buffer_variable(struct gl_shader_program *shProg,
if (type != GL_BUFFER_VARIABLE)
return true;
- for (unsigned i = 0; i < shProg->NumShaderStorageBlocks; i++) {
- const char *block_name = shProg->ShaderStorageBlocks[i].Name;
+ for (unsigned i = 0; i < shProg->data->NumShaderStorageBlocks; i++) {
+ const char *block_name = shProg->data->ShaderStorageBlocks[i].Name;
block_name_len = strlen(block_name);
const char *block_square_bracket = strchr(block_name, '[');
@@ -4097,8 +4097,8 @@ calculate_array_size_and_stride(struct gl_shader_program *shProg,
char *var_name = get_top_level_name(uni->name);
char *interface_name =
get_top_level_name(uni->is_shader_storage ?
- shProg->ShaderStorageBlocks[block_index].Name :
- shProg->UniformBlocks[block_index].Name);
+ shProg->data->ShaderStorageBlocks[block_index].Name :
+ shProg->data->UniformBlocks[block_index].Name);
if (strcmp(var_name, interface_name) == 0) {
/* Deal with instanced array of SSBOs */
@@ -4235,73 +4235,75 @@ build_program_resource_list(struct gl_context *ctx,
}
/* Add uniforms from uniform storage. */
- for (unsigned i = 0; i < shProg->NumUniformStorage; i++) {
+ for (unsigned i = 0; i < shProg->data->NumUniformStorage; i++) {
/* Do not add uniforms internally used by Mesa. */
- if (shProg->UniformStorage[i].hidden)
+ if (shProg->data->UniformStorage[i].hidden)
continue;
uint8_t stageref =
- build_stageref(shProg, shProg->UniformStorage[i].name,
+ build_stageref(shProg, shProg->data->UniformStorage[i].name,
ir_var_uniform);
/* Add stagereferences for uniforms in a uniform block. */
- bool is_shader_storage = shProg->UniformStorage[i].is_shader_storage;
- int block_index = shProg->UniformStorage[i].block_index;
+ bool is_shader_storage =
+ shProg->data->UniformStorage[i].is_shader_storage;
+ int block_index = shProg->data->UniformStorage[i].block_index;
if (block_index != -1) {
stageref |= is_shader_storage ?
- shProg->ShaderStorageBlocks[block_index].stageref :
- shProg->UniformBlocks[block_index].stageref;
+ shProg->data->ShaderStorageBlocks[block_index].stageref :
+ shProg->data->UniformBlocks[block_index].stageref;
}
GLenum type = is_shader_storage ? GL_BUFFER_VARIABLE : GL_UNIFORM;
if (!should_add_buffer_variable(shProg, type,
- shProg->UniformStorage[i].name))
+ shProg->data->UniformStorage[i].name))
continue;
if (is_shader_storage) {
- calculate_array_size_and_stride(shProg, &shProg->UniformStorage[i]);
+ calculate_array_size_and_stride(shProg,
+ &shProg->data->UniformStorage[i]);
}
if (!add_program_resource(shProg, resource_set, type,
- &shProg->UniformStorage[i], stageref))
+ &shProg->data->UniformStorage[i], stageref))
return;
}
/* Add program uniform blocks. */
- for (unsigned i = 0; i < shProg->NumUniformBlocks; i++) {
+ for (unsigned i = 0; i < shProg->data->NumUniformBlocks; i++) {
if (!add_program_resource(shProg, resource_set, GL_UNIFORM_BLOCK,
- &shProg->UniformBlocks[i], 0))
+ &shProg->data->UniformBlocks[i], 0))
return;
}
/* Add program shader storage blocks. */
- for (unsigned i = 0; i < shProg->NumShaderStorageBlocks; i++) {
+ for (unsigned i = 0; i < shProg->data->NumShaderStorageBlocks; i++) {
if (!add_program_resource(shProg, resource_set, GL_SHADER_STORAGE_BLOCK,
- &shProg->ShaderStorageBlocks[i], 0))
+ &shProg->data->ShaderStorageBlocks[i], 0))
return;
}
/* Add atomic counter buffers. */
- for (unsigned i = 0; i < shProg->NumAtomicBuffers; i++) {
+ for (unsigned i = 0; i < shProg->data->NumAtomicBuffers; i++) {
if (!add_program_resource(shProg, resource_set, GL_ATOMIC_COUNTER_BUFFER,
- &shProg->AtomicBuffers[i], 0))
+ &shProg->data->AtomicBuffers[i], 0))
return;
}
- for (unsigned i = 0; i < shProg->NumUniformStorage; i++) {
+ for (unsigned i = 0; i < shProg->data->NumUniformStorage; i++) {
GLenum type;
- if (!shProg->UniformStorage[i].hidden)
+ if (!shProg->data->UniformStorage[i].hidden)
continue;
for (int j = MESA_SHADER_VERTEX; j < MESA_SHADER_STAGES; j++) {
- if (!shProg->UniformStorage[i].opaque[j].active ||
- !shProg->UniformStorage[i].type->is_subroutine())
+ if (!shProg->data->UniformStorage[i].opaque[j].active ||
+ !shProg->data->UniformStorage[i].type->is_subroutine())
continue;
type = _mesa_shader_stage_to_subroutine_uniform((gl_shader_stage)j);
/* add shader subroutines */
if (!add_program_resource(shProg, resource_set,
- type, &shProg->UniformStorage[i], 0))
+ type, &shProg->data->UniformStorage[i], 0))
return;
}
}
@@ -4686,7 +4688,7 @@ link_varyings_and_uniforms(unsigned first, unsigned last,
check_image_resources(ctx, prog);
link_check_atomic_counter_resources(ctx, prog);
- if (!prog->LinkStatus)
+ if (!prog->data->LinkStatus)
return false;
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
@@ -4714,8 +4716,8 @@ link_varyings_and_uniforms(unsigned first, unsigned last,
void
link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
{
- prog->LinkStatus = true; /* All error paths will set this to false */
- prog->Validated = false;
+ prog->data->LinkStatus = true; /* All error paths will set this to false */
+ prog->data->Validated = false;
prog->_Used = false;
/* Section 7.3 (Program Objects) of the OpenGL 4.5 Core Profile spec says:
@@ -4848,7 +4850,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
link_intrastage_shaders(mem_ctx, ctx, prog, shader_list[stage],
num_shaders[stage], false);
- if (!prog->LinkStatus) {
+ if (!prog->data->LinkStatus) {
if (sh)
_mesa_delete_linked_shader(ctx, sh);
goto done;
@@ -4871,7 +4873,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
validate_fragment_shader_executable(prog, sh);
break;
}
- if (!prog->LinkStatus) {
+ if (!prog->data->LinkStatus) {
if (sh)
_mesa_delete_linked_shader(ctx, sh);
goto done;
@@ -4900,7 +4902,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
* varyings.
*/
cross_validate_uniforms(prog);
- if (!prog->LinkStatus)
+ if (!prog->data->LinkStatus)
goto done;
unsigned first, last, prev;
@@ -4920,7 +4922,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
num_explicit_uniform_locs = check_explicit_uniform_locations(ctx, prog);
link_assign_subroutine_types(prog);
- if (!prog->LinkStatus)
+ if (!prog->data->LinkStatus)
goto done;
resize_tes_inputs(ctx, prog);
@@ -4935,13 +4937,13 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
validate_interstage_inout_blocks(prog, prog->_LinkedShaders[prev],
prog->_LinkedShaders[i]);
- if (!prog->LinkStatus)
+ if (!prog->data->LinkStatus)
goto done;
cross_validate_outputs_to_inputs(prog,
prog->_LinkedShaders[prev],
prog->_LinkedShaders[i]);
- if (!prog->LinkStatus)
+ if (!prog->data->LinkStatus)
goto done;
prev = i;
@@ -4949,7 +4951,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
/* Cross-validate uniform blocks between shader stages */
validate_interstage_uniform_blocks(prog, prog->_LinkedShaders);
- if (!prog->LinkStatus)
+ if (!prog->data->LinkStatus)
goto done;
for (unsigned int i = 0; i < MESA_SHADER_STAGES; i++) {
@@ -4990,7 +4992,7 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
continue;
detect_recursion_linked(prog, prog->_LinkedShaders[i]->ir);
- if (!prog->LinkStatus)
+ if (!prog->data->LinkStatus)
goto done;
if (ctx->Const.ShaderCompilerOptions[i].LowerCombinedClipCullDistance) {
diff --git a/src/compiler/glsl/standalone.cpp b/src/compiler/glsl/standalone.cpp
index 41f122af566..00c9500d871 100644
--- a/src/compiler/glsl/standalone.cpp
+++ b/src/compiler/glsl/standalone.cpp
@@ -439,7 +439,9 @@ standalone_compile_shader(const struct standalone_options *_options,
whole_program = rzalloc (NULL, struct gl_shader_program);
assert(whole_program != NULL);
- whole_program->InfoLog = ralloc_strdup(whole_program, "");
+ whole_program->data = rzalloc(whole_program, struct gl_shader_program_data);
+ assert(whole_program->data != NULL);
+ whole_program->data->InfoLog = ralloc_strdup(whole_program->data, "");
/* Created just to avoid segmentation faults */
whole_program->AttributeBindings = new string_to_uint_map;
@@ -510,7 +512,7 @@ standalone_compile_shader(const struct standalone_options *_options,
} else {
const gl_shader_stage stage = whole_program->Shaders[0]->Stage;
- whole_program->LinkStatus = GL_TRUE;
+ whole_program->data->LinkStatus = GL_TRUE;
whole_program->_LinkedShaders[stage] =
link_intrastage_shaders(whole_program /* mem_ctx */,
ctx,
@@ -523,7 +525,7 @@ standalone_compile_shader(const struct standalone_options *_options,
* references.
*/
if (whole_program->_LinkedShaders[stage] != NULL) {
- assert(whole_program->LinkStatus);
+ assert(whole_program->data->LinkStatus);
struct gl_shader_compiler_options *const compiler_options =
&ctx->Const.ShaderCompilerOptions[stage];
@@ -545,13 +547,13 @@ standalone_compile_shader(const struct standalone_options *_options,
}
}
- status = (whole_program->LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE;
+ status = (whole_program->data->LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE;
- if (strlen(whole_program->InfoLog) > 0) {
+ if (strlen(whole_program->data->InfoLog) > 0) {
printf("\n");
if (!options->just_log)
printf("Info log for linking:\n");
- printf("%s", whole_program->InfoLog);
+ printf("%s", whole_program->data->InfoLog);
if (!options->just_log)
printf("\n");
}
diff --git a/src/compiler/glsl/standalone_scaffolding.cpp b/src/compiler/glsl/standalone_scaffolding.cpp
index 6d17e387785..11134269c90 100644
--- a/src/compiler/glsl/standalone_scaffolding.cpp
+++ b/src/compiler/glsl/standalone_scaffolding.cpp
@@ -141,26 +141,26 @@ _mesa_clear_shader_program_data(struct gl_context *ctx,
}
}
- shProg->NumUniformStorage = 0;
- shProg->UniformStorage = NULL;
+ shProg->data->NumUniformStorage = 0;
+ shProg->data->UniformStorage = NULL;
shProg->NumUniformRemapTable = 0;
shProg->UniformRemapTable = NULL;
shProg->UniformHash = NULL;
- ralloc_free(shProg->InfoLog);
- shProg->InfoLog = ralloc_strdup(shProg, "");
+ ralloc_free(shProg->data->InfoLog);
+ shProg->data->InfoLog = ralloc_strdup(shProg->data, "");
- ralloc_free(shProg->UniformBlocks);
- shProg->UniformBlocks = NULL;
- shProg->NumUniformBlocks = 0;
+ ralloc_free(shProg->data->UniformBlocks);
+ shProg->data->UniformBlocks = NULL;
+ shProg->data->NumUniformBlocks = 0;
- ralloc_free(shProg->ShaderStorageBlocks);
- shProg->ShaderStorageBlocks = NULL;
- shProg->NumShaderStorageBlocks = 0;
+ ralloc_free(shProg->data->ShaderStorageBlocks);
+ shProg->data->ShaderStorageBlocks = NULL;
+ shProg->data->NumShaderStorageBlocks = 0;
- ralloc_free(shProg->AtomicBuffers);
- shProg->AtomicBuffers = NULL;
- shProg->NumAtomicBuffers = 0;
+ ralloc_free(shProg->data->AtomicBuffers);
+ shProg->data->AtomicBuffers = NULL;
+ shProg->data->NumAtomicBuffers = 0;
}
void initialize_context_to_defaults(struct gl_context *ctx, gl_api api)
diff --git a/src/compiler/glsl/tests/set_uniform_initializer_tests.cpp b/src/compiler/glsl/tests/set_uniform_initializer_tests.cpp
index 245494c739b..d30abc320b3 100644
--- a/src/compiler/glsl/tests/set_uniform_initializer_tests.cpp
+++ b/src/compiler/glsl/tests/set_uniform_initializer_tests.cpp
@@ -70,6 +70,7 @@ set_uniform_initializer::SetUp()
{
this->mem_ctx = ralloc_context(NULL);
this->prog = rzalloc(NULL, struct gl_shader_program);
+ this->prog->data = rzalloc(this->prog, struct gl_shader_program_data);
/* Set default values used by the test cases.
*/
@@ -110,43 +111,43 @@ establish_uniform_storage(struct gl_shader_program *prog, unsigned num_storage,
const unsigned red_zone_components = total_components - data_components;
prog->UniformHash = new string_to_uint_map;
- prog->UniformStorage = rzalloc_array(prog, struct gl_uniform_storage,
- num_storage);
- prog->NumUniformStorage = num_storage;
+ prog->data->UniformStorage = rzalloc_array(prog, struct gl_uniform_storage,
+ num_storage);
+ prog->data->NumUniformStorage = num_storage;
- prog->UniformStorage[index_to_set].name = (char *) name;
- prog->UniformStorage[index_to_set].type = type;
- prog->UniformStorage[index_to_set].array_elements = array_size;
+ prog->data->UniformStorage[index_to_set].name = (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++) {
- prog->UniformStorage[index_to_set].opaque[sh].index = ~0;
- prog->UniformStorage[index_to_set].opaque[sh].active = false;
+ prog->data->UniformStorage[index_to_set].opaque[sh].index = ~0;
+ prog->data->UniformStorage[index_to_set].opaque[sh].active = false;
}
- prog->UniformStorage[index_to_set].num_driver_storage = 0;
- prog->UniformStorage[index_to_set].driver_storage = NULL;
- prog->UniformStorage[index_to_set].storage =
+ prog->data->UniformStorage[index_to_set].num_driver_storage = 0;
+ prog->data->UniformStorage[index_to_set].driver_storage = NULL;
+ prog->data->UniformStorage[index_to_set].storage =
rzalloc_array(prog, union gl_constant_value, total_components);
- fill_storage_array_with_sentinels(prog->UniformStorage[index_to_set].storage,
+ fill_storage_array_with_sentinels(prog->data->UniformStorage[index_to_set].storage,
data_components,
red_zone_components);
prog->UniformHash->put(index_to_set,
- prog->UniformStorage[index_to_set].name);
+ prog->data->UniformStorage[index_to_set].name);
for (unsigned i = 0; i < num_storage; i++) {
if (i == index_to_set)
continue;
- prog->UniformStorage[i].name = (char *) "invalid slot";
- prog->UniformStorage[i].type = glsl_type::void_type;
- prog->UniformStorage[i].array_elements = 0;
+ prog->data->UniformStorage[i].name = (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++) {
- prog->UniformStorage[i].opaque[sh].index = ~0;
- prog->UniformStorage[i].opaque[sh].active = false;
+ prog->data->UniformStorage[i].opaque[sh].index = ~0;
+ prog->data->UniformStorage[i].opaque[sh].active = false;
}
- prog->UniformStorage[i].num_driver_storage = 0;
- prog->UniformStorage[i].driver_storage = NULL;
- prog->UniformStorage[i].storage = NULL;
+ prog->data->UniformStorage[i].num_driver_storage = 0;
+ prog->data->UniformStorage[i].driver_storage = NULL;
+ prog->data->UniformStorage[i].storage = NULL;
}
return red_zone_components;
@@ -169,7 +170,7 @@ non_array_test(void *mem_ctx, struct gl_shader_program *prog,
linker::set_uniform_initializer(mem_ctx, prog, name, type, val, 0xF00F);
- verify_data(prog->UniformStorage[actual_index].storage, 0, val,
+ verify_data(prog->data->UniformStorage[actual_index].storage, 0, val,
red_zone_components, 0xF00F);
}
@@ -325,7 +326,7 @@ array_test(void *mem_ctx, struct gl_shader_program *prog,
linker::set_uniform_initializer(mem_ctx, prog, name, element_type, val,
0xF00F);
- verify_data(prog->UniformStorage[actual_index].storage, array_size,
+ verify_data(prog->data->UniformStorage[actual_index].storage, array_size,
val, red_zone_components, 0xF00F);
}
diff --git a/src/compiler/nir/nir_lower_atomics.c b/src/compiler/nir/nir_lower_atomics.c
index 6fea8f468f2..7a213fcb46e 100644
--- a/src/compiler/nir/nir_lower_atomics.c
+++ b/src/compiler/nir/nir_lower_atomics.c
@@ -100,7 +100,7 @@ lower_instr(nir_intrinsic_instr *instr,
nir_intrinsic_instr *new_instr = nir_intrinsic_instr_create(mem_ctx, op);
nir_intrinsic_set_base(new_instr,
- shader_program->UniformStorage[uniform_loc].opaque[shader->stage].index);
+ shader_program->data->UniformStorage[uniform_loc].opaque[shader->stage].index);
nir_load_const_instr *offset_const =
nir_load_const_instr_create(mem_ctx, 1, 32);
diff --git a/src/compiler/nir/nir_lower_samplers.c b/src/compiler/nir/nir_lower_samplers.c
index e878edd9b54..9debfb2eaf9 100644
--- a/src/compiler/nir/nir_lower_samplers.c
+++ b/src/compiler/nir/nir_lower_samplers.c
@@ -140,14 +140,14 @@ lower_sampler(nir_tex_instr *instr, const struct gl_shader_program *shader_progr
instr->texture_array_size = array_elements;
}
- if (location > shader_program->NumUniformStorage - 1 ||
- !shader_program->UniformStorage[location].opaque[stage].active) {
+ if (location > shader_program->data->NumUniformStorage - 1 ||
+ !shader_program->data->UniformStorage[location].opaque[stage].active) {
assert(!"cannot return a sampler");
return;
}
instr->texture_index +=
- shader_program->UniformStorage[location].opaque[stage].index;
+ shader_program->data->UniformStorage[location].opaque[stage].index;
instr->sampler_index = instr->texture_index;