diff options
author | Eric Anholt <eric@anholt.net> | 2012-07-09 15:52:53 -0700 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2012-08-07 11:47:49 -0700 |
commit | 2ea3ab14f2182978f471674c9dfce029d37f70a7 (patch) | |
tree | 43b8cc92126bea4c705e942c06390a060eaf5631 /src/glsl/ir_validate.cpp | |
parent | 71ba6de342b88dcf8ed3aa347da157b7724230e7 (diff) | |
download | external_mesa3d-2ea3ab14f2182978f471674c9dfce029d37f70a7.zip external_mesa3d-2ea3ab14f2182978f471674c9dfce029d37f70a7.tar.gz external_mesa3d-2ea3ab14f2182978f471674c9dfce029d37f70a7.tar.bz2 |
glsl: Add a "ubo_load" expression type for fetches from UBOs.
Drivers will probably want to be able to take UBO references in a
shader like:
uniform ubo1 {
float a;
float b;
float c;
float d;
}
void main() {
gl_FragColor = vec4(a, b, c, d);
}
and generate a single aligned vec4 load out of the UBO. For intel,
this involves recognizing the shared offset of the aligned loads and
CSEing them out. Obviously that involves breaking things down to
loads from an offset from a particular UBO first. Thus, the driver
doesn't want to see
variable_ref(ir_variable("a")),
and even more so does it not want to see
array_ref(record_ref(variable_ref(ir_variable("a")),
"field1"), variable_ref(ir_variable("i"))).
where a.field1[i] is a row_major matrix.
Instead, we're going to make a lowering pass to break UBO references
down to expressions that are obvious to codegen, and amenable to
merging through CSE.
v2: Fix some partial thoughts in the ir_binop comment (review by Kenneth)
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Diffstat (limited to 'src/glsl/ir_validate.cpp')
-rw-r--r-- | src/glsl/ir_validate.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/glsl/ir_validate.cpp b/src/glsl/ir_validate.cpp index 191d398..af0b576 100644 --- a/src/glsl/ir_validate.cpp +++ b/src/glsl/ir_validate.cpp @@ -423,6 +423,13 @@ ir_validate::visit_leave(ir_expression *ir) assert(ir->operands[0]->type == ir->operands[1]->type); break; + case ir_binop_ubo_load: + assert(ir->operands[0]->as_constant()); + assert(ir->operands[0]->type == glsl_type::uint_type); + + assert(ir->operands[1]->type == glsl_type::uint_type); + break; + case ir_quadop_vector: /* The vector operator collects some number of scalars and generates a * vector from them. |