v3d: handle writes to gl_Layer from geometry shaders
authorIago Toral Quiroga <itoral@igalia.com>
Tue, 29 Oct 2019 09:12:28 +0000 (10:12 +0100)
committerIago Toral Quiroga <itoral@igalia.com>
Mon, 16 Dec 2019 07:42:37 +0000 (08:42 +0100)
commit6c7a2b69f8df5a9c0cb8c8f3b099694bbe1b0b53
tree3fcde4d2747cc470dfcc174df12cc4f2b585ba2e
parent45bc61add078b11e1809cf607e9c876329004d5d
v3d: handle writes to gl_Layer from geometry shaders

When geometry shaders write a value to gl_Layer that doesn't correspond to
an existing layer in the target framebuffer the rendering behavior is
undefined according to the spec, however, there are CTS tests that trigger
this scenario on purpose, probably to ensure that nothing terrible happens.

For V3D, this situation is problematic because the binner uses the layer
index to select the offset to write into the tile state data, and we only
allocate tile state for MAX2(num_layers, 1), so we want to make sure we
don't produce values that would lead to out of bounds writes. The simulator
has an assert to catch this, although we haven't observed issues in actual
hardware it is probably best to play safe.

Reviewed-by: Alejandro PiƱeiro <apinheiro@igalia.com>
src/broadcom/compiler/nir_to_vir.c
src/broadcom/compiler/v3d_compiler.h
src/broadcom/compiler/v3d_nir_lower_io.c
src/compiler/nir/nir_intrinsics.py
src/gallium/drivers/v3d/v3d_uniforms.c