v3d: Add GL_ARB_vertex_array_bgra support

This is done by adding support to PIPE_FORMAT_B8G8R8A8_UNORM, and
relying on the R/B swapping for vertex attributes implemented in the
compiler.

v2:
 - Simplify the loop (Iago)

v3:
 - Assert before derreferencing variable (Iago).

Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3078
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7196>
This commit is contained in:
Juan A. Suarez Romero 2020-10-16 17:07:57 +02:00 committed by Marge Bot
parent 9648bfba56
commit 60b9c00afd
3 changed files with 25 additions and 1 deletions

View File

@ -86,7 +86,7 @@ GL 3.2, GLSL 1.50 --- all DONE: i965, nv50, nvc0, r600, radeonsi, llvmpipe, soft
Core/compatibility profiles DONE
Geometry shaders DONE ()
GL_ARB_vertex_array_bgra (BGRA vertex order) DONE (freedreno, panfrost)
GL_ARB_vertex_array_bgra (BGRA vertex order) DONE (freedreno, v3d, panfrost)
GL_ARB_draw_elements_base_vertex (Base vertex offset) DONE (freedreno, v3d, panfrost)
GL_ARB_fragment_coord_conventions (Frag shader coord) DONE (freedreno, v3d, panfrost)
GL_ARB_provoking_vertex (Provoking vertex) DONE (freedreno, v3d, panfrost)

View File

@ -762,6 +762,29 @@ v3d_update_compiled_vs(struct v3d_context *v3d, uint8_t prim_mode)
(prim_mode == PIPE_PRIM_POINTS &&
v3d->rasterizer->base.point_size_per_vertex);
nir_shader *s = v3d->prog.bind_vs->base.ir.nir;
uint64_t inputs_read = s->info.inputs_read;
assert(util_bitcount(inputs_read) <= v3d->vtx->num_elements);
while (inputs_read) {
int location = u_bit_scan64(&inputs_read);
nir_variable *var =
nir_find_variable_with_location(s, nir_var_shader_in, location);
assert (var != NULL);
int driver_location = var->data.driver_location;
switch (v3d->vtx->pipe[driver_location].src_format) {
case PIPE_FORMAT_B8G8R8A8_UNORM:
case PIPE_FORMAT_B10G10R10A2_UNORM:
case PIPE_FORMAT_B10G10R10A2_SNORM:
case PIPE_FORMAT_B10G10R10A2_USCALED:
case PIPE_FORMAT_B10G10R10A2_SSCALED:
key->va_swap_rb_mask |= 1 << location;
break;
default:
break;
}
}
struct v3d_compiled_shader *vs =
v3d_get_compiled_shader(v3d, &key->base, sizeof(*key));
if (vs != v3d->prog.vs) {

View File

@ -560,6 +560,7 @@ v3d_screen_is_format_supported(struct pipe_screen *pscreen,
case PIPE_FORMAT_R16G16B16_SSCALED:
case PIPE_FORMAT_R16G16_SSCALED:
case PIPE_FORMAT_R16_SSCALED:
case PIPE_FORMAT_B8G8R8A8_UNORM:
case PIPE_FORMAT_R8G8B8A8_UNORM:
case PIPE_FORMAT_R8G8B8_UNORM:
case PIPE_FORMAT_R8G8_UNORM: