summaryrefslogtreecommitdiff
path: root/src/mesa/shader
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-01-09 09:59:49 -0700
committerBrian Paul <brianp@vmware.com>2009-01-09 10:11:09 -0700
commita719d704741ae21d1b12138c863f22286b98a5af (patch)
tree45ab3d5ca487fb0fd47f9d57a96d2717aaa01004 /src/mesa/shader
parent630b6e896b30d8e856c1c86f4b67f64111ba59f5 (diff)
glsl: make minimum struct size = 2, not 1
1-component structs such as "struct foo { float x; }" could get placed at any position within a register. This caused some trouble computing the field offset which assumed all struct objects were placed at R.x. It would be unusual to hit this case in normal shaders. (cherry picked from master, commit ca03e881a8d8fa3e36a601238559c20311373633)
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index cc6d71478d..712f5975dc 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -213,7 +213,14 @@ _slang_sizeof_type_specifier(const slang_type_specifier *spec)
break;
case SLANG_SPEC_STRUCT:
sz = _slang_field_offset(spec, 0); /* special use */
- if (sz > 4) {
+ if (sz == 1) {
+ /* 1-float structs are actually troublesome to deal with since they
+ * might get placed at R.x, R.y, R.z or R.z. Return size=2 to
+ * ensure the object is placed at R.x
+ */
+ sz = 2;
+ }
+ else if (sz > 4) {
sz = (sz + 3) & ~0x3; /* round up to multiple of four */
}
break;