v3d/compiler: extend swapping R/B support to all vertex attributes

So far the support for R/B swapping in vertex attributes were for the
generic attributes.

But there are cases like glSecondaryColorPointer() supporting BGRA
formats that require the R/B swapping to be also allowed in the
non-generic vertex attributes (in this case, in the COLOR1 attribute).

v2:
 - Don't split line (Iago)

Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7196>
This commit is contained in:
Juan A. Suarez Romero 2020-10-16 11:27:42 +02:00 committed by Marge Bot
parent 44925a8a55
commit 1e723745dd
3 changed files with 6 additions and 11 deletions

View file

@ -1611,14 +1611,10 @@ ntq_setup_vs_inputs(struct v3d_compile *c)
c->vattr_sizes[loc] = MAX2(c->vattr_sizes[loc],
start_component + num_components);
/* Handle BGRA user inputs */
/* Handle BGRA inputs */
if (start_component == 0 &&
var->data.location >= VERT_ATTRIB_GENERIC0) {
int32_t idx = var->data.location - VERT_ATTRIB_GENERIC0;
if (c->vs_key->va_swap_rb_mask & (1 << idx)) {
c->vattr_sizes[loc] =
MAX2(3, c->vattr_sizes[loc]);
}
c->vs_key->va_swap_rb_mask & (1 << var->data.location)) {
c->vattr_sizes[loc] = MAX2(3, c->vattr_sizes[loc]);
}
}

View file

@ -418,7 +418,7 @@ struct v3d_vs_key {
* 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;
uint32_t va_swap_rb_mask;
bool is_coord;
bool per_vertex_point_size;

View file

@ -332,9 +332,8 @@ v3d_nir_lower_vertex_input(struct v3d_compile *c, nir_builder *b,
if (!c->vs_key->va_swap_rb_mask)
return;
const uint32_t location =
nir_intrinsic_io_semantics(instr).location - VERT_ATTRIB_GENERIC0;
assert(location < V3D_MAX_VS_INPUTS / 4);
const uint32_t location = nir_intrinsic_io_semantics(instr).location;
if (!(c->vs_key->va_swap_rb_mask & (1 << location)))
return;