v3d/compiler: support swapping R/B channels in vertex attributes.

We will need this in Vulkan to support vertex format
VK_FORMAT_B8G8R8A8_UNORM.  The hardware doesn't allow to swizzle
vertex attribute components, so we need to do it in the shader.

v2:
 - Use nir_intrinsic_io_semantics() to retrieve the location instead
   of looping through the shader input variables (Eric).
 - Assert that we only have one component (Eric).

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> (v1)
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
Iago Toral Quiroga
2020-07-07 11:10:57 +02:00
committed by Marge Bot
parent a2538b2520
commit 5a2ef59963
2 changed files with 39 additions and 0 deletions

View File

@@ -412,6 +412,12 @@ struct v3d_vs_key {
struct v3d_varying_slot used_outputs[V3D_MAX_ANY_STAGE_INPUTS];
uint8_t num_used_outputs;
/* A bit-mask indicating if we need to swap the R/B channels for
* vertex attributes. Since the hardware doesn't provide any
* means to swizzle vertex attributes we need to do it in the shader.
*/
uint16_t va_swap_rb_mask;
bool is_coord;
bool per_vertex_point_size;
bool clamp_color;