#define VIRGL_ENCODE_MAX_DWORDS MIN2(VIRGL_MAX_CMDBUF_DWORDS, VIRGL_CMD0_MAX_DWORDS)
+#define CONV_FORMAT(f) [PIPE_FORMAT_##f] = VIRGL_FORMAT_##f,
+
+static const enum virgl_formats virgl_formats_conv_table[PIPE_FORMAT_COUNT] = {
+ CONV_FORMAT(B8G8R8A8_UNORM)
+ CONV_FORMAT(B8G8R8X8_UNORM)
+ CONV_FORMAT(A8R8G8B8_UNORM)
+ CONV_FORMAT(X8R8G8B8_UNORM)
+ CONV_FORMAT(B5G5R5A1_UNORM)
+ CONV_FORMAT(B4G4R4A4_UNORM)
+ CONV_FORMAT(B5G6R5_UNORM)
+ CONV_FORMAT(R10G10B10A2_UNORM)
+ CONV_FORMAT(L8_UNORM)
+ CONV_FORMAT(A8_UNORM)
+ CONV_FORMAT(L8A8_UNORM)
+ CONV_FORMAT(L16_UNORM)
+ CONV_FORMAT(Z16_UNORM)
+ CONV_FORMAT(Z32_UNORM)
+ CONV_FORMAT(Z32_FLOAT)
+ CONV_FORMAT(Z24_UNORM_S8_UINT)
+ CONV_FORMAT(S8_UINT_Z24_UNORM)
+ CONV_FORMAT(Z24X8_UNORM)
+ CONV_FORMAT(X8Z24_UNORM)
+ CONV_FORMAT(S8_UINT)
+ CONV_FORMAT(R64_FLOAT)
+ CONV_FORMAT(R64G64_FLOAT)
+ CONV_FORMAT(R64G64B64_FLOAT)
+ CONV_FORMAT(R64G64B64A64_FLOAT)
+ CONV_FORMAT(R32_FLOAT)
+ CONV_FORMAT(R32G32_FLOAT)
+ CONV_FORMAT(R32G32B32_FLOAT)
+ CONV_FORMAT(R32G32B32A32_FLOAT)
+ CONV_FORMAT(R32_UNORM)
+ CONV_FORMAT(R32G32_UNORM)
+ CONV_FORMAT(R32G32B32_UNORM)
+ CONV_FORMAT(R32G32B32A32_UNORM)
+ CONV_FORMAT(R32_USCALED)
+ CONV_FORMAT(R32G32_USCALED)
+ CONV_FORMAT(R32G32B32_USCALED)
+ CONV_FORMAT(R32G32B32A32_USCALED)
+ CONV_FORMAT(R32_SNORM)
+ CONV_FORMAT(R32G32_SNORM)
+ CONV_FORMAT(R32G32B32_SNORM)
+ CONV_FORMAT(R32G32B32A32_SNORM)
+ CONV_FORMAT(R32_SSCALED)
+ CONV_FORMAT(R32G32_SSCALED)
+ CONV_FORMAT(R32G32B32_SSCALED)
+ CONV_FORMAT(R32G32B32A32_SSCALED)
+ CONV_FORMAT(R16_UNORM)
+ CONV_FORMAT(R16G16_UNORM)
+ CONV_FORMAT(R16G16B16_UNORM)
+ CONV_FORMAT(R16G16B16A16_UNORM)
+ CONV_FORMAT(R16_USCALED)
+ CONV_FORMAT(R16G16_USCALED)
+ CONV_FORMAT(R16G16B16_USCALED)
+ CONV_FORMAT(R16G16B16A16_USCALED)
+ CONV_FORMAT(R16_SNORM)
+ CONV_FORMAT(R16G16_SNORM)
+ CONV_FORMAT(R16G16B16_SNORM)
+ CONV_FORMAT(R16G16B16A16_SNORM)
+ CONV_FORMAT(R16_SSCALED)
+ CONV_FORMAT(R16G16_SSCALED)
+ CONV_FORMAT(R16G16B16_SSCALED)
+ CONV_FORMAT(R16G16B16A16_SSCALED)
+ CONV_FORMAT(R8_UNORM)
+ CONV_FORMAT(R8G8_UNORM)
+ CONV_FORMAT(R8G8B8_UNORM)
+ CONV_FORMAT(R8G8B8A8_UNORM)
+ CONV_FORMAT(R8_USCALED)
+ CONV_FORMAT(R8G8_USCALED)
+ CONV_FORMAT(R8G8B8_USCALED)
+ CONV_FORMAT(R8G8B8A8_USCALED)
+ CONV_FORMAT(R8_SNORM)
+ CONV_FORMAT(R8G8_SNORM)
+ CONV_FORMAT(R8G8B8_SNORM)
+ CONV_FORMAT(R8G8B8A8_SNORM)
+ CONV_FORMAT(R8_SSCALED)
+ CONV_FORMAT(R8G8_SSCALED)
+ CONV_FORMAT(R8G8B8_SSCALED)
+ CONV_FORMAT(R8G8B8A8_SSCALED)
+ CONV_FORMAT(R16_FLOAT)
+ CONV_FORMAT(R16G16_FLOAT)
+ CONV_FORMAT(R16G16B16_FLOAT)
+ CONV_FORMAT(R16G16B16A16_FLOAT)
+ CONV_FORMAT(L8_SRGB)
+ CONV_FORMAT(L8A8_SRGB)
+ CONV_FORMAT(R8G8B8_SRGB)
+ CONV_FORMAT(A8B8G8R8_SRGB)
+ CONV_FORMAT(X8B8G8R8_SRGB)
+ CONV_FORMAT(B8G8R8A8_SRGB)
+ CONV_FORMAT(B8G8R8X8_SRGB)
+ CONV_FORMAT(A8R8G8B8_SRGB)
+ CONV_FORMAT(X8R8G8B8_SRGB)
+ CONV_FORMAT(R8G8B8A8_SRGB)
+ CONV_FORMAT(DXT1_RGB)
+ CONV_FORMAT(DXT1_RGBA)
+ CONV_FORMAT(DXT3_RGBA)
+ CONV_FORMAT(DXT5_RGBA)
+ CONV_FORMAT(DXT1_SRGB)
+ CONV_FORMAT(DXT1_SRGBA)
+ CONV_FORMAT(DXT3_SRGBA)
+ CONV_FORMAT(DXT5_SRGBA)
+ CONV_FORMAT(RGTC1_UNORM)
+ CONV_FORMAT(RGTC1_SNORM)
+ CONV_FORMAT(RGTC2_UNORM)
+ CONV_FORMAT(RGTC2_SNORM)
+ CONV_FORMAT(A8B8G8R8_UNORM)
+ CONV_FORMAT(B5G5R5X1_UNORM)
+ CONV_FORMAT(R10G10B10A2_USCALED)
+ CONV_FORMAT(R11G11B10_FLOAT)
+ CONV_FORMAT(R9G9B9E5_FLOAT)
+ CONV_FORMAT(Z32_FLOAT_S8X24_UINT)
+ CONV_FORMAT(B10G10R10A2_UNORM)
+ CONV_FORMAT(R8G8B8X8_UNORM)
+ CONV_FORMAT(B4G4R4X4_UNORM)
+ CONV_FORMAT(X24S8_UINT)
+ CONV_FORMAT(S8X24_UINT)
+ CONV_FORMAT(X32_S8X24_UINT)
+ CONV_FORMAT(B2G3R3_UNORM)
+ CONV_FORMAT(L16A16_UNORM)
+ CONV_FORMAT(A16_UNORM)
+ CONV_FORMAT(I16_UNORM)
+ CONV_FORMAT(LATC1_UNORM)
+ CONV_FORMAT(LATC1_SNORM)
+ CONV_FORMAT(LATC2_UNORM)
+ CONV_FORMAT(LATC2_SNORM)
+ CONV_FORMAT(A8_SNORM)
+ CONV_FORMAT(L8_SNORM)
+ CONV_FORMAT(L8A8_SNORM)
+ CONV_FORMAT(A16_SNORM)
+ CONV_FORMAT(L16_SNORM)
+ CONV_FORMAT(L16A16_SNORM)
+ CONV_FORMAT(A16_FLOAT)
+ CONV_FORMAT(L16_FLOAT)
+ CONV_FORMAT(L16A16_FLOAT)
+ CONV_FORMAT(A32_FLOAT)
+ CONV_FORMAT(L32_FLOAT)
+ CONV_FORMAT(L32A32_FLOAT)
+ CONV_FORMAT(YV12)
+ CONV_FORMAT(YV16)
+ CONV_FORMAT(IYUV)
+ CONV_FORMAT(NV12)
+ CONV_FORMAT(NV21)
+ CONV_FORMAT(R8_UINT)
+ CONV_FORMAT(R8G8_UINT)
+ CONV_FORMAT(R8G8B8_UINT)
+ CONV_FORMAT(R8G8B8A8_UINT)
+ CONV_FORMAT(R8_SINT)
+ CONV_FORMAT(R8G8_SINT)
+ CONV_FORMAT(R8G8B8_SINT)
+ CONV_FORMAT(R8G8B8A8_SINT)
+ CONV_FORMAT(R16_UINT)
+ CONV_FORMAT(R16G16_UINT)
+ CONV_FORMAT(R16G16B16_UINT)
+ CONV_FORMAT(R16G16B16A16_UINT)
+ CONV_FORMAT(R16_SINT)
+ CONV_FORMAT(R16G16_SINT)
+ CONV_FORMAT(R16G16B16_SINT)
+ CONV_FORMAT(R16G16B16A16_SINT)
+ CONV_FORMAT(R32_UINT)
+ CONV_FORMAT(R32G32_UINT)
+ CONV_FORMAT(R32G32B32_UINT)
+ CONV_FORMAT(R32G32B32A32_UINT)
+ CONV_FORMAT(R32_SINT)
+ CONV_FORMAT(R32G32_SINT)
+ CONV_FORMAT(R32G32B32_SINT)
+ CONV_FORMAT(R32G32B32A32_SINT)
+ CONV_FORMAT(A8_UINT)
+ CONV_FORMAT(L8_UINT)
+ CONV_FORMAT(L8A8_UINT)
+ CONV_FORMAT(A8_SINT)
+ CONV_FORMAT(L8_SINT)
+ CONV_FORMAT(L8A8_SINT)
+ CONV_FORMAT(A16_UINT)
+ CONV_FORMAT(L16_UINT)
+ CONV_FORMAT(L16A16_UINT)
+ CONV_FORMAT(A16_SINT)
+ CONV_FORMAT(L16_SINT)
+ CONV_FORMAT(L16A16_SINT)
+ CONV_FORMAT(A32_UINT)
+ CONV_FORMAT(L32_UINT)
+ CONV_FORMAT(L32A32_UINT)
+ CONV_FORMAT(A32_SINT)
+ CONV_FORMAT(L32_SINT)
+ CONV_FORMAT(L32A32_SINT)
+ CONV_FORMAT(R10G10B10A2_SSCALED)
+ CONV_FORMAT(R10G10B10A2_SNORM)
+ CONV_FORMAT(B10G10R10A2_SNORM)
+ CONV_FORMAT(B10G10R10A2_UINT)
+ CONV_FORMAT(R8G8B8X8_SNORM)
+ CONV_FORMAT(R8G8B8X8_SRGB)
+ CONV_FORMAT(R8G8B8X8_UINT)
+ CONV_FORMAT(R8G8B8X8_SINT)
+ CONV_FORMAT(B10G10R10X2_UNORM)
+ CONV_FORMAT(R16G16B16X16_UNORM)
+ CONV_FORMAT(R16G16B16X16_SNORM)
+ CONV_FORMAT(R16G16B16X16_FLOAT)
+ CONV_FORMAT(R16G16B16X16_UINT)
+ CONV_FORMAT(R16G16B16X16_SINT)
+ CONV_FORMAT(R32G32B32X32_FLOAT)
+ CONV_FORMAT(R32G32B32X32_UINT)
+ CONV_FORMAT(R32G32B32X32_SINT)
+ CONV_FORMAT(R10G10B10A2_UINT)
+ CONV_FORMAT(BPTC_RGBA_UNORM)
+ CONV_FORMAT(BPTC_SRGBA)
+ CONV_FORMAT(BPTC_RGB_FLOAT)
+ CONV_FORMAT(BPTC_RGB_UFLOAT)
+ CONV_FORMAT(R10G10B10X2_UNORM)
+ CONV_FORMAT(A4B4G4R4_UNORM)
+ CONV_FORMAT(R8_SRGB)
+};
+
+enum virgl_formats pipe_to_virgl_format(enum pipe_format format)
+{
+ enum virgl_formats vformat = virgl_formats_conv_table[format];
+ if (format != PIPE_FORMAT_NONE && !vformat)
+ debug_printf("VIRGL: pipe format %s not in the format table\n", util_format_name(format));
+ return vformat;
+}
+
static int virgl_encoder_write_cmd_dword(struct virgl_context *ctx,
uint32_t dword)
{
virgl_encoder_write_dword(ctx->cbuf, element[i].src_offset);
virgl_encoder_write_dword(ctx->cbuf, element[i].instance_divisor);
virgl_encoder_write_dword(ctx->cbuf, element[i].vertex_buffer_index);
- virgl_encoder_write_dword(ctx->cbuf, element[i].src_format);
+ virgl_encoder_write_dword(ctx->cbuf, pipe_to_virgl_format(element[i].src_format));
}
return 0;
}
virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_CREATE_OBJECT, VIRGL_OBJECT_SURFACE, VIRGL_OBJ_SURFACE_SIZE));
virgl_encoder_write_dword(ctx->cbuf, handle);
virgl_encoder_write_res(ctx, res);
- virgl_encoder_write_dword(ctx->cbuf, templat->format);
+ virgl_encoder_write_dword(ctx->cbuf, pipe_to_virgl_format(templat->format));
assert(templat->texture->target != PIPE_BUFFER);
virgl_encoder_write_dword(ctx->cbuf, templat->u.tex.level);
unsigned elem_size = util_format_get_blocksize(state->format);
struct virgl_screen *rs = virgl_screen(ctx->base.screen);
uint32_t tmp;
- uint32_t dword_fmt_target = state->format;
+ uint32_t dword_fmt_target = pipe_to_virgl_format(state->format);
virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_CREATE_OBJECT, VIRGL_OBJECT_SAMPLER_VIEW, VIRGL_OBJ_SAMPLER_VIEW_SIZE));
virgl_encoder_write_dword(ctx->cbuf, handle);
virgl_encoder_write_res(ctx, res);
virgl_encoder_write_res(ctx, dst_res);
virgl_encoder_write_dword(ctx->cbuf, blit->dst.level);
- virgl_encoder_write_dword(ctx->cbuf, blit->dst.format);
+ virgl_encoder_write_dword(ctx->cbuf, pipe_to_virgl_format(blit->dst.format));
virgl_encoder_write_dword(ctx->cbuf, blit->dst.box.x);
virgl_encoder_write_dword(ctx->cbuf, blit->dst.box.y);
virgl_encoder_write_dword(ctx->cbuf, blit->dst.box.z);
virgl_encoder_write_res(ctx, src_res);
virgl_encoder_write_dword(ctx->cbuf, blit->src.level);
- virgl_encoder_write_dword(ctx->cbuf, blit->src.format);
+ virgl_encoder_write_dword(ctx->cbuf, pipe_to_virgl_format(blit->src.format));
virgl_encoder_write_dword(ctx->cbuf, blit->src.box.x);
virgl_encoder_write_dword(ctx->cbuf, blit->src.box.y);
virgl_encoder_write_dword(ctx->cbuf, blit->src.box.z);
for (i = 0; i < count; i++) {
if (images && images[i].resource) {
struct virgl_resource *res = virgl_resource(images[i].resource);
- virgl_encoder_write_dword(ctx->cbuf, images[i].format);
+ virgl_encoder_write_dword(ctx->cbuf, pipe_to_virgl_format(images[i].format));
virgl_encoder_write_dword(ctx->cbuf, images[i].access);
virgl_encoder_write_dword(ctx->cbuf, images[i].u.buf.offset);
virgl_encoder_write_dword(ctx->cbuf, images[i].u.buf.size);
VIRGL_FORMAT_Z24_UNORM_S8_UINT = 19,
VIRGL_FORMAT_S8_UINT_Z24_UNORM = 20,
VIRGL_FORMAT_Z24X8_UNORM = 21,
+ VIRGL_FORMAT_X8Z24_UNORM = 22,
VIRGL_FORMAT_S8_UINT = 23, /**< ubyte stencil */
-
+ VIRGL_FORMAT_R64_FLOAT = 24,
+ VIRGL_FORMAT_R64G64_FLOAT = 25,
+ VIRGL_FORMAT_R64G64B64_FLOAT = 26,
+ VIRGL_FORMAT_R64G64B64A64_FLOAT = 27,
VIRGL_FORMAT_R32_FLOAT = 28,
VIRGL_FORMAT_R32G32_FLOAT = 29,
VIRGL_FORMAT_R32G32B32_FLOAT = 30,
VIRGL_FORMAT_R32G32B32A32_FLOAT = 31,
+ VIRGL_FORMAT_R32_UNORM = 32,
+ VIRGL_FORMAT_R32G32_UNORM = 33,
+ VIRGL_FORMAT_R32G32B32_UNORM = 34,
+ VIRGL_FORMAT_R32G32B32A32_UNORM = 35,
+ VIRGL_FORMAT_R32_USCALED = 36,
+ VIRGL_FORMAT_R32G32_USCALED = 37,
+ VIRGL_FORMAT_R32G32B32_USCALED = 38,
+ VIRGL_FORMAT_R32G32B32A32_USCALED = 39,
+ VIRGL_FORMAT_R32_SNORM = 40,
+ VIRGL_FORMAT_R32G32_SNORM = 41,
+ VIRGL_FORMAT_R32G32B32_SNORM = 42,
+ VIRGL_FORMAT_R32G32B32A32_SNORM = 43,
+ VIRGL_FORMAT_R32_SSCALED = 44,
+ VIRGL_FORMAT_R32G32_SSCALED = 45,
+ VIRGL_FORMAT_R32G32B32_SSCALED = 46,
+ VIRGL_FORMAT_R32G32B32A32_SSCALED = 47,
+
VIRGL_FORMAT_R16_UNORM = 48,
VIRGL_FORMAT_R16G16_UNORM = 49,
-
+ VIRGL_FORMAT_R16G16B16_UNORM = 50,
VIRGL_FORMAT_R16G16B16A16_UNORM = 51,
+ VIRGL_FORMAT_R16_USCALED = 52,
+ VIRGL_FORMAT_R16G16_USCALED = 53,
+ VIRGL_FORMAT_R16G16B16_USCALED = 54,
+ VIRGL_FORMAT_R16G16B16A16_USCALED = 55,
+
VIRGL_FORMAT_R16_SNORM = 56,
VIRGL_FORMAT_R16G16_SNORM = 57,
+ VIRGL_FORMAT_R16G16B16_SNORM = 58,
VIRGL_FORMAT_R16G16B16A16_SNORM = 59,
+ VIRGL_FORMAT_R16_SSCALED = 60,
+ VIRGL_FORMAT_R16G16_SSCALED = 61,
+ VIRGL_FORMAT_R16G16B16_SSCALED = 62,
+ VIRGL_FORMAT_R16G16B16A16_SSCALED = 63,
+
VIRGL_FORMAT_R8_UNORM = 64,
VIRGL_FORMAT_R8G8_UNORM = 65,
-
+ VIRGL_FORMAT_R8G8B8_UNORM = 66,
VIRGL_FORMAT_R8G8B8A8_UNORM = 67,
+ VIRGL_FORMAT_R8_USCALED = 69,
+ VIRGL_FORMAT_R8G8_USCALED = 70,
+ VIRGL_FORMAT_R8G8B8_USCALED = 71,
+ VIRGL_FORMAT_R8G8B8A8_USCALED = 72,
+
VIRGL_FORMAT_R8_SNORM = 74,
VIRGL_FORMAT_R8G8_SNORM = 75,
VIRGL_FORMAT_R8G8B8_SNORM = 76,
VIRGL_FORMAT_R8G8B8A8_SNORM = 77,
+ VIRGL_FORMAT_R8_SSCALED = 82,
+ VIRGL_FORMAT_R8G8_SSCALED = 83,
+ VIRGL_FORMAT_R8G8B8_SSCALED = 84,
+ VIRGL_FORMAT_R8G8B8A8_SSCALED = 85,
+
VIRGL_FORMAT_R16_FLOAT = 91,
VIRGL_FORMAT_R16G16_FLOAT = 92,
VIRGL_FORMAT_R16G16B16_FLOAT = 93,
VIRGL_FORMAT_L8_SRGB = 95,
VIRGL_FORMAT_L8A8_SRGB = 96,
+ VIRGL_FORMAT_R8G8B8_SRGB = 97,
+ VIRGL_FORMAT_A8B8G8R8_SRGB = 98,
+ VIRGL_FORMAT_X8B8G8R8_SRGB = 99,
VIRGL_FORMAT_B8G8R8A8_SRGB = 100,
VIRGL_FORMAT_B8G8R8X8_SRGB = 101,
+ VIRGL_FORMAT_A8R8G8B8_SRGB = 102,
+ VIRGL_FORMAT_X8R8G8B8_SRGB = 103,
VIRGL_FORMAT_R8G8B8A8_SRGB = 104,
/* compressed formats */
VIRGL_FORMAT_A8B8G8R8_UNORM = 121,
VIRGL_FORMAT_B5G5R5X1_UNORM = 122,
+ VIRGL_FORMAT_R10G10B10A2_USCALED = 123,
VIRGL_FORMAT_R11G11B10_FLOAT = 124,
VIRGL_FORMAT_R9G9B9E5_FLOAT = 125,
VIRGL_FORMAT_Z32_FLOAT_S8X24_UINT = 126,
VIRGL_FORMAT_B4G4R4X4_UNORM = 135,
VIRGL_FORMAT_X24S8_UINT = 136,
VIRGL_FORMAT_S8X24_UINT = 137,
+ VIRGL_FORMAT_X32_S8X24_UINT = 138,
VIRGL_FORMAT_B2G3R3_UNORM = 139,
VIRGL_FORMAT_L16A16_UNORM = 140,
VIRGL_FORMAT_A16_UNORM = 141,
+ VIRGL_FORMAT_I16_UNORM = 142,
+
+ VIRGL_FORMAT_LATC1_UNORM = 143,
+ VIRGL_FORMAT_LATC1_SNORM = 144,
+ VIRGL_FORMAT_LATC2_UNORM = 145,
+ VIRGL_FORMAT_LATC2_SNORM = 146,
VIRGL_FORMAT_A8_SNORM = 147,
VIRGL_FORMAT_L8_SNORM = 148,
VIRGL_FORMAT_NV12 = 166,
VIRGL_FORMAT_NV21 = 167,
+ VIRGL_FORMAT_R10G10B10A2_SSCALED = 172,
+ VIRGL_FORMAT_R10G10B10A2_SNORM = 173,
+ VIRGL_FORMAT_B10G10R10A2_SNORM = 176,
+
VIRGL_FORMAT_R8_UINT = 177,
VIRGL_FORMAT_R8G8_UINT = 178,
VIRGL_FORMAT_R8G8B8_UINT = 179,
VIRGL_FORMAT_R16G16B16X16_FLOAT = 236,
VIRGL_FORMAT_R16G16B16X16_UINT = 237,
VIRGL_FORMAT_R16G16B16X16_SINT = 238,
+ VIRGL_FORMAT_R32G32B32X32_FLOAT = 239,
+ VIRGL_FORMAT_R32G32B32X32_UINT = 240,
+ VIRGL_FORMAT_R32G32B32X32_SINT = 241,
VIRGL_FORMAT_R10G10B10A2_UINT = 253,