mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 20:28:04 +02:00
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.
This commit is contained in:
parent
4497a5a57d
commit
ca03e881a8
1 changed files with 8 additions and 1 deletions
|
|
@ -228,7 +228,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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue