summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2014-06-13 11:37:23 -0400
committerRob Clark <[email protected]>2014-06-13 15:20:34 -0400
commit06e9536e5f5f0cc280385bcf813ecdcf6573401b (patch)
treefbbe53bbfb0d40ee94403c9a4960886206769489
parentba6a490bbc81380fdffcb080752682b7f38b95e6 (diff)
freedreno/a3xx: vtx formats
Add support for more vertex buffer formats. Signed-off-by: Rob Clark <[email protected]>
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_emit.c8
-rw-r--r--src/gallium/drivers/freedreno/a3xx/fd3_util.c134
2 files changed, 79 insertions, 63 deletions
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
index 4c6b5c15aaa..878d6ff6325 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_emit.c
@@ -327,9 +327,12 @@ fd3_emit_vertex_bufs(struct fd_ringbuffer *ring,
if (vp->inputs[i].compmask) {
struct pipe_resource *prsc = vbufs[i].prsc;
struct fd_resource *rsc = fd_resource(prsc);
- enum a3xx_vtx_fmt fmt = fd3_pipe2vtx(vbufs[i].format);
+ enum pipe_format pfmt = vbufs[i].format;
+ enum a3xx_vtx_fmt fmt = fd3_pipe2vtx(pfmt);
bool switchnext = (i != last);
- uint32_t fs = util_format_get_blocksize(vbufs[i].format);
+ uint32_t fs = util_format_get_blocksize(pfmt);
+
+ debug_assert(fmt != ~0);
OUT_PKT0(ring, REG_A3XX_VFD_FETCH(j), 2);
OUT_RING(ring, A3XX_VFD_FETCH_INSTR_0_FETCHSIZE(fs - 1) |
@@ -343,6 +346,7 @@ fd3_emit_vertex_bufs(struct fd_ringbuffer *ring,
OUT_RING(ring, A3XX_VFD_DECODE_INSTR_CONSTFILL |
A3XX_VFD_DECODE_INSTR_WRITEMASK(vp->inputs[i].compmask) |
A3XX_VFD_DECODE_INSTR_FORMAT(fmt) |
+ A3XX_VFD_DECODE_INSTR_SWAP(fd3_pipe2swap(pfmt)) |
A3XX_VFD_DECODE_INSTR_REGID(vp->inputs[i].regid) |
A3XX_VFD_DECODE_INSTR_SHIFTCNT(fs) |
A3XX_VFD_DECODE_INSTR_LASTCOMPVALID |
diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_util.c b/src/gallium/drivers/freedreno/a3xx/fd3_util.c
index 682b47d0836..43f30ba526d 100644
--- a/src/gallium/drivers/freedreno/a3xx/fd3_util.c
+++ b/src/gallium/drivers/freedreno/a3xx/fd3_util.c
@@ -37,70 +37,44 @@ fd3_pipe2vtx(enum pipe_format format)
{
switch (format) {
/* 8-bit buffers. */
- case PIPE_FORMAT_A8_UNORM:
- case PIPE_FORMAT_I8_UNORM:
- case PIPE_FORMAT_L8_UNORM:
case PIPE_FORMAT_R8_UNORM:
- case PIPE_FORMAT_L8_SRGB:
return VFMT_NORM_UBYTE_8;
- case PIPE_FORMAT_A8_SNORM:
- case PIPE_FORMAT_I8_SNORM:
- case PIPE_FORMAT_L8_SNORM:
case PIPE_FORMAT_R8_SNORM:
return VFMT_NORM_BYTE_8;
- case PIPE_FORMAT_A8_UINT:
- case PIPE_FORMAT_I8_UINT:
- case PIPE_FORMAT_L8_UINT:
case PIPE_FORMAT_R8_UINT:
return VFMT_UBYTE_8;
- case PIPE_FORMAT_A8_SINT:
- case PIPE_FORMAT_I8_SINT:
- case PIPE_FORMAT_L8_SINT:
case PIPE_FORMAT_R8_SINT:
return VFMT_BYTE_8;
/* 16-bit buffers. */
case PIPE_FORMAT_R16_UNORM:
- case PIPE_FORMAT_A16_UNORM:
- case PIPE_FORMAT_L16_UNORM:
- case PIPE_FORMAT_I16_UNORM:
case PIPE_FORMAT_Z16_UNORM:
return VFMT_NORM_USHORT_16;
case PIPE_FORMAT_R16_SNORM:
- case PIPE_FORMAT_A16_SNORM:
- case PIPE_FORMAT_L16_SNORM:
- case PIPE_FORMAT_I16_SNORM:
return VFMT_NORM_SHORT_16;
case PIPE_FORMAT_R16_UINT:
- case PIPE_FORMAT_A16_UINT:
- case PIPE_FORMAT_L16_UINT:
- case PIPE_FORMAT_I16_UINT:
return VFMT_USHORT_16;
case PIPE_FORMAT_R16_SINT:
- case PIPE_FORMAT_A16_SINT:
- case PIPE_FORMAT_L16_SINT:
- case PIPE_FORMAT_I16_SINT:
return VFMT_SHORT_16;
- case PIPE_FORMAT_L8A8_UNORM:
+ case PIPE_FORMAT_R16_FLOAT:
+ return VFMT_FLOAT_16;
+
case PIPE_FORMAT_R8G8_UNORM:
return VFMT_NORM_UBYTE_8_8;
- case PIPE_FORMAT_L8A8_SNORM:
case PIPE_FORMAT_R8G8_SNORM:
return VFMT_NORM_BYTE_8_8;
- case PIPE_FORMAT_L8A8_UINT:
case PIPE_FORMAT_R8G8_UINT:
return VFMT_UBYTE_8_8;
- case PIPE_FORMAT_L8A8_SINT:
case PIPE_FORMAT_R8G8_SINT:
return VFMT_BYTE_8_8;
@@ -121,42 +95,62 @@ fd3_pipe2vtx(enum pipe_format format)
case PIPE_FORMAT_A8B8G8R8_UNORM:
case PIPE_FORMAT_A8R8G8B8_UNORM:
case PIPE_FORMAT_B8G8R8A8_UNORM:
- case PIPE_FORMAT_B8G8R8X8_UNORM:
case PIPE_FORMAT_R8G8B8A8_UNORM:
- case PIPE_FORMAT_R8G8B8X8_UNORM:
- case PIPE_FORMAT_X8B8G8R8_UNORM:
- case PIPE_FORMAT_X8R8G8B8_UNORM:
- case PIPE_FORMAT_A8B8G8R8_SRGB:
- case PIPE_FORMAT_B8G8R8A8_SRGB:
return VFMT_NORM_UBYTE_8_8_8_8;
case PIPE_FORMAT_R8G8B8A8_SNORM:
- case PIPE_FORMAT_R8G8B8X8_SNORM:
return VFMT_NORM_BYTE_8_8_8_8;
case PIPE_FORMAT_R8G8B8A8_UINT:
- case PIPE_FORMAT_R8G8B8X8_UINT:
return VFMT_UBYTE_8_8_8_8;
case PIPE_FORMAT_R8G8B8A8_SINT:
- case PIPE_FORMAT_R8G8B8X8_SINT:
return VFMT_BYTE_8_8_8_8;
-/* TODO probably need gles3 blob drivers to find the 32bit int formats:
- case PIPE_FORMAT_R32_UINT:
- case PIPE_FORMAT_R32_SINT:
- case PIPE_FORMAT_A32_UINT:
- case PIPE_FORMAT_A32_SINT:
- case PIPE_FORMAT_L32_UINT:
- case PIPE_FORMAT_L32_SINT:
- case PIPE_FORMAT_I32_UINT:
- case PIPE_FORMAT_I32_SINT:
-*/
+ case PIPE_FORMAT_R16G16_SSCALED:
+ return VFMT_SHORT_16_16;
+
+ case PIPE_FORMAT_R16G16_FLOAT:
+ return VFMT_FLOAT_16_16;
+
+ case PIPE_FORMAT_R16G16_UINT:
+ return VFMT_USHORT_16_16;
+
+ case PIPE_FORMAT_R16G16_UNORM:
+ return VFMT_NORM_USHORT_16_16;
+
+ case PIPE_FORMAT_R16G16_SNORM:
+ return VFMT_NORM_SHORT_16_16;
+
+ case PIPE_FORMAT_R10G10B10A2_UNORM:
+ return VFMT_NORM_UINT_10_10_10_2;
+
+ case PIPE_FORMAT_R10G10B10A2_SNORM:
+ return VFMT_NORM_INT_10_10_10_2;
+
+ case PIPE_FORMAT_R10G10B10A2_USCALED:
+ return VFMT_UINT_10_10_10_2;
+
+ case PIPE_FORMAT_R10G10B10A2_SSCALED:
+ return VFMT_INT_10_10_10_2;
+
+ /* 48-bit buffers. */
+ case PIPE_FORMAT_R16G16B16_FLOAT:
+ return VFMT_FLOAT_16_16_16;
+
+ case PIPE_FORMAT_R16G16B16_SSCALED:
+ return VFMT_SHORT_16_16_16;
+
+ case PIPE_FORMAT_R16G16B16_UINT:
+ return VFMT_USHORT_16_16_16;
+
+ case PIPE_FORMAT_R16G16B16_SNORM:
+ return VFMT_NORM_SHORT_16_16_16;
+
+ case PIPE_FORMAT_R16G16B16_UNORM:
+ return VFMT_NORM_USHORT_16_16_16;
case PIPE_FORMAT_R32_FLOAT:
- case PIPE_FORMAT_A32_FLOAT:
- case PIPE_FORMAT_L32_FLOAT:
- case PIPE_FORMAT_I32_FLOAT:
case PIPE_FORMAT_Z32_FLOAT:
return VFMT_FLOAT_32;
@@ -177,23 +171,14 @@ fd3_pipe2vtx(enum pipe_format format)
return VFMT_SHORT_16_16_16_16;
case PIPE_FORMAT_R32G32_FLOAT:
- case PIPE_FORMAT_L32A32_FLOAT:
return VFMT_FLOAT_32_32;
case PIPE_FORMAT_R32G32_FIXED:
return VFMT_FIXED_32_32;
case PIPE_FORMAT_R16G16B16A16_FLOAT:
- case PIPE_FORMAT_R16G16B16X16_FLOAT:
return VFMT_FLOAT_16_16_16_16;
-/* TODO probably need gles3 blob drivers to find the 32bit int formats:
- case PIPE_FORMAT_R32G32_SINT:
- case PIPE_FORMAT_R32G32_UINT:
- case PIPE_FORMAT_L32A32_UINT:
- case PIPE_FORMAT_L32A32_SINT:
-*/
-
/* 96-bit buffers. */
case PIPE_FORMAT_R32G32B32_FLOAT:
return VFMT_FLOAT_32_32_32;
@@ -203,7 +188,6 @@ fd3_pipe2vtx(enum pipe_format format)
/* 128-bit buffers. */
case PIPE_FORMAT_R32G32B32A32_FLOAT:
- case PIPE_FORMAT_R32G32B32X32_FLOAT:
return VFMT_FLOAT_32_32_32_32;
case PIPE_FORMAT_R32G32B32A32_FIXED:
@@ -214,6 +198,20 @@ fd3_pipe2vtx(enum pipe_format format)
case PIPE_FORMAT_R32G32B32A32_UNORM:
case PIPE_FORMAT_R32G32B32A32_SINT:
case PIPE_FORMAT_R32G32B32A32_UINT:
+
+ case PIPE_FORMAT_R32_UINT:
+ case PIPE_FORMAT_R32_SINT:
+ case PIPE_FORMAT_A32_UINT:
+ case PIPE_FORMAT_A32_SINT:
+ case PIPE_FORMAT_L32_UINT:
+ case PIPE_FORMAT_L32_SINT:
+ case PIPE_FORMAT_I32_UINT:
+ case PIPE_FORMAT_I32_SINT:
+
+ case PIPE_FORMAT_R32G32_SINT:
+ case PIPE_FORMAT_R32G32_UINT:
+ case PIPE_FORMAT_L32A32_UINT:
+ case PIPE_FORMAT_L32A32_SINT:
*/
default:
@@ -358,8 +356,22 @@ fd3_pipe2swap(enum pipe_format format)
switch (format) {
case PIPE_FORMAT_B8G8R8A8_UNORM:
case PIPE_FORMAT_B8G8R8X8_UNORM:
+ case PIPE_FORMAT_B8G8R8A8_SRGB:
+ case PIPE_FORMAT_B8G8R8X8_SRGB:
return WXYZ;
+ case PIPE_FORMAT_A8R8G8B8_UNORM:
+ case PIPE_FORMAT_X8R8G8B8_UNORM:
+ case PIPE_FORMAT_A8R8G8B8_SRGB:
+ case PIPE_FORMAT_X8R8G8B8_SRGB:
+ return ZYXW;
+
+ case PIPE_FORMAT_A8B8G8R8_UNORM:
+ case PIPE_FORMAT_X8B8G8R8_UNORM:
+ case PIPE_FORMAT_A8B8G8R8_SRGB:
+ case PIPE_FORMAT_X8B8G8R8_SRGB:
+ return XYZW;
+
case PIPE_FORMAT_R8G8B8A8_UNORM:
case PIPE_FORMAT_R8G8B8X8_UNORM:
case PIPE_FORMAT_Z24X8_UNORM: