[Mesa-dev] [PATCH 04/74] glsl: link buffer variables and shader storage buffer interface blocks
Iago Toral Quiroga
itoral at igalia.com
Thu May 14 07:06:07 PDT 2015
From: Kristian Høgsberg <krh at bitplanet.net>
---
src/glsl/link_interface_blocks.cpp | 15 ++++++++++++---
src/glsl/link_uniform_initializers.cpp | 3 ++-
src/glsl/link_uniforms.cpp | 8 +++++---
src/glsl/linker.cpp | 4 ++--
4 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/src/glsl/link_interface_blocks.cpp b/src/glsl/link_interface_blocks.cpp
index 07f5b42..9c30acc 100644
--- a/src/glsl/link_interface_blocks.cpp
+++ b/src/glsl/link_interface_blocks.cpp
@@ -112,7 +112,8 @@ intrastage_match(interface_block_definition *a,
* it's not clear from the spec whether they need to match, but
* Mesa's implementation relies on them matching.
*/
- if (a->instance_name != NULL && mode != ir_var_uniform &&
+ if (a->instance_name != NULL &&
+ mode != ir_var_uniform && mode != ir_var_buffer &&
strcmp(a->instance_name, b->instance_name) != 0) {
return false;
}
@@ -253,6 +254,7 @@ validate_intrastage_interface_blocks(struct gl_shader_program *prog,
interface_block_definitions in_interfaces;
interface_block_definitions out_interfaces;
interface_block_definitions uniform_interfaces;
+ interface_block_definitions buffer_interfaces;
for (unsigned int i = 0; i < num_shaders; i++) {
if (shader_list[i] == NULL)
@@ -279,6 +281,9 @@ validate_intrastage_interface_blocks(struct gl_shader_program *prog,
case ir_var_uniform:
definitions = &uniform_interfaces;
break;
+ case ir_var_buffer:
+ definitions = &buffer_interfaces;
+ break;
default:
/* Only in, out, and uniform interfaces are legal, so we should
* never get here.
@@ -361,7 +366,9 @@ validate_interstage_uniform_blocks(struct gl_shader_program *prog,
const gl_shader *stage = stages[i];
foreach_in_list(ir_instruction, node, stage->ir) {
ir_variable *var = node->as_variable();
- if (!var || !var->get_interface_type() || var->data.mode != ir_var_uniform)
+ if (!var || !var->get_interface_type() ||
+ (var->data.mode != ir_var_uniform &&
+ var->data.mode != ir_var_buffer))
continue;
interface_block_definition *old_def =
@@ -374,7 +381,9 @@ validate_interstage_uniform_blocks(struct gl_shader_program *prog,
* uniform matchin rules (for uniforms, it is as though all
* shaders are in the same shader stage).
*/
- if (!intrastage_match(old_def, &new_def, ir_var_uniform, prog)) {
+ if (!intrastage_match(old_def, &new_def,
+ (ir_variable_mode) var->data.mode,
+ prog)) {
linker_error(prog, "definitions of interface block `%s' do not "
"match\n", var->get_interface_type()->name);
return;
diff --git a/src/glsl/link_uniform_initializers.cpp b/src/glsl/link_uniform_initializers.cpp
index 6907384..d36806f 100644
--- a/src/glsl/link_uniform_initializers.cpp
+++ b/src/glsl/link_uniform_initializers.cpp
@@ -256,7 +256,8 @@ link_set_uniform_initializers(struct gl_shader_program *prog,
foreach_in_list(ir_instruction, node, shader->ir) {
ir_variable *const var = node->as_variable();
- if (!var || var->data.mode != ir_var_uniform)
+ if (!var || (var->data.mode != ir_var_uniform &&
+ var->data.mode != ir_var_buffer))
continue;
if (!mem_ctx)
diff --git a/src/glsl/link_uniforms.cpp b/src/glsl/link_uniforms.cpp
index 2c928e1..2137364 100644
--- a/src/glsl/link_uniforms.cpp
+++ b/src/glsl/link_uniforms.cpp
@@ -760,7 +760,8 @@ link_update_uniform_buffer_variables(struct gl_shader *shader)
if ((var == NULL) || !var->is_in_uniform_block())
continue;
- assert(var->data.mode == ir_var_uniform);
+ assert(var->data.mode == ir_var_uniform ||
+ var->data.mode == ir_var_buffer);
if (var->is_interface_instance()) {
var->data.location = 0;
@@ -937,7 +938,8 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
foreach_in_list(ir_instruction, node, sh->ir) {
ir_variable *const var = node->as_variable();
- if ((var == NULL) || (var->data.mode != ir_var_uniform))
+ if ((var == NULL) || (var->data.mode != ir_var_uniform &&
+ var->data.mode != ir_var_buffer))
continue;
/* FINISHME: Update code to process built-in uniforms!
@@ -989,7 +991,7 @@ link_assign_uniform_locations(struct gl_shader_program *prog,
foreach_in_list(ir_instruction, node, prog->_LinkedShaders[i]->ir) {
ir_variable *const var = node->as_variable();
- if ((var == NULL) || (var->data.mode != ir_var_uniform))
+ if ((var == NULL) || (var->data.mode != ir_var_uniform && var->data.mode != ir_var_buffer))
continue;
/* FINISHME: Update code to process built-in uniforms!
diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index ea73c6f..08914e0 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -744,7 +744,7 @@ cross_validate_globals(struct gl_shader_program *prog,
if (var == NULL)
continue;
- if (uniforms_only && (var->data.mode != ir_var_uniform))
+ if (uniforms_only && (var->data.mode != ir_var_uniform && var->data.mode != ir_var_buffer))
continue;
/* Don't cross validate temporaries that are at global scope. These
@@ -2520,7 +2520,7 @@ check_explicit_uniform_locations(struct gl_context *ctx,
foreach_in_list(ir_instruction, node, sh->ir) {
ir_variable *var = node->as_variable();
- if ((var && var->data.mode == ir_var_uniform) &&
+ if (var && (var->data.mode == ir_var_uniform || var->data.mode == ir_var_buffer) &&
var->data.explicit_location) {
if (!reserve_explicit_locations(prog, uniform_map, var)) {
delete uniform_map;
--
1.9.1
More information about the mesa-dev
mailing list