OSDN Git Service

i965: Fix output register sizes when multiple variables share a slot.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 10 Oct 2017 08:02:44 +0000 (01:02 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Wed, 11 Oct 2017 00:29:37 +0000 (17:29 -0700)
commit6f5abf31466aedd63234aa318f8d2d0e4cb35570
tree4bf705a2fad1af5d36a7d21e675e055fdaf73fcf
parent2d36efdb7f18f061c519dbb93f6058bf161aad33
i965: Fix output register sizes when multiple variables share a slot.

ARB_enhanced_layouts allows multiple output variables to share the same
location - and these variables may not have the same sizes.  For
example, consider these output variables:

   // consume X/Y/Z components of 6 vectors
   layout(location = 0) out vec3 a[6];

   // consumes W component of the first vector
   layout(location = 0, component = 3) out float b;

Looking at the first declaration, we see that VARYING_SLOT_VAR0 needs 24
components worth of space (vec3 padded out to a vec4, 4 * 6 = 24).  But
looking at the second declaration, we would think that VARYING_SLOT_VAR0
needs only 4 components of space (a single float padded out to a vec4).

nir_setup_outputs() only considered the space requirements of the first
declaration it happened to see, so if 'float b' came first, it would
underallocate the output register space, causing brw_fs_validator.cpp
to assert fail about inst->dst.offset exceeding the register size.

Fixes Piglit's tests/spec/arb_enhanced_layouts/execution/component-layout/
vs-to-fs-array-interleave-single-location.shader_test.

Thanks to Tim Arceri for finding this bug and writing a test!

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/intel/compiler/brw_fs_nir.cpp