lima: add natively supported vertex buffer formats

Add natively supported vertex buffer formats. If formats are not listed
here as natively supported, mesa triggers a buffer format translation
routine per draw call which can be expensive.
This helps improve performance in some applications.
The 32-bit integer formats were found by trial and error with a script
and checked in particular with piglit test gl-2.0-vertexattribpointer.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6714>
This commit is contained in:
Erico Nunes 2020-09-14 00:29:03 +02:00 committed by Marge Bot
parent c669db0b50
commit 12128fb135
2 changed files with 75 additions and 3 deletions

View File

@ -193,7 +193,8 @@ lima_clear(struct pipe_context *pctx, unsigned buffers, const struct pipe_scisso
enum lima_attrib_type {
LIMA_ATTRIB_FLOAT = 0x000,
/* todo: find out what lives here. */
LIMA_ATTRIB_I32 = 0x001,
LIMA_ATTRIB_U32 = 0x002,
LIMA_ATTRIB_I16 = 0x004,
LIMA_ATTRIB_U16 = 0x005,
LIMA_ATTRIB_I8 = 0x006,
@ -202,8 +203,8 @@ enum lima_attrib_type {
LIMA_ATTRIB_U8N = 0x009,
LIMA_ATTRIB_I16N = 0x00A,
LIMA_ATTRIB_U16N = 0x00B,
/* todo: where is the 32 int */
/* todo: find out what lives here. */
LIMA_ATTRIB_I32N = 0x00D,
LIMA_ATTRIB_U32N = 0x00E,
LIMA_ATTRIB_FIXED = 0x101
};
@ -232,6 +233,12 @@ lima_pipe_format_to_attrib_type(enum pipe_format format)
else
return LIMA_ATTRIB_I16;
}
else if (c->size == 32) {
if (c->normalized)
return LIMA_ATTRIB_I32N;
else
return LIMA_ATTRIB_I32;
}
break;
case UTIL_FORMAT_TYPE_UNSIGNED:
if (c->size == 8) {
@ -246,6 +253,12 @@ lima_pipe_format_to_attrib_type(enum pipe_format format)
else
return LIMA_ATTRIB_U16;
}
else if (c->size == 32) {
if (c->normalized)
return LIMA_ATTRIB_U32N;
else
return LIMA_ATTRIB_U32;
}
break;
}

View File

@ -322,7 +322,66 @@ lima_screen_is_format_supported(struct pipe_screen *pscreen,
if (usage & PIPE_BIND_VERTEX_BUFFER) {
switch (format) {
case PIPE_FORMAT_R32_FLOAT:
case PIPE_FORMAT_R32G32_FLOAT:
case PIPE_FORMAT_R32G32B32_FLOAT:
case PIPE_FORMAT_R32G32B32A32_FLOAT:
case PIPE_FORMAT_R32_FIXED:
case PIPE_FORMAT_R32G32_FIXED:
case PIPE_FORMAT_R32G32B32_FIXED:
case PIPE_FORMAT_R32G32B32A32_FIXED:
case PIPE_FORMAT_R16_FLOAT:
case PIPE_FORMAT_R16G16_FLOAT:
case PIPE_FORMAT_R16G16B16_FLOAT:
case PIPE_FORMAT_R16G16B16A16_FLOAT:
case PIPE_FORMAT_R32_UNORM:
case PIPE_FORMAT_R32G32_UNORM:
case PIPE_FORMAT_R32G32B32_UNORM:
case PIPE_FORMAT_R32G32B32A32_UNORM:
case PIPE_FORMAT_R32_SNORM:
case PIPE_FORMAT_R32G32_SNORM:
case PIPE_FORMAT_R32G32B32_SNORM:
case PIPE_FORMAT_R32G32B32A32_SNORM:
case PIPE_FORMAT_R32_USCALED:
case PIPE_FORMAT_R32G32_USCALED:
case PIPE_FORMAT_R32G32B32_USCALED:
case PIPE_FORMAT_R32G32B32A32_USCALED:
case PIPE_FORMAT_R32_SSCALED:
case PIPE_FORMAT_R32G32_SSCALED:
case PIPE_FORMAT_R32G32B32_SSCALED:
case PIPE_FORMAT_R32G32B32A32_SSCALED:
case PIPE_FORMAT_R16_UNORM:
case PIPE_FORMAT_R16G16_UNORM:
case PIPE_FORMAT_R16G16B16_UNORM:
case PIPE_FORMAT_R16G16B16A16_UNORM:
case PIPE_FORMAT_R16_SNORM:
case PIPE_FORMAT_R16G16_SNORM:
case PIPE_FORMAT_R16G16B16_SNORM:
case PIPE_FORMAT_R16G16B16A16_SNORM:
case PIPE_FORMAT_R16_USCALED:
case PIPE_FORMAT_R16G16_USCALED:
case PIPE_FORMAT_R16G16B16_USCALED:
case PIPE_FORMAT_R16G16B16A16_USCALED:
case PIPE_FORMAT_R16_SSCALED:
case PIPE_FORMAT_R16G16_SSCALED:
case PIPE_FORMAT_R16G16B16_SSCALED:
case PIPE_FORMAT_R16G16B16A16_SSCALED:
case PIPE_FORMAT_R8_UNORM:
case PIPE_FORMAT_R8G8_UNORM:
case PIPE_FORMAT_R8G8B8_UNORM:
case PIPE_FORMAT_R8G8B8A8_UNORM:
case PIPE_FORMAT_R8_SNORM:
case PIPE_FORMAT_R8G8_SNORM:
case PIPE_FORMAT_R8G8B8_SNORM:
case PIPE_FORMAT_R8G8B8A8_SNORM:
case PIPE_FORMAT_R8_USCALED:
case PIPE_FORMAT_R8G8_USCALED:
case PIPE_FORMAT_R8G8B8_USCALED:
case PIPE_FORMAT_R8G8B8A8_USCALED:
case PIPE_FORMAT_R8_SSCALED:
case PIPE_FORMAT_R8G8_SSCALED:
case PIPE_FORMAT_R8G8B8_SSCALED:
case PIPE_FORMAT_R8G8B8A8_SSCALED:
break;
default:
return false;