static void demo_prepare_depth(struct demo *demo)
{
- const XGL_FORMAT depth_format = { XGL_CH_FMT_R16, XGL_NUM_FMT_DS };
+ const XGL_FORMAT depth_format = XGL_FMT_D16_UNORM;
const XGL_IMAGE_CREATE_INFO image = {
.sType = XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.pNext = NULL,
static void demo_prepare_textures(struct demo *demo)
{
- const XGL_FORMAT tex_format = { XGL_CH_FMT_R8G8B8A8, XGL_NUM_FMT_UNORM };
+ const XGL_FORMAT tex_format = XGL_FMT_R8G8B8A8_UNORM;
XGL_INT tex_width;
XGL_INT tex_height;
XGL_RESULT err;
demo->width = 500;
demo->height = 500;
- demo->format.channelFormat = XGL_CH_FMT_B8G8R8A8;
- demo->format.numericFormat = XGL_NUM_FMT_UNORM;
+ demo->format = XGL_FMT_B8G8R8A8_UNORM;
demo->spin_angle = 0.01f;
demo->spin_increment = 0.01f;
static void demo_prepare_depth(struct demo *demo)
{
- const XGL_FORMAT depth_format = { XGL_CH_FMT_R16, XGL_NUM_FMT_DS };
+ const XGL_FORMAT depth_format = XGL_FMT_D16_UNORM;
const XGL_IMAGE_CREATE_INFO image = {
.sType = XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.pNext = NULL,
static void demo_prepare_textures(struct demo *demo)
{
- const XGL_FORMAT tex_format = { XGL_CH_FMT_B8G8R8A8, XGL_NUM_FMT_UNORM };
+ const XGL_FORMAT tex_format = XGL_FMT_B8G8R8A8_UNORM;
const XGL_INT tex_width = 2;
const XGL_INT tex_height = 2;
const uint32_t tex_colors[DEMO_TEXTURE_COUNT][2] = {
demo->vertices.vi_bindings[0].stepRate = XGL_VERTEX_INPUT_STEP_RATE_VERTEX;
demo->vertices.vi_attrs[0].binding = 0;
- demo->vertices.vi_attrs[0].format.channelFormat = XGL_CH_FMT_R32G32B32;
- demo->vertices.vi_attrs[0].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ demo->vertices.vi_attrs[0].format = XGL_FMT_R32G32B32_SFLOAT;
demo->vertices.vi_attrs[0].offsetInBytes = 0;
demo->vertices.vi_attrs[1].binding = 0;
- demo->vertices.vi_attrs[1].format.channelFormat = XGL_CH_FMT_R32G32;
- demo->vertices.vi_attrs[1].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ demo->vertices.vi_attrs[1].format = XGL_FMT_R32G32_SFLOAT;
demo->vertices.vi_attrs[1].offsetInBytes = sizeof(float) * 3;
}
demo->width = 300;
demo->height = 300;
- demo->format.channelFormat = XGL_CH_FMT_B8G8R8A8;
- demo->format.numericFormat = XGL_NUM_FMT_UNORM;
+ demo->format = XGL_FMT_B8G8R8A8_UNORM;
}
static void demo_cleanup(struct demo *demo)
XGL_DEVICE obj;
- XGL_FORMAT_PROPERTIES format_props[XGL_MAX_CH_FMT][XGL_MAX_NUM_FMT];
+ XGL_FORMAT_PROPERTIES format_props[XGL_NUM_FMT];
};
struct app_gpu {
}
}
-static const char *xgl_channel_format_string(XGL_CHANNEL_FORMAT ch)
+static const char *xgl_format_string(XGL_FORMAT fmt)
{
- switch (ch) {
-#define STR(r) case XGL_CH_FMT_ ##r: return #r
+ switch (fmt) {
+#define STR(r) case XGL_FMT_ ##r: return #r
STR(UNDEFINED);
- STR(R4G4);
- STR(R4G4B4A4);
- STR(R5G6B5);
- STR(B5G6R5);
- STR(R5G5B5A1);
- STR(R8);
- STR(R8G8);
- STR(R8G8B8A8);
- STR(B8G8R8A8);
- STR(R10G11B11);
- STR(R11G11B10);
- STR(R10G10B10A2);
- STR(R16);
- STR(R16G16);
- STR(R16G16B16A16);
- STR(R32);
- STR(R32G32);
- STR(R32G32B32);
- STR(R32G32B32A32);
- STR(R16G8);
- STR(R32G8);
- STR(R9G9B9E5);
- STR(BC1);
- STR(BC2);
- STR(BC3);
- STR(BC4);
- STR(BC5);
- STR(BC6U);
- STR(BC6S);
- STR(BC7);
- STR(R8G8B8);
- STR(R16G16B16);
- STR(B10G10R10A2);
- STR(R64);
- STR(R64G64);
- STR(R64G64B64);
- STR(R64G64B64A64);
+ STR(R4G4_UNORM);
+ STR(R4G4_USCALED);
+ STR(R4G4B4A4_UNORM);
+ STR(R4G4B4A4_USCALED);
+ STR(R5G6B5_UNORM);
+ STR(R5G6B5_USCALED);
+ STR(R5G5B5A1_UNORM);
+ STR(R5G5B5A1_USCALED);
+ STR(R8_UNORM);
+ STR(R8_SNORM);
+ STR(R8_USCALED);
+ STR(R8_SSCALED);
+ STR(R8_UINT);
+ STR(R8_SINT);
+ STR(R8_SRGB);
+ STR(R8G8_UNORM);
+ STR(R8G8_SNORM);
+ STR(R8G8_USCALED);
+ STR(R8G8_SSCALED);
+ STR(R8G8_UINT);
+ STR(R8G8_SINT);
+ STR(R8G8_SRGB);
+ STR(R8G8B8_UNORM);
+ STR(R8G8B8_SNORM);
+ STR(R8G8B8_USCALED);
+ STR(R8G8B8_SSCALED);
+ STR(R8G8B8_UINT);
+ STR(R8G8B8_SINT);
+ STR(R8G8B8_SRGB);
+ STR(R8G8B8A8_UNORM);
+ STR(R8G8B8A8_SNORM);
+ STR(R8G8B8A8_USCALED);
+ STR(R8G8B8A8_SSCALED);
+ STR(R8G8B8A8_UINT);
+ STR(R8G8B8A8_SINT);
+ STR(R8G8B8A8_SRGB);
+ STR(R10G10B10A2_UNORM);
+ STR(R10G10B10A2_SNORM);
+ STR(R10G10B10A2_USCALED);
+ STR(R10G10B10A2_SSCALED);
+ STR(R10G10B10A2_UINT);
+ STR(R10G10B10A2_SINT);
+ STR(R16_UNORM);
+ STR(R16_SNORM);
+ STR(R16_USCALED);
+ STR(R16_SSCALED);
+ STR(R16_UINT);
+ STR(R16_SINT);
+ STR(R16_SFLOAT);
+ STR(R16G16_UNORM);
+ STR(R16G16_SNORM);
+ STR(R16G16_USCALED);
+ STR(R16G16_SSCALED);
+ STR(R16G16_UINT);
+ STR(R16G16_SINT);
+ STR(R16G16_SFLOAT);
+ STR(R16G16B16_UNORM);
+ STR(R16G16B16_SNORM);
+ STR(R16G16B16_USCALED);
+ STR(R16G16B16_SSCALED);
+ STR(R16G16B16_UINT);
+ STR(R16G16B16_SINT);
+ STR(R16G16B16_SFLOAT);
+ STR(R16G16B16A16_UNORM);
+ STR(R16G16B16A16_SNORM);
+ STR(R16G16B16A16_USCALED);
+ STR(R16G16B16A16_SSCALED);
+ STR(R16G16B16A16_UINT);
+ STR(R16G16B16A16_SINT);
+ STR(R16G16B16A16_SFLOAT);
+ STR(R32_UINT);
+ STR(R32_SINT);
+ STR(R32_SFLOAT);
+ STR(R32G32_UINT);
+ STR(R32G32_SINT);
+ STR(R32G32_SFLOAT);
+ STR(R32G32B32_UINT);
+ STR(R32G32B32_SINT);
+ STR(R32G32B32_SFLOAT);
+ STR(R32G32B32A32_UINT);
+ STR(R32G32B32A32_SINT);
+ STR(R32G32B32A32_SFLOAT);
+ STR(R64_SFLOAT);
+ STR(R64G64_SFLOAT);
+ STR(R64G64B64_SFLOAT);
+ STR(R64G64B64A64_SFLOAT);
+ STR(R11G11B10_UFLOAT);
+ STR(R9G9B9E5_UFLOAT);
+ STR(D16_UNORM);
+ STR(D24_UNORM);
+ STR(D32_SFLOAT);
+ STR(S8_UINT);
+ STR(D16_UNORM_S8_UINT);
+ STR(D24_UNORM_S8_UINT);
+ STR(D32_SFLOAT_S8_UINT);
+ STR(BC1_UNORM);
+ STR(BC1_SRGB);
+ STR(BC2_UNORM);
+ STR(BC2_SRGB);
+ STR(BC3_UNORM);
+ STR(BC3_SRGB);
+ STR(BC4_UNORM);
+ STR(BC4_SNORM);
+ STR(BC5_UNORM);
+ STR(BC5_SNORM);
+ STR(BC6H_UFLOAT);
+ STR(BC6H_SFLOAT);
+ STR(BC7_UNORM);
+ STR(BC7_SRGB);
+ STR(ETC2_R8G8B8_UNORM);
+ STR(ETC2_R8G8B8A1_UNORM);
+ STR(ETC2_R8G8B8A8_UNORM);
+ STR(EAC_R11_UNORM);
+ STR(EAC_R11_SNORM);
+ STR(EAC_R11G11_UNORM);
+ STR(EAC_R11G11_SNORM);
+ STR(ASTC_4x4_UNORM);
+ STR(ASTC_4x4_SRGB);
+ STR(ASTC_4x5_UNORM);
+ STR(ASTC_4x5_SRGB);
+ STR(ASTC_5x5_UNORM);
+ STR(ASTC_5x5_SRGB);
+ STR(ASTC_6x5_UNORM);
+ STR(ASTC_6x5_SRGB);
+ STR(ASTC_6x6_UNORM);
+ STR(ASTC_6x6_SRGB);
+ STR(ASTC_8x5_UNORM);
+ STR(ASTC_8x5_SRGB);
+ STR(ASTC_8x6_UNORM);
+ STR(ASTC_8x6_SRGB);
+ STR(ASTC_8x8_UNORM);
+ STR(ASTC_8x8_SRGB);
+ STR(ASTC_10x5_UNORM);
+ STR(ASTC_10x5_SRGB);
+ STR(ASTC_10x6_UNORM);
+ STR(ASTC_10x6_SRGB);
+ STR(ASTC_10x8_UNORM);
+ STR(ASTC_10x8_SRGB);
+ STR(ASTC_10x10_UNORM);
+ STR(ASTC_10x10_SRGB);
+ STR(ASTC_12x10_UNORM);
+ STR(ASTC_12x10_SRGB);
+ STR(ASTC_12x12_UNORM);
+ STR(ASTC_12x12_SRGB);
+ STR(B5G6R5_UNORM);
+ STR(B5G6R5_USCALED);
+ STR(B8G8R8_UNORM);
+ STR(B8G8R8_SNORM);
+ STR(B8G8R8_USCALED);
+ STR(B8G8R8_SSCALED);
+ STR(B8G8R8_UINT);
+ STR(B8G8R8_SINT);
+ STR(B8G8R8_SRGB);
+ STR(B8G8R8A8_UNORM);
+ STR(B8G8R8A8_SNORM);
+ STR(B8G8R8A8_USCALED);
+ STR(B8G8R8A8_SSCALED);
+ STR(B8G8R8A8_UINT);
+ STR(B8G8R8A8_SINT);
+ STR(B8G8R8A8_SRGB);
+ STR(B10G10R10A2_UNORM);
+ STR(B10G10R10A2_SNORM);
+ STR(B10G10R10A2_USCALED);
+ STR(B10G10R10A2_SSCALED);
+ STR(B10G10R10A2_UINT);
+ STR(B10G10R10A2_SINT);
#undef STR
- default: return "UNKNOWN_CH";
- }
-}
-
-static const char *xgl_numeric_format_string(XGL_NUM_FORMAT num)
-{
- switch (num) {
-#define STR(r) case XGL_NUM_FMT_ ##r: return #r
- STR(UNDEFINED);
- STR(UNORM);
- STR(SNORM);
- STR(UINT);
- STR(SINT);
- STR(FLOAT);
- STR(SRGB);
- STR(DS);
- STR(USCALED);
- STR(SSCALED);
-#undef STR
- default: return "UNKNOWN_NUM";
+ default: return "UNKNOWN_FORMAT";
}
}
static void app_dev_init_formats(struct app_dev *dev)
{
- XGL_CHANNEL_FORMAT ch;
- XGL_NUM_FORMAT num;
-
- for (ch = 0; ch < XGL_MAX_CH_FMT; ch++) {
- for (num = 0; num < XGL_MAX_NUM_FMT; num++) {
- const XGL_FORMAT fmt = {
- .channelFormat = ch,
- .numericFormat = num,
- };
- XGL_RESULT err;
- XGL_SIZE size = sizeof(dev->format_props[ch][num]);
-
- err = xglGetFormatInfo(dev->obj, fmt,
- XGL_INFO_TYPE_FORMAT_PROPERTIES,
- &size, &dev->format_props[ch][num]);
- if (err) {
- memset(&dev->format_props[ch][num], 0,
- sizeof(dev->format_props[ch][num]));
- }
- else if (size != sizeof(dev->format_props[ch][num])) {
- ERR_EXIT(XGL_ERROR_UNKNOWN);
- }
+ XGL_FORMAT f;
+
+ for (f = 0; f < XGL_NUM_FMT; f++) {
+ const XGL_FORMAT fmt = f;
+ XGL_RESULT err;
+ XGL_SIZE size = sizeof(dev->format_props[f]);
+
+ err = xglGetFormatInfo(dev->obj, fmt,
+ XGL_INFO_TYPE_FORMAT_PROPERTIES,
+ &size, &dev->format_props[f]);
+ if (err) {
+ memset(&dev->format_props[f], 0,
+ sizeof(dev->format_props[f]));
+ }
+ else if (size != sizeof(dev->format_props[f])) {
+ ERR_EXIT(XGL_ERROR_UNKNOWN);
}
}
}
free(gpu->queue_props);
}
-static void app_dev_dump_format_props(const struct app_dev *dev, XGL_CHANNEL_FORMAT ch, XGL_NUM_FORMAT num)
+static void app_dev_dump_format_props(const struct app_dev *dev, XGL_FORMAT fmt)
{
- const XGL_FORMAT_PROPERTIES *props = &dev->format_props[ch][num];
+ const XGL_FORMAT_PROPERTIES *props = &dev->format_props[fmt];
struct {
const char *name;
XGL_FLAGS flags;
tilings[1].name = "optimal";
tilings[1].flags = props->optimalTilingFeatures;
- printf("FORMAT_%s_%s\n", xgl_channel_format_string(ch),
- xgl_numeric_format_string(num));
+ printf("FORMAT_%s\n", xgl_format_string(fmt));
for (i = 0; i < ARRAY_SIZE(tilings); i++) {
if (!tilings[i].flags)
continue;
static void
app_dev_dump(const struct app_dev *dev)
{
- XGL_CHANNEL_FORMAT ch;
- XGL_NUM_FORMAT num;
+ XGL_FORMAT fmt;
- for (ch = 0; ch < XGL_MAX_CH_FMT; ch++) {
- for (num = 0; num < XGL_MAX_NUM_FMT; num++)
- app_dev_dump_format_props(dev, ch, num);
+ for (fmt = 0; fmt < XGL_NUM_FMT; fmt++) {
+ app_dev_dump_format_props(dev, fmt);
}
}
static const struct icd_format_info {
XGL_SIZE size;
XGL_UINT channel_count;
-} icd_format_table[XGL_MAX_CH_FMT + 1] = {
- [XGL_CH_FMT_UNDEFINED] = { 0, 0 },
- [XGL_CH_FMT_R4G4] = { 1, 2 },
- [XGL_CH_FMT_R4G4B4A4] = { 2, 4 },
- [XGL_CH_FMT_R5G6B5] = { 2, 3 },
- [XGL_CH_FMT_B5G6R5] = { 2, 3 },
- [XGL_CH_FMT_R5G5B5A1] = { 2, 4 },
- [XGL_CH_FMT_R8] = { 1, 1 },
- [XGL_CH_FMT_R8G8] = { 2, 2 },
- [XGL_CH_FMT_R8G8B8A8] = { 4, 4 },
- [XGL_CH_FMT_B8G8R8A8] = { 4, 4 },
- [XGL_CH_FMT_R10G11B11] = { 4, 3 },
- [XGL_CH_FMT_R11G11B10] = { 4, 3 },
- [XGL_CH_FMT_R10G10B10A2] = { 4, 4 },
- [XGL_CH_FMT_R16] = { 2, 1 },
- [XGL_CH_FMT_R16G16] = { 4, 2 },
- [XGL_CH_FMT_R16G16B16A16] = { 8, 4 },
- [XGL_CH_FMT_R32] = { 4, 1 },
- [XGL_CH_FMT_R32G32] = { 8, 2 },
- [XGL_CH_FMT_R32G32B32] = { 12, 3 },
- [XGL_CH_FMT_R32G32B32A32] = { 16, 4 },
- [XGL_CH_FMT_R16G8] = { 3, 2 },
- [XGL_CH_FMT_R32G8] = { 5, 2 },
- [XGL_CH_FMT_R9G9B9E5] = { 4, 3 },
- [XGL_CH_FMT_BC1] = { 8, 4 },
- [XGL_CH_FMT_BC2] = { 16, 4 },
- [XGL_CH_FMT_BC3] = { 16, 4 },
- [XGL_CH_FMT_BC4] = { 8, 4 },
- [XGL_CH_FMT_BC5] = { 16, 4 },
- [XGL_CH_FMT_BC6U] = { 16, 4 },
- [XGL_CH_FMT_BC6S] = { 16, 4 },
- [XGL_CH_FMT_BC7] = { 16, 4 },
- [XGL_CH_FMT_R8G8B8] = { 3, 3 },
- [XGL_CH_FMT_R16G16B16] = { 6, 3 },
- [XGL_CH_FMT_B10G10R10A2] = { 4, 4 },
- [XGL_CH_FMT_R64] = { 8, 1 },
- [XGL_CH_FMT_R64G64] = { 16, 2 },
- [XGL_CH_FMT_R64G64B64] = { 24, 3 },
- [XGL_CH_FMT_R64G64B64A64] = { 32, 4 },
+} icd_format_table[XGL_NUM_FMT] = {
+ [XGL_FMT_UNDEFINED] = { 0, 0 },
+ [XGL_FMT_R4G4_UNORM] = { 1, 2 },
+ [XGL_FMT_R4G4_USCALED] = { 1, 2 },
+ [XGL_FMT_R4G4B4A4_UNORM] = { 2, 4 },
+ [XGL_FMT_R4G4B4A4_USCALED] = { 2, 4 },
+ [XGL_FMT_R5G6B5_UNORM] = { 2, 3 },
+ [XGL_FMT_R5G6B5_USCALED] = { 2, 3 },
+ [XGL_FMT_R5G5B5A1_UNORM] = { 2, 4 },
+ [XGL_FMT_R5G5B5A1_USCALED] = { 2, 4 },
+ [XGL_FMT_R8_UNORM] = { 1, 1 },
+ [XGL_FMT_R8_SNORM] = { 1, 1 },
+ [XGL_FMT_R8_USCALED] = { 1, 1 },
+ [XGL_FMT_R8_SSCALED] = { 1, 1 },
+ [XGL_FMT_R8_UINT] = { 1, 1 },
+ [XGL_FMT_R8_SINT] = { 1, 1 },
+ [XGL_FMT_R8_SRGB] = { 1, 1 },
+ [XGL_FMT_R8G8_UNORM] = { 2, 2 },
+ [XGL_FMT_R8G8_SNORM] = { 2, 2 },
+ [XGL_FMT_R8G8_USCALED] = { 2, 2 },
+ [XGL_FMT_R8G8_SSCALED] = { 2, 2 },
+ [XGL_FMT_R8G8_UINT] = { 2, 2 },
+ [XGL_FMT_R8G8_SINT] = { 2, 2 },
+ [XGL_FMT_R8G8_SRGB] = { 2, 2 },
+ [XGL_FMT_R8G8B8_UNORM] = { 3, 3 },
+ [XGL_FMT_R8G8B8_SNORM] = { 3, 3 },
+ [XGL_FMT_R8G8B8_USCALED] = { 3, 3 },
+ [XGL_FMT_R8G8B8_SSCALED] = { 3, 3 },
+ [XGL_FMT_R8G8B8_UINT] = { 3, 3 },
+ [XGL_FMT_R8G8B8_SINT] = { 3, 3 },
+ [XGL_FMT_R8G8B8_SRGB] = { 3, 3 },
+ [XGL_FMT_R8G8B8A8_UNORM] = { 4, 4 },
+ [XGL_FMT_R8G8B8A8_SNORM] = { 4, 4 },
+ [XGL_FMT_R8G8B8A8_USCALED] = { 4, 4 },
+ [XGL_FMT_R8G8B8A8_SSCALED] = { 4, 4 },
+ [XGL_FMT_R8G8B8A8_UINT] = { 4, 4 },
+ [XGL_FMT_R8G8B8A8_SINT] = { 4, 4 },
+ [XGL_FMT_R8G8B8A8_SRGB] = { 4, 4 },
+ [XGL_FMT_R10G10B10A2_UNORM] = { 4, 4 },
+ [XGL_FMT_R10G10B10A2_SNORM] = { 4, 4 },
+ [XGL_FMT_R10G10B10A2_USCALED] = { 4, 4 },
+ [XGL_FMT_R10G10B10A2_SSCALED] = { 4, 4 },
+ [XGL_FMT_R10G10B10A2_UINT] = { 4, 4 },
+ [XGL_FMT_R10G10B10A2_SINT] = { 4, 4 },
+ [XGL_FMT_R16_UNORM] = { 2, 1 },
+ [XGL_FMT_R16_SNORM] = { 2, 1 },
+ [XGL_FMT_R16_USCALED] = { 2, 1 },
+ [XGL_FMT_R16_SSCALED] = { 2, 1 },
+ [XGL_FMT_R16_UINT] = { 2, 1 },
+ [XGL_FMT_R16_SINT] = { 2, 1 },
+ [XGL_FMT_R16_SFLOAT] = { 2, 1 },
+ [XGL_FMT_R16G16_UNORM] = { 4, 2 },
+ [XGL_FMT_R16G16_SNORM] = { 4, 2 },
+ [XGL_FMT_R16G16_USCALED] = { 4, 2 },
+ [XGL_FMT_R16G16_SSCALED] = { 4, 2 },
+ [XGL_FMT_R16G16_UINT] = { 4, 2 },
+ [XGL_FMT_R16G16_SINT] = { 4, 2 },
+ [XGL_FMT_R16G16_SFLOAT] = { 4, 2 },
+ [XGL_FMT_R16G16B16_UNORM] = { 6, 3 },
+ [XGL_FMT_R16G16B16_SNORM] = { 6, 3 },
+ [XGL_FMT_R16G16B16_USCALED] = { 6, 3 },
+ [XGL_FMT_R16G16B16_SSCALED] = { 6, 3 },
+ [XGL_FMT_R16G16B16_UINT] = { 6, 3 },
+ [XGL_FMT_R16G16B16_SINT] = { 6, 3 },
+ [XGL_FMT_R16G16B16_SFLOAT] = { 6, 3 },
+ [XGL_FMT_R16G16B16A16_UNORM] = { 8, 4 },
+ [XGL_FMT_R16G16B16A16_SNORM] = { 8, 4 },
+ [XGL_FMT_R16G16B16A16_USCALED] = { 8, 4 },
+ [XGL_FMT_R16G16B16A16_SSCALED] = { 8, 4 },
+ [XGL_FMT_R16G16B16A16_UINT] = { 8, 4 },
+ [XGL_FMT_R16G16B16A16_SINT] = { 8, 4 },
+ [XGL_FMT_R16G16B16A16_SFLOAT] = { 8, 4 },
+ [XGL_FMT_R32_UINT] = { 4, 1 },
+ [XGL_FMT_R32_SINT] = { 4, 1 },
+ [XGL_FMT_R32_SFLOAT] = { 4, 1 },
+ [XGL_FMT_R32G32_UINT] = { 8, 2 },
+ [XGL_FMT_R32G32_SINT] = { 8, 2 },
+ [XGL_FMT_R32G32_SFLOAT] = { 8, 2 },
+ [XGL_FMT_R32G32B32_UINT] = { 12, 3 },
+ [XGL_FMT_R32G32B32_SINT] = { 12, 3 },
+ [XGL_FMT_R32G32B32_SFLOAT] = { 12, 3 },
+ [XGL_FMT_R32G32B32A32_UINT] = { 16, 4 },
+ [XGL_FMT_R32G32B32A32_SINT] = { 16, 4 },
+ [XGL_FMT_R32G32B32A32_SFLOAT] = { 16, 4 },
+ [XGL_FMT_R64_SFLOAT] = { 8, 1 },
+ [XGL_FMT_R64G64_SFLOAT] = { 16, 2 },
+ [XGL_FMT_R64G64B64_SFLOAT] = { 24, 3 },
+ [XGL_FMT_R64G64B64A64_SFLOAT] = { 32, 4 },
+ [XGL_FMT_R11G11B10_UFLOAT] = { 4, 3 },
+ [XGL_FMT_R9G9B9E5_UFLOAT] = { 4, 3 },
+ [XGL_FMT_D16_UNORM] = { 2, 1 },
+ [XGL_FMT_D24_UNORM] = { 3, 1 },
+ [XGL_FMT_D32_SFLOAT] = { 4, 1 },
+ [XGL_FMT_S8_UINT] = { 1, 1 },
+ [XGL_FMT_D16_UNORM_S8_UINT] = { 3, 2 },
+ [XGL_FMT_D24_UNORM_S8_UINT] = { 4, 2 },
+ [XGL_FMT_D32_SFLOAT_S8_UINT] = { 4, 2 },
+ [XGL_FMT_BC1_UNORM] = { 8, 4 },
+ [XGL_FMT_BC1_SRGB] = { 8, 4 },
+ [XGL_FMT_BC2_UNORM] = { 16, 4 },
+ [XGL_FMT_BC2_SRGB] = { 16, 4 },
+ [XGL_FMT_BC3_UNORM] = { 16, 4 },
+ [XGL_FMT_BC3_SRGB] = { 16, 4 },
+ [XGL_FMT_BC4_UNORM] = { 8, 4 },
+ [XGL_FMT_BC4_SNORM] = { 8, 4 },
+ [XGL_FMT_BC5_UNORM] = { 16, 4 },
+ [XGL_FMT_BC5_SNORM] = { 16, 4 },
+ [XGL_FMT_BC6H_UFLOAT] = { 16, 4 },
+ [XGL_FMT_BC6H_SFLOAT] = { 16, 4 },
+ [XGL_FMT_BC7_UNORM] = { 16, 4 },
+ [XGL_FMT_BC7_SRGB] = { 16, 4 },
+ /* TODO: Initialize remaining compressed formats. */
+ [XGL_FMT_ETC2_R8G8B8_UNORM] = { 0, 0 },
+ [XGL_FMT_ETC2_R8G8B8A1_UNORM] = { 0, 0 },
+ [XGL_FMT_ETC2_R8G8B8A8_UNORM] = { 0, 0 },
+ [XGL_FMT_EAC_R11_UNORM] = { 0, 0 },
+ [XGL_FMT_EAC_R11_SNORM] = { 0, 0 },
+ [XGL_FMT_EAC_R11G11_UNORM] = { 0, 0 },
+ [XGL_FMT_EAC_R11G11_SNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_4x4_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_4x4_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_4x5_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_4x5_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_5x5_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_5x5_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_6x5_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_6x5_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_6x6_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_6x6_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_8x5_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_8x5_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_8x6_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_8x6_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_8x8_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_8x8_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_10x5_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_10x5_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_10x6_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_10x6_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_10x8_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_10x8_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_10x10_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_10x10_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_12x10_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_12x10_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_12x12_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_12x12_SRGB] = { 0, 0 },
+ [XGL_FMT_B5G6R5_UNORM] = { 2, 3 },
+ [XGL_FMT_B5G6R5_USCALED] = { 2, 3 },
+ [XGL_FMT_B8G8R8_UNORM] = { 3, 3 },
+ [XGL_FMT_B8G8R8_SNORM] = { 3, 3 },
+ [XGL_FMT_B8G8R8_USCALED] = { 3, 3 },
+ [XGL_FMT_B8G8R8_SSCALED] = { 3, 3 },
+ [XGL_FMT_B8G8R8_UINT] = { 3, 3 },
+ [XGL_FMT_B8G8R8_SINT] = { 3, 3 },
+ [XGL_FMT_B8G8R8_SRGB] = { 3, 3 },
+ [XGL_FMT_B8G8R8A8_UNORM] = { 4, 4 },
+ [XGL_FMT_B8G8R8A8_SNORM] = { 4, 4 },
+ [XGL_FMT_B8G8R8A8_USCALED] = { 4, 4 },
+ [XGL_FMT_B8G8R8A8_SSCALED] = { 4, 4 },
+ [XGL_FMT_B8G8R8A8_UINT] = { 4, 4 },
+ [XGL_FMT_B8G8R8A8_SINT] = { 4, 4 },
+ [XGL_FMT_B8G8R8A8_SRGB] = { 4, 4 },
+ [XGL_FMT_B10G10R10A2_UNORM] = { 4, 4 },
+ [XGL_FMT_B10G10R10A2_SNORM] = { 4, 4 },
+ [XGL_FMT_B10G10R10A2_USCALED] = { 4, 4 },
+ [XGL_FMT_B10G10R10A2_SSCALED] = { 4, 4 },
+ [XGL_FMT_B10G10R10A2_UINT] = { 4, 4 },
+ [XGL_FMT_B10G10R10A2_SINT] = { 4, 4 },
};
+bool icd_format_is_ds(XGL_FORMAT format)
+{
+ bool is_ds = false;
+
+ switch (format) {
+ case XGL_FMT_D16_UNORM:
+ case XGL_FMT_D24_UNORM:
+ case XGL_FMT_D32_SFLOAT:
+ case XGL_FMT_S8_UINT:
+ case XGL_FMT_D16_UNORM_S8_UINT:
+ case XGL_FMT_D24_UNORM_S8_UINT:
+ case XGL_FMT_D32_SFLOAT_S8_UINT:
+ is_ds = true;
+ break;
+ default:
+ break;
+ }
+
+ return is_ds;
+}
+
+bool icd_format_is_norm(XGL_FORMAT format)
+{
+ bool is_norm = false;
+
+ switch (format) {
+ case XGL_FMT_R4G4_UNORM:
+ case XGL_FMT_R4G4B4A4_UNORM:
+ case XGL_FMT_R5G6B5_UNORM:
+ case XGL_FMT_R5G5B5A1_UNORM:
+ case XGL_FMT_R8_UNORM:
+ case XGL_FMT_R8_SNORM:
+ case XGL_FMT_R8G8_UNORM:
+ case XGL_FMT_R8G8_SNORM:
+ case XGL_FMT_R8G8B8_UNORM:
+ case XGL_FMT_R8G8B8_SNORM:
+ case XGL_FMT_R8G8B8A8_UNORM:
+ case XGL_FMT_R8G8B8A8_SNORM:
+ case XGL_FMT_R10G10B10A2_UNORM:
+ case XGL_FMT_R10G10B10A2_SNORM:
+ case XGL_FMT_R16_UNORM:
+ case XGL_FMT_R16_SNORM:
+ case XGL_FMT_R16G16_UNORM:
+ case XGL_FMT_R16G16_SNORM:
+ case XGL_FMT_R16G16B16_UNORM:
+ case XGL_FMT_R16G16B16_SNORM:
+ case XGL_FMT_R16G16B16A16_UNORM:
+ case XGL_FMT_R16G16B16A16_SNORM:
+ case XGL_FMT_BC1_UNORM:
+ case XGL_FMT_BC2_UNORM:
+ case XGL_FMT_BC3_UNORM:
+ case XGL_FMT_BC4_UNORM:
+ case XGL_FMT_BC4_SNORM:
+ case XGL_FMT_BC5_UNORM:
+ case XGL_FMT_BC5_SNORM:
+ case XGL_FMT_BC7_UNORM:
+ case XGL_FMT_ETC2_R8G8B8_UNORM:
+ case XGL_FMT_ETC2_R8G8B8A1_UNORM:
+ case XGL_FMT_ETC2_R8G8B8A8_UNORM:
+ case XGL_FMT_EAC_R11_UNORM:
+ case XGL_FMT_EAC_R11_SNORM:
+ case XGL_FMT_EAC_R11G11_UNORM:
+ case XGL_FMT_EAC_R11G11_SNORM:
+ case XGL_FMT_ASTC_4x4_UNORM:
+ case XGL_FMT_ASTC_4x5_UNORM:
+ case XGL_FMT_ASTC_5x5_UNORM:
+ case XGL_FMT_ASTC_6x5_UNORM:
+ case XGL_FMT_ASTC_6x6_UNORM:
+ case XGL_FMT_ASTC_8x5_UNORM:
+ case XGL_FMT_ASTC_8x6_UNORM:
+ case XGL_FMT_ASTC_8x8_UNORM:
+ case XGL_FMT_ASTC_10x5_UNORM:
+ case XGL_FMT_ASTC_10x6_UNORM:
+ case XGL_FMT_ASTC_10x8_UNORM:
+ case XGL_FMT_ASTC_10x10_UNORM:
+ case XGL_FMT_ASTC_12x10_UNORM:
+ case XGL_FMT_ASTC_12x12_UNORM:
+ case XGL_FMT_B5G6R5_UNORM:
+ case XGL_FMT_B8G8R8_UNORM:
+ case XGL_FMT_B8G8R8_SNORM:
+ case XGL_FMT_B8G8R8A8_UNORM:
+ case XGL_FMT_B8G8R8A8_SNORM:
+ case XGL_FMT_B10G10R10A2_UNORM:
+ case XGL_FMT_B10G10R10A2_SNORM:
+ is_norm = true;
+ break;
+ default:
+ break;
+ }
+
+ return is_norm;
+};
+
+bool icd_format_is_int(XGL_FORMAT format)
+{
+ bool is_int = false;
+
+ switch (format) {
+ case XGL_FMT_R8_UINT:
+ case XGL_FMT_R8_SINT:
+ case XGL_FMT_R8G8_UINT:
+ case XGL_FMT_R8G8_SINT:
+ case XGL_FMT_R8G8B8_UINT:
+ case XGL_FMT_R8G8B8_SINT:
+ case XGL_FMT_R8G8B8A8_UINT:
+ case XGL_FMT_R8G8B8A8_SINT:
+ case XGL_FMT_R10G10B10A2_UINT:
+ case XGL_FMT_R10G10B10A2_SINT:
+ case XGL_FMT_R16_UINT:
+ case XGL_FMT_R16_SINT:
+ case XGL_FMT_R16G16_UINT:
+ case XGL_FMT_R16G16_SINT:
+ case XGL_FMT_R16G16B16_UINT:
+ case XGL_FMT_R16G16B16_SINT:
+ case XGL_FMT_R16G16B16A16_UINT:
+ case XGL_FMT_R16G16B16A16_SINT:
+ case XGL_FMT_R32_UINT:
+ case XGL_FMT_R32_SINT:
+ case XGL_FMT_R32G32_UINT:
+ case XGL_FMT_R32G32_SINT:
+ case XGL_FMT_R32G32B32_UINT:
+ case XGL_FMT_R32G32B32_SINT:
+ case XGL_FMT_R32G32B32A32_UINT:
+ case XGL_FMT_R32G32B32A32_SINT:
+ case XGL_FMT_B8G8R8_UINT:
+ case XGL_FMT_B8G8R8_SINT:
+ case XGL_FMT_B8G8R8A8_UINT:
+ case XGL_FMT_B8G8R8A8_SINT:
+ case XGL_FMT_B10G10R10A2_UINT:
+ case XGL_FMT_B10G10R10A2_SINT:
+ is_int = true;
+ break;
+ default:
+ break;
+ }
+
+ return is_int;
+}
+
+bool icd_format_is_float(XGL_FORMAT format)
+{
+ bool is_float = false;
+
+ switch (format) {
+ case XGL_FMT_R16_SFLOAT:
+ case XGL_FMT_R16G16_SFLOAT:
+ case XGL_FMT_R16G16B16_SFLOAT:
+ case XGL_FMT_R16G16B16A16_SFLOAT:
+ case XGL_FMT_R32_SFLOAT:
+ case XGL_FMT_R32G32_SFLOAT:
+ case XGL_FMT_R32G32B32_SFLOAT:
+ case XGL_FMT_R32G32B32A32_SFLOAT:
+ case XGL_FMT_R64_SFLOAT:
+ case XGL_FMT_R64G64_SFLOAT:
+ case XGL_FMT_R64G64B64_SFLOAT:
+ case XGL_FMT_R64G64B64A64_SFLOAT:
+ case XGL_FMT_R11G11B10_UFLOAT:
+ case XGL_FMT_R9G9B9E5_UFLOAT:
+ case XGL_FMT_BC6H_UFLOAT:
+ case XGL_FMT_BC6H_SFLOAT:
+ is_float = true;
+ break;
+ default:
+ break;
+ }
+
+ return is_float;
+}
+
+bool icd_format_is_srgb(XGL_FORMAT format)
+{
+ bool is_srgb = false;
+
+ switch (format) {
+ case XGL_FMT_R8_SRGB:
+ case XGL_FMT_R8G8_SRGB:
+ case XGL_FMT_R8G8B8_SRGB:
+ case XGL_FMT_R8G8B8A8_SRGB:
+ case XGL_FMT_BC1_SRGB:
+ case XGL_FMT_BC2_SRGB:
+ case XGL_FMT_BC3_SRGB:
+ case XGL_FMT_BC7_SRGB:
+ case XGL_FMT_ASTC_4x4_SRGB:
+ case XGL_FMT_ASTC_4x5_SRGB:
+ case XGL_FMT_ASTC_5x5_SRGB:
+ case XGL_FMT_ASTC_6x5_SRGB:
+ case XGL_FMT_ASTC_6x6_SRGB:
+ case XGL_FMT_ASTC_8x5_SRGB:
+ case XGL_FMT_ASTC_8x6_SRGB:
+ case XGL_FMT_ASTC_8x8_SRGB:
+ case XGL_FMT_ASTC_10x5_SRGB:
+ case XGL_FMT_ASTC_10x6_SRGB:
+ case XGL_FMT_ASTC_10x8_SRGB:
+ case XGL_FMT_ASTC_10x10_SRGB:
+ case XGL_FMT_ASTC_12x10_SRGB:
+ case XGL_FMT_ASTC_12x12_SRGB:
+ case XGL_FMT_B8G8R8_SRGB:
+ case XGL_FMT_B8G8R8A8_SRGB:
+ is_srgb = true;
+ break;
+ default:
+ break;
+ }
+
+ return is_srgb;
+}
+
+bool icd_format_is_compressed(XGL_FORMAT format)
+{
+ switch (format) {
+ case XGL_FMT_BC1_UNORM:
+ case XGL_FMT_BC1_SRGB:
+ case XGL_FMT_BC2_UNORM:
+ case XGL_FMT_BC2_SRGB:
+ case XGL_FMT_BC3_UNORM:
+ case XGL_FMT_BC3_SRGB:
+ case XGL_FMT_BC4_UNORM:
+ case XGL_FMT_BC4_SNORM:
+ case XGL_FMT_BC5_UNORM:
+ case XGL_FMT_BC5_SNORM:
+ case XGL_FMT_BC6H_UFLOAT:
+ case XGL_FMT_BC6H_SFLOAT:
+ case XGL_FMT_BC7_UNORM:
+ case XGL_FMT_BC7_SRGB:
+ case XGL_FMT_ETC2_R8G8B8_UNORM:
+ case XGL_FMT_ETC2_R8G8B8A1_UNORM:
+ case XGL_FMT_ETC2_R8G8B8A8_UNORM:
+ case XGL_FMT_EAC_R11_UNORM:
+ case XGL_FMT_EAC_R11_SNORM:
+ case XGL_FMT_EAC_R11G11_UNORM:
+ case XGL_FMT_EAC_R11G11_SNORM:
+ case XGL_FMT_ASTC_4x4_UNORM:
+ case XGL_FMT_ASTC_4x4_SRGB:
+ case XGL_FMT_ASTC_4x5_UNORM:
+ case XGL_FMT_ASTC_4x5_SRGB:
+ case XGL_FMT_ASTC_5x5_UNORM:
+ case XGL_FMT_ASTC_5x5_SRGB:
+ case XGL_FMT_ASTC_6x5_UNORM:
+ case XGL_FMT_ASTC_6x5_SRGB:
+ case XGL_FMT_ASTC_6x6_UNORM:
+ case XGL_FMT_ASTC_6x6_SRGB:
+ case XGL_FMT_ASTC_8x5_UNORM:
+ case XGL_FMT_ASTC_8x5_SRGB:
+ case XGL_FMT_ASTC_8x6_UNORM:
+ case XGL_FMT_ASTC_8x6_SRGB:
+ case XGL_FMT_ASTC_8x8_UNORM:
+ case XGL_FMT_ASTC_8x8_SRGB:
+ case XGL_FMT_ASTC_10x5_UNORM:
+ case XGL_FMT_ASTC_10x5_SRGB:
+ case XGL_FMT_ASTC_10x6_UNORM:
+ case XGL_FMT_ASTC_10x6_SRGB:
+ case XGL_FMT_ASTC_10x8_UNORM:
+ case XGL_FMT_ASTC_10x8_SRGB:
+ case XGL_FMT_ASTC_10x10_UNORM:
+ case XGL_FMT_ASTC_10x10_SRGB:
+ case XGL_FMT_ASTC_12x10_UNORM:
+ case XGL_FMT_ASTC_12x10_SRGB:
+ case XGL_FMT_ASTC_12x12_UNORM:
+ case XGL_FMT_ASTC_12x12_SRGB:
+ return true;
+ default:
+ return false;
+ }
+}
+
size_t icd_format_get_size(XGL_FORMAT format)
{
- return icd_format_table[format.channelFormat].size;
+ return icd_format_table[format].size;
}
XGL_IMAGE_FORMAT_CLASS icd_format_get_class(XGL_FORMAT format)
unsigned int icd_format_get_channel_count(XGL_FORMAT format)
{
- return icd_format_table[format.channelFormat].channel_count;
+ return icd_format_table[format].channel_count;
}
/**
void *value)
{
/* assume little-endian */
- switch (format.channelFormat) {
- case XGL_CH_FMT_UNDEFINED:
+ switch (format) {
+ case XGL_FMT_UNDEFINED:
break;
- case XGL_CH_FMT_R4G4:
+ case XGL_FMT_R4G4_UNORM:
+ case XGL_FMT_R4G4_USCALED:
((uint8_t *) value)[0] = (color[0] & 0xf) << 0 |
(color[1] & 0xf) << 4;
break;
- case XGL_CH_FMT_R4G4B4A4:
+ case XGL_FMT_R4G4B4A4_UNORM:
+ case XGL_FMT_R4G4B4A4_USCALED:
((uint16_t *) value)[0] = (color[0] & 0xf) << 0 |
(color[1] & 0xf) << 4 |
(color[2] & 0xf) << 8 |
(color[3] & 0xf) << 12;
break;
- case XGL_CH_FMT_R5G6B5:
+ case XGL_FMT_R5G6B5_UNORM:
+ case XGL_FMT_R5G6B5_USCALED:
((uint16_t *) value)[0] = (color[0] & 0x1f) << 0 |
(color[1] & 0x3f) << 5 |
(color[2] & 0x1f) << 11;
break;
- case XGL_CH_FMT_B5G6R5:
+ case XGL_FMT_B5G6R5_UNORM:
((uint16_t *) value)[0] = (color[2] & 0x1f) << 0 |
(color[1] & 0x3f) << 5 |
(color[0] & 0x1f) << 11;
break;
- case XGL_CH_FMT_R5G5B5A1:
+ case XGL_FMT_R5G5B5A1_UNORM:
+ case XGL_FMT_R5G5B5A1_USCALED:
((uint16_t *) value)[0] = (color[0] & 0x1f) << 0 |
(color[1] & 0x1f) << 5 |
(color[2] & 0x1f) << 10 |
(color[3] & 0x1) << 15;
break;
- case XGL_CH_FMT_R8:
+ case XGL_FMT_R8_UNORM:
+ case XGL_FMT_R8_SNORM:
+ case XGL_FMT_R8_USCALED:
+ case XGL_FMT_R8_SSCALED:
+ case XGL_FMT_R8_UINT:
+ case XGL_FMT_R8_SINT:
+ case XGL_FMT_R8_SRGB:
((uint8_t *) value)[0] = (uint8_t) color[0];
break;
- case XGL_CH_FMT_R8G8:
+ case XGL_FMT_R8G8_UNORM:
+ case XGL_FMT_R8G8_SNORM:
+ case XGL_FMT_R8G8_USCALED:
+ case XGL_FMT_R8G8_SSCALED:
+ case XGL_FMT_R8G8_UINT:
+ case XGL_FMT_R8G8_SINT:
+ case XGL_FMT_R8G8_SRGB:
((uint8_t *) value)[0] = (uint8_t) color[0];
((uint8_t *) value)[1] = (uint8_t) color[1];
break;
- case XGL_CH_FMT_R8G8B8A8:
+ case XGL_FMT_R8G8B8A8_UNORM:
+ case XGL_FMT_R8G8B8A8_SNORM:
+ case XGL_FMT_R8G8B8A8_USCALED:
+ case XGL_FMT_R8G8B8A8_SSCALED:
+ case XGL_FMT_R8G8B8A8_UINT:
+ case XGL_FMT_R8G8B8A8_SINT:
+ case XGL_FMT_R8G8B8A8_SRGB:
((uint8_t *) value)[0] = (uint8_t) color[0];
((uint8_t *) value)[1] = (uint8_t) color[1];
((uint8_t *) value)[2] = (uint8_t) color[2];
((uint8_t *) value)[3] = (uint8_t) color[3];
break;
- case XGL_CH_FMT_B8G8R8A8:
+ case XGL_FMT_B8G8R8A8_UNORM:
+ case XGL_FMT_B8G8R8A8_SRGB:
((uint8_t *) value)[0] = (uint8_t) color[2];
((uint8_t *) value)[1] = (uint8_t) color[1];
((uint8_t *) value)[2] = (uint8_t) color[0];
((uint8_t *) value)[3] = (uint8_t) color[3];
break;
- case XGL_CH_FMT_R10G11B11:
- ((uint32_t *) value)[0] = (color[0] & 0x3ff) << 0 |
- (color[1] & 0x7ff) << 10 |
- (color[2] & 0x7ff) << 21;
- break;
- case XGL_CH_FMT_R11G11B10:
+ case XGL_FMT_R11G11B10_UFLOAT:
((uint32_t *) value)[0] = (color[0] & 0x7ff) << 0 |
(color[1] & 0x7ff) << 11 |
(color[2] & 0x3ff) << 22;
break;
- case XGL_CH_FMT_R10G10B10A2:
+ case XGL_FMT_R10G10B10A2_UNORM:
+ case XGL_FMT_R10G10B10A2_SNORM:
+ case XGL_FMT_R10G10B10A2_USCALED:
+ case XGL_FMT_R10G10B10A2_SSCALED:
+ case XGL_FMT_R10G10B10A2_UINT:
+ case XGL_FMT_R10G10B10A2_SINT:
((uint32_t *) value)[0] = (color[0] & 0x3ff) << 0 |
(color[1] & 0x3ff) << 10 |
(color[2] & 0x3ff) << 20 |
(color[3] & 0x3) << 30;
break;
- case XGL_CH_FMT_R16:
+ case XGL_FMT_R16_UNORM:
+ case XGL_FMT_R16_SNORM:
+ case XGL_FMT_R16_USCALED:
+ case XGL_FMT_R16_SSCALED:
+ case XGL_FMT_R16_UINT:
+ case XGL_FMT_R16_SINT:
+ case XGL_FMT_R16_SFLOAT:
((uint16_t *) value)[0] = (uint16_t) color[0];
break;
- case XGL_CH_FMT_R16G16:
+ case XGL_FMT_R16G16_UNORM:
+ case XGL_FMT_R16G16_SNORM:
+ case XGL_FMT_R16G16_USCALED:
+ case XGL_FMT_R16G16_SSCALED:
+ case XGL_FMT_R16G16_UINT:
+ case XGL_FMT_R16G16_SINT:
+ case XGL_FMT_R16G16_SFLOAT:
((uint16_t *) value)[0] = (uint16_t) color[0];
((uint16_t *) value)[1] = (uint16_t) color[1];
break;
- case XGL_CH_FMT_R16G16B16A16:
+ case XGL_FMT_R16G16B16A16_UNORM:
+ case XGL_FMT_R16G16B16A16_SNORM:
+ case XGL_FMT_R16G16B16A16_USCALED:
+ case XGL_FMT_R16G16B16A16_SSCALED:
+ case XGL_FMT_R16G16B16A16_UINT:
+ case XGL_FMT_R16G16B16A16_SINT:
+ case XGL_FMT_R16G16B16A16_SFLOAT:
((uint16_t *) value)[0] = (uint16_t) color[0];
((uint16_t *) value)[1] = (uint16_t) color[1];
((uint16_t *) value)[2] = (uint16_t) color[2];
((uint16_t *) value)[3] = (uint16_t) color[3];
break;
- case XGL_CH_FMT_R32:
+ case XGL_FMT_R32_UINT:
+ case XGL_FMT_R32_SINT:
+ case XGL_FMT_R32_SFLOAT:
((uint32_t *) value)[0] = color[0];
break;
- case XGL_CH_FMT_R32G32:
+ case XGL_FMT_R32G32_UINT:
+ case XGL_FMT_R32G32_SINT:
+ case XGL_FMT_R32G32_SFLOAT:
((uint32_t *) value)[0] = color[0];
((uint32_t *) value)[1] = color[1];
break;
- case XGL_CH_FMT_R32G32B32:
+ case XGL_FMT_R32G32B32_UINT:
+ case XGL_FMT_R32G32B32_SINT:
+ case XGL_FMT_R32G32B32_SFLOAT:
((uint32_t *) value)[0] = color[0];
((uint32_t *) value)[1] = color[1];
((uint32_t *) value)[2] = color[2];
break;
- case XGL_CH_FMT_R32G32B32A32:
+ case XGL_FMT_R32G32B32A32_UINT:
+ case XGL_FMT_R32G32B32A32_SINT:
+ case XGL_FMT_R32G32B32A32_SFLOAT:
((uint32_t *) value)[0] = color[0];
((uint32_t *) value)[1] = color[1];
((uint32_t *) value)[2] = color[2];
((uint32_t *) value)[3] = color[3];
break;
- case XGL_CH_FMT_R16G8:
+ case XGL_FMT_D16_UNORM_S8_UINT:
((uint16_t *) value)[0] = (uint16_t) color[0];
((char *) value)[2] = (uint8_t) color[1];
break;
- case XGL_CH_FMT_R32G8:
+ case XGL_FMT_D32_SFLOAT_S8_UINT:
((uint32_t *) value)[0] = (uint32_t) color[0];
((char *) value)[4] = (uint8_t) color[1];
break;
- case XGL_CH_FMT_R9G9B9E5:
+ case XGL_FMT_R9G9B9E5_UFLOAT:
((uint32_t *) value)[0] = (color[0] & 0x1ff) << 0 |
(color[1] & 0x1ff) << 9 |
(color[2] & 0x1ff) << 18 |
(color[3] & 0x1f) << 27;
break;
- case XGL_CH_FMT_BC1:
- case XGL_CH_FMT_BC4:
+ case XGL_FMT_BC1_UNORM:
+ case XGL_FMT_BC1_SRGB:
+ case XGL_FMT_BC4_UNORM:
+ case XGL_FMT_BC4_SNORM:
memcpy(value, color, 8);
break;
- case XGL_CH_FMT_BC2:
- case XGL_CH_FMT_BC3:
- case XGL_CH_FMT_BC5:
- case XGL_CH_FMT_BC6U:
- case XGL_CH_FMT_BC6S:
- case XGL_CH_FMT_BC7:
+ case XGL_FMT_BC2_UNORM:
+ case XGL_FMT_BC2_SRGB:
+ case XGL_FMT_BC3_UNORM:
+ case XGL_FMT_BC3_SRGB:
+ case XGL_FMT_BC5_UNORM:
+ case XGL_FMT_BC5_SNORM:
+ case XGL_FMT_BC6H_UFLOAT:
+ case XGL_FMT_BC6H_SFLOAT:
+ case XGL_FMT_BC7_UNORM:
+ case XGL_FMT_BC7_SRGB:
memcpy(value, color, 16);
break;
- case XGL_CH_FMT_R8G8B8:
+ case XGL_FMT_R8G8B8_UNORM:
+ case XGL_FMT_R8G8B8_SNORM:
+ case XGL_FMT_R8G8B8_USCALED:
+ case XGL_FMT_R8G8B8_SSCALED:
+ case XGL_FMT_R8G8B8_UINT:
+ case XGL_FMT_R8G8B8_SINT:
+ case XGL_FMT_R8G8B8_SRGB:
((uint8_t *) value)[0] = (uint8_t) color[0];
((uint8_t *) value)[1] = (uint8_t) color[1];
((uint8_t *) value)[2] = (uint8_t) color[2];
break;
- case XGL_CH_FMT_R16G16B16:
+ case XGL_FMT_R16G16B16_UNORM:
+ case XGL_FMT_R16G16B16_SNORM:
+ case XGL_FMT_R16G16B16_USCALED:
+ case XGL_FMT_R16G16B16_SSCALED:
+ case XGL_FMT_R16G16B16_UINT:
+ case XGL_FMT_R16G16B16_SINT:
+ case XGL_FMT_R16G16B16_SFLOAT:
((uint16_t *) value)[0] = (uint16_t) color[0];
((uint16_t *) value)[1] = (uint16_t) color[1];
((uint16_t *) value)[2] = (uint16_t) color[2];
break;
- case XGL_CH_FMT_B10G10R10A2:
+ case XGL_FMT_B10G10R10A2_UNORM:
+ case XGL_FMT_B10G10R10A2_SNORM:
+ case XGL_FMT_B10G10R10A2_USCALED:
+ case XGL_FMT_B10G10R10A2_SSCALED:
+ case XGL_FMT_B10G10R10A2_UINT:
+ case XGL_FMT_B10G10R10A2_SINT:
((uint32_t *) value)[0] = (color[2] & 0x3ff) << 0 |
(color[1] & 0x3ff) << 10 |
(color[0] & 0x3ff) << 20 |
(color[3] & 0x3) << 30;
break;
- case XGL_CH_FMT_R64:
+ case XGL_FMT_R64_SFLOAT:
/* higher 32 bits always 0 */
((uint64_t *) value)[0] = color[0];
break;
- case XGL_CH_FMT_R64G64:
+ case XGL_FMT_R64G64_SFLOAT:
((uint64_t *) value)[0] = color[0];
((uint64_t *) value)[1] = color[1];
break;
- case XGL_CH_FMT_R64G64B64:
+ case XGL_FMT_R64G64B64_SFLOAT:
((uint64_t *) value)[0] = color[0];
((uint64_t *) value)[1] = color[1];
((uint64_t *) value)[2] = color[2];
break;
- case XGL_CH_FMT_R64G64B64A64:
+ case XGL_FMT_R64G64B64A64_SFLOAT:
((uint64_t *) value)[0] = color[0];
((uint64_t *) value)[1] = color[1];
((uint64_t *) value)[2] = color[2];
static inline bool icd_format_is_undef(XGL_FORMAT format)
{
- return (format.numericFormat == XGL_NUM_FMT_UNDEFINED);
+ return (format == XGL_FMT_UNDEFINED);
}
-static inline bool icd_format_is_ds(XGL_FORMAT format)
-{
- return (format.numericFormat == XGL_NUM_FMT_DS);
-}
+bool icd_format_is_ds(XGL_FORMAT format);
static inline bool icd_format_is_color(XGL_FORMAT format)
{
return !(icd_format_is_undef(format) || icd_format_is_ds(format));
}
-static inline bool icd_format_is_norm(XGL_FORMAT format)
-{
- return (format.numericFormat == XGL_NUM_FMT_UNORM ||
- format.numericFormat == XGL_NUM_FMT_SNORM);
-};
+bool icd_format_is_norm(XGL_FORMAT format);
-static inline bool icd_format_is_int(XGL_FORMAT format)
-{
- return (format.numericFormat == XGL_NUM_FMT_UINT ||
- format.numericFormat == XGL_NUM_FMT_SINT);
-}
+bool icd_format_is_int(XGL_FORMAT format);
-static inline bool icd_format_is_float(XGL_FORMAT format)
-{
- return (format.numericFormat == XGL_NUM_FMT_FLOAT);
-}
+bool icd_format_is_float(XGL_FORMAT format);
-static inline bool icd_format_is_srgb(XGL_FORMAT format)
-{
- return (format.numericFormat == XGL_NUM_FMT_SRGB);
-}
+bool icd_format_is_srgb(XGL_FORMAT format);
-static inline bool icd_format_is_scaled(XGL_FORMAT format)
-{
- return (format.numericFormat == XGL_NUM_FMT_USCALED ||
- format.numericFormat == XGL_NUM_FMT_SSCALED);
-}
-
-static inline bool icd_format_is_compressed(XGL_FORMAT format)
-{
- switch (format.channelFormat) {
- case XGL_CH_FMT_BC1:
- case XGL_CH_FMT_BC2:
- case XGL_CH_FMT_BC3:
- case XGL_CH_FMT_BC4:
- case XGL_CH_FMT_BC5:
- case XGL_CH_FMT_BC6U:
- case XGL_CH_FMT_BC6S:
- case XGL_CH_FMT_BC7:
- return true;
- default:
- return false;
- }
-}
-
-static inline bool icd_format_is_equal(XGL_FORMAT a, XGL_FORMAT b)
-{
- return (a.channelFormat == b.channelFormat &&
- a.numericFormat == b.numericFormat);
-}
+bool icd_format_is_compressed(XGL_FORMAT format);
static inline int icd_format_get_block_width(XGL_FORMAT format)
{
static XGL_FORMAT cmd_meta_img_raw_format(const struct intel_cmd *cmd,
XGL_FORMAT format)
{
- format.numericFormat = XGL_NUM_FMT_UINT;
-
switch (icd_format_get_size(format)) {
case 1:
- format.channelFormat = XGL_CH_FMT_R8;
+ format = XGL_FMT_R8_UINT;
break;
case 2:
- format.channelFormat = XGL_CH_FMT_R16;
+ format = XGL_FMT_R16_UINT;
break;
case 4:
- format.channelFormat = XGL_CH_FMT_R32;
+ format = XGL_FMT_R32_UINT;
break;
case 8:
- format.channelFormat = XGL_CH_FMT_R32G32;
+ format = XGL_FMT_R32G32_UINT;
break;
case 16:
- format.channelFormat = XGL_CH_FMT_R32G32B32A32;
+ format = XGL_FMT_R32G32B32A32_UINT;
break;
default:
assert(!"unsupported image format for raw blit op");
- format.channelFormat = XGL_CH_FMT_UNDEFINED;
- format.numericFormat = XGL_NUM_FMT_UNDEFINED;
+ format = XGL_FMT_UNDEFINED;
break;
}
meta.height = 1;
meta.samples = 1;
- format.channelFormat = XGL_CH_FMT_UNDEFINED;
- format.numericFormat = XGL_NUM_FMT_UINT;
+ format = XGL_FMT_UNDEFINED;
for (i = 0; i < regionCount; i++) {
const XGL_BUFFER_COPY *region = &pRegions[i];
- XGL_CHANNEL_FORMAT ch;
+ XGL_FORMAT fmt;
meta.src.x = region->srcOffset;
meta.dst.x = region->destOffset;
* INTEL_DEV_META_VS_COPY_MEM is untyped but expects the stride to
* be 16
*/
- ch = XGL_CH_FMT_R32G32B32A32;
+ fmt = XGL_FMT_R32G32B32A32_UINT;
} else {
if (cmd_gen(cmd) == INTEL_GEN(6)) {
intel_dev_log(cmd->dev, XGL_DBG_MSG_ERROR,
* INTEL_DEV_META_VS_COPY_MEM_UNALIGNED is untyped but expects the
* stride to be 4
*/
- ch = XGL_CH_FMT_R8G8B8A8;
+ fmt = XGL_FMT_R8G8B8A8_UINT;
}
- if (format.channelFormat != ch) {
- format.channelFormat = ch;
+ if (format != fmt) {
+ format = fmt;
cmd_meta_set_src_for_buf(cmd, src, format, &meta);
cmd_meta_set_dst_for_buf(cmd, dst, format, &meta);
return;
}
- if (icd_format_is_equal(src->layout.format, dst->layout.format)) {
+ if (src->layout.format == dst->layout.format) {
raw_copy = true;
raw_format = cmd_meta_img_raw_format(cmd, src->layout.format);
} else if (icd_format_is_compressed(src->layout.format) ||
meta.mode = INTEL_CMD_META_VS_POINTS;
img_format = cmd_meta_img_raw_format(cmd, img->layout.format);
- buf_format.numericFormat = XGL_NUM_FMT_UINT;
/* buf_format is ignored by hw, but we derive stride from it */
- switch (img_format.channelFormat) {
- case XGL_CH_FMT_R8:
+ switch (img_format) {
+ case XGL_FMT_R8_UINT:
meta.shader_id = INTEL_DEV_META_VS_COPY_R8_TO_MEM;
- buf_format.channelFormat = XGL_CH_FMT_R8G8B8A8;
+ buf_format = XGL_FMT_R8G8B8A8_UINT;
break;
- case XGL_CH_FMT_R16:
+ case XGL_FMT_R16_UINT:
meta.shader_id = INTEL_DEV_META_VS_COPY_R16_TO_MEM;
- buf_format.channelFormat = XGL_CH_FMT_R8G8B8A8;
+ buf_format = XGL_FMT_R8G8B8A8_UINT;
break;
- case XGL_CH_FMT_R32:
+ case XGL_FMT_R32_UINT:
meta.shader_id = INTEL_DEV_META_VS_COPY_R32_TO_MEM;
- buf_format.channelFormat = XGL_CH_FMT_R32G32B32A32;
+ buf_format = XGL_FMT_R32G32B32A32_UINT;
break;
- case XGL_CH_FMT_R32G32:
+ case XGL_FMT_R32G32_UINT:
meta.shader_id = INTEL_DEV_META_VS_COPY_R32G32_TO_MEM;
- buf_format.channelFormat = XGL_CH_FMT_R32G32B32A32;
+ buf_format = XGL_FMT_R32G32B32A32_UINT;
break;
- case XGL_CH_FMT_R32G32B32A32:
+ case XGL_FMT_R32G32B32A32_UINT:
meta.shader_id = INTEL_DEV_META_VS_COPY_R32G32B32A32_TO_MEM;
- buf_format.channelFormat = XGL_CH_FMT_R32G32B32A32;
+ buf_format = XGL_FMT_R32G32B32A32_UINT;
break;
default:
break;
}
- if (img_format.channelFormat == XGL_CH_FMT_UNDEFINED ||
+ if (img_format == XGL_FMT_UNDEFINED ||
(cmd_gen(cmd) == INTEL_GEN(6) &&
icd_format_get_size(img_format) < 4)) {
intel_dev_log(cmd->dev, XGL_DBG_MSG_ERROR,
/*
* INTEL_DEV_META_VS_COPY_MEM is untyped but expects the stride to be 16
*/
- format.channelFormat = XGL_CH_FMT_R32G32B32A32;
- format.numericFormat = XGL_NUM_FMT_UINT;
+ format = XGL_FMT_R32G32B32A32_UINT;
cmd_meta_set_src_for_writer(cmd, INTEL_CMD_WRITER_STATE,
offset + dataSize, format, &meta);
/*
* INTEL_DEV_META_VS_FILL_MEM is untyped but expects the stride to be 16
*/
- format.channelFormat = XGL_CH_FMT_R32G32B32A32;
- format.numericFormat = XGL_NUM_FMT_UINT;
+ format = XGL_FMT_R32G32B32A32_UINT;
cmd_meta_set_dst_for_buf(cmd, dst, format, &meta);
XGL_UINT i;
if (src->samples <= 1 || dst->samples > 1 ||
- !icd_format_is_equal(src->layout.format, dst->layout.format)) {
+ src->layout.format != dst->layout.format) {
cmd->result = XGL_ERROR_UNKNOWN;
return;
}
if (cmd_gen(cmd) >= INTEL_GEN(7)) {
int format;
- switch (pipeline->db_format.channelFormat) {
- case XGL_CH_FMT_R16:
+ switch (pipeline->db_format) {
+ case XGL_FMT_D16_UNORM:
format = GEN6_ZFORMAT_D16_UNORM;
break;
- case XGL_CH_FMT_R32:
- case XGL_CH_FMT_R32G8:
+ case XGL_FMT_D32_SFLOAT:
+ case XGL_FMT_D32_SFLOAT_S8_UINT:
format = GEN6_ZFORMAT_D32_FLOAT;
break;
default:
flush_flags |= cmd_get_flush_flags(cmd,
img_get_layout_caches(img, image_memory_barrier->oldLayout),
img_get_layout_caches(img, image_memory_barrier->newLayout),
- (img->layout.format.numericFormat == XGL_NUM_FMT_DS));
+ icd_format_is_ds(img->layout.format));
}
break;
default:
#undef CAP
};
-static const int intel_color_mapping[XGL_MAX_CH_FMT + 1][9] = {
- [XGL_CH_FMT_B5G6R5] = { GEN6_FORMAT_B5G6R5_UNORM,
- 0,
- 0,
- 0,
- 0,
- GEN6_FORMAT_B5G6R5_UNORM_SRGB,
- 0,
- 0,
- 0, },
- [XGL_CH_FMT_R8] = { GEN6_FORMAT_R8_UNORM,
- GEN6_FORMAT_R8_SNORM,
- GEN6_FORMAT_R8_UINT,
- GEN6_FORMAT_R8_SINT,
- 0,
- 0,
- 0,
- GEN6_FORMAT_R8_USCALED,
- GEN6_FORMAT_R8_SSCALED, },
- [XGL_CH_FMT_R8G8] = { GEN6_FORMAT_R8G8_UNORM,
- GEN6_FORMAT_R8G8_SNORM,
- GEN6_FORMAT_R8G8_UINT,
- GEN6_FORMAT_R8G8_SINT,
- 0,
- 0,
- 0,
- GEN6_FORMAT_R8G8_USCALED,
- GEN6_FORMAT_R8G8_SSCALED, },
- [XGL_CH_FMT_R8G8B8A8] = { GEN6_FORMAT_R8G8B8A8_UNORM,
- GEN6_FORMAT_R8G8B8A8_SNORM,
- GEN6_FORMAT_R8G8B8A8_UINT,
- GEN6_FORMAT_R8G8B8A8_SINT,
- 0,
- GEN6_FORMAT_R8G8B8A8_UNORM_SRGB,
- 0,
- GEN6_FORMAT_R8G8B8A8_USCALED,
- GEN6_FORMAT_R8G8B8A8_SSCALED, },
- [XGL_CH_FMT_B8G8R8A8] = { GEN6_FORMAT_B8G8R8A8_UNORM,
- 0,
- 0,
- 0,
- 0,
- GEN6_FORMAT_B8G8R8A8_UNORM_SRGB,
- 0,
- 0,
- 0, },
- [XGL_CH_FMT_R11G11B10] = { 0,
- 0,
- 0,
- 0,
- GEN6_FORMAT_R11G11B10_FLOAT,
- 0,
- 0,
- 0,
- 0, },
- [XGL_CH_FMT_R10G10B10A2] = { GEN6_FORMAT_R10G10B10A2_UNORM,
- GEN6_FORMAT_R10G10B10A2_SNORM,
- GEN6_FORMAT_R10G10B10A2_UINT,
- GEN6_FORMAT_R10G10B10A2_SINT,
- 0,
- 0,
- 0,
- GEN6_FORMAT_R10G10B10A2_USCALED,
- GEN6_FORMAT_R10G10B10A2_SSCALED, },
- [XGL_CH_FMT_R16] = { GEN6_FORMAT_R16_UNORM,
- GEN6_FORMAT_R16_SNORM,
- GEN6_FORMAT_R16_UINT,
- GEN6_FORMAT_R16_SINT,
- GEN6_FORMAT_R16_FLOAT,
- 0,
- 0,
- GEN6_FORMAT_R16_USCALED,
- GEN6_FORMAT_R16_SSCALED, },
- [XGL_CH_FMT_R16G16] = { GEN6_FORMAT_R16G16_UNORM,
- GEN6_FORMAT_R16G16_SNORM,
- GEN6_FORMAT_R16G16_UINT,
- GEN6_FORMAT_R16G16_SINT,
- GEN6_FORMAT_R16G16_FLOAT,
- 0,
- 0,
- GEN6_FORMAT_R16G16_USCALED,
- GEN6_FORMAT_R16G16_SSCALED, },
- [XGL_CH_FMT_R16G16B16A16] = { GEN6_FORMAT_R16G16B16A16_UNORM,
- GEN6_FORMAT_R16G16B16A16_SNORM,
- GEN6_FORMAT_R16G16B16A16_UINT,
- GEN6_FORMAT_R16G16B16A16_SINT,
- GEN6_FORMAT_R16G16B16A16_FLOAT,
- 0,
- 0,
- GEN6_FORMAT_R16G16B16A16_USCALED,
- GEN6_FORMAT_R16G16B16A16_SSCALED, },
- [XGL_CH_FMT_R32] = { GEN6_FORMAT_R32_UNORM,
- GEN6_FORMAT_R32_SNORM,
- GEN6_FORMAT_R32_UINT,
- GEN6_FORMAT_R32_SINT,
- GEN6_FORMAT_R32_FLOAT,
- 0,
- 0,
- GEN6_FORMAT_R32_USCALED,
- GEN6_FORMAT_R32_SSCALED, },
- [XGL_CH_FMT_R32G32] = { GEN6_FORMAT_R32G32_UNORM,
- GEN6_FORMAT_R32G32_SNORM,
- GEN6_FORMAT_R32G32_UINT,
- GEN6_FORMAT_R32G32_SINT,
- GEN6_FORMAT_R32G32_FLOAT,
- 0,
- 0,
- GEN6_FORMAT_R32G32_USCALED,
- GEN6_FORMAT_R32G32_SSCALED, },
- [XGL_CH_FMT_R32G32B32] = { GEN6_FORMAT_R32G32B32_UNORM,
- GEN6_FORMAT_R32G32B32_SNORM,
- GEN6_FORMAT_R32G32B32_UINT,
- GEN6_FORMAT_R32G32B32_SINT,
- GEN6_FORMAT_R32G32B32_FLOAT,
- 0,
- 0,
- GEN6_FORMAT_R32G32B32_USCALED,
- GEN6_FORMAT_R32G32B32_SSCALED, },
- [XGL_CH_FMT_R32G32B32A32] = { GEN6_FORMAT_R32G32B32A32_UNORM,
- GEN6_FORMAT_R32G32B32A32_SNORM,
- GEN6_FORMAT_R32G32B32A32_UINT,
- GEN6_FORMAT_R32G32B32A32_SINT,
- GEN6_FORMAT_R32G32B32A32_FLOAT,
- 0,
- 0,
- GEN6_FORMAT_R32G32B32A32_USCALED,
- GEN6_FORMAT_R32G32B32A32_SSCALED, },
- [XGL_CH_FMT_R9G9B9E5] = { 0,
- 0,
- 0,
- 0,
- GEN6_FORMAT_R9G9B9E5_SHAREDEXP,
- 0,
- 0,
- 0,
- 0, },
- [XGL_CH_FMT_BC1] = { GEN6_FORMAT_BC1_UNORM,
- 0,
- 0,
- 0,
- 0,
- GEN6_FORMAT_BC1_UNORM_SRGB,
- 0,
- 0,
- 0, },
- [XGL_CH_FMT_BC2] = { GEN6_FORMAT_BC2_UNORM,
- 0,
- 0,
- 0,
- 0,
- GEN6_FORMAT_BC2_UNORM_SRGB,
- 0,
- 0,
- 0, },
- [XGL_CH_FMT_BC3] = { GEN6_FORMAT_BC3_UNORM,
- 0,
- 0,
- 0,
- 0,
- GEN6_FORMAT_BC3_UNORM_SRGB,
- 0,
- 0,
- 0, },
- [XGL_CH_FMT_BC4] = { GEN6_FORMAT_BC4_UNORM,
- GEN6_FORMAT_BC4_SNORM,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0, },
- [XGL_CH_FMT_BC5] = { GEN6_FORMAT_BC5_UNORM,
- GEN6_FORMAT_BC5_SNORM,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0, },
- [XGL_CH_FMT_BC6U] = { GEN6_FORMAT_BC6H_UF16,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0, },
- [XGL_CH_FMT_BC6S] = { GEN6_FORMAT_BC6H_SF16,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0, },
- [XGL_CH_FMT_BC7] = { GEN6_FORMAT_BC7_UNORM,
- 0,
- 0,
- 0,
- 0,
- GEN6_FORMAT_BC7_UNORM_SRGB,
- 0,
- 0,
- 0, },
- [XGL_CH_FMT_R8G8B8] = { GEN6_FORMAT_R8G8B8_UNORM,
- GEN6_FORMAT_R8G8B8_SNORM,
- GEN6_FORMAT_R8G8B8_UINT,
- GEN6_FORMAT_R8G8B8_SINT,
- 0,
- GEN6_FORMAT_R8G8B8_UNORM_SRGB,
- 0,
- GEN6_FORMAT_R8G8B8_USCALED,
- GEN6_FORMAT_R8G8B8_SSCALED, },
- [XGL_CH_FMT_R16G16B16] = { GEN6_FORMAT_R16G16B16_UNORM,
- GEN6_FORMAT_R16G16B16_SNORM,
- GEN6_FORMAT_R16G16B16_UINT,
- GEN6_FORMAT_R16G16B16_SINT,
- 0,
- 0,
- 0,
- GEN6_FORMAT_R16G16B16_USCALED,
- GEN6_FORMAT_R16G16B16_SSCALED, },
- [XGL_CH_FMT_B10G10R10A2] = { GEN6_FORMAT_B10G10R10A2_UNORM,
- GEN6_FORMAT_B10G10R10A2_SNORM,
- GEN6_FORMAT_B10G10R10A2_UINT,
- GEN6_FORMAT_B10G10R10A2_SINT,
- 0,
- GEN6_FORMAT_B10G10R10A2_UNORM_SRGB,
- 0,
- GEN6_FORMAT_B10G10R10A2_USCALED,
- GEN6_FORMAT_B10G10R10A2_SSCALED, },
- [XGL_CH_FMT_R64] = { 0,
- 0,
- 0,
- 0,
- GEN6_FORMAT_R64_FLOAT,
- 0,
- 0,
- 0,
- 0, },
- [XGL_CH_FMT_R64G64] = { 0,
- 0,
- 0,
- 0,
- GEN6_FORMAT_R64G64_FLOAT,
- 0,
- 0,
- 0,
- 0, },
- [XGL_CH_FMT_R64G64B64] = { 0,
- 0,
- 0,
- 0,
- GEN6_FORMAT_R64G64B64_FLOAT,
- 0,
- 0,
- 0,
- 0, },
- [XGL_CH_FMT_R64G64B64A64] = { 0,
- 0,
- 0,
- 0,
- GEN6_FORMAT_R64G64B64A64_FLOAT,
- 0,
- 0,
- 0,
- 0, },
+static const int intel_color_mapping[XGL_NUM_FMT] = {
+ [XGL_FMT_R4G4_UNORM] = 0,
+ [XGL_FMT_R4G4_USCALED] = 0,
+ [XGL_FMT_R4G4B4A4_UNORM] = 0,
+ [XGL_FMT_R4G4B4A4_USCALED] = 0,
+ [XGL_FMT_R5G6B5_UNORM] = 0,
+ [XGL_FMT_R5G6B5_USCALED] = 0,
+ [XGL_FMT_R5G5B5A1_UNORM] = 0,
+ [XGL_FMT_R5G5B5A1_USCALED] = 0,
+ [XGL_FMT_R8_UNORM] = GEN6_FORMAT_R8_UNORM,
+ [XGL_FMT_R8_SNORM] = GEN6_FORMAT_R8_SNORM,
+ [XGL_FMT_R8_USCALED] = GEN6_FORMAT_R8_USCALED,
+ [XGL_FMT_R8_SSCALED] = GEN6_FORMAT_R8_SSCALED,
+ [XGL_FMT_R8_UINT] = GEN6_FORMAT_R8_UINT,
+ [XGL_FMT_R8_SINT] = GEN6_FORMAT_R8_SINT,
+ [XGL_FMT_R8_SRGB] = 0,
+ [XGL_FMT_R8G8_UNORM] = GEN6_FORMAT_R8G8_UNORM,
+ [XGL_FMT_R8G8_SNORM] = GEN6_FORMAT_R8G8_SNORM,
+ [XGL_FMT_R8G8_USCALED] = GEN6_FORMAT_R8G8_USCALED,
+ [XGL_FMT_R8G8_SSCALED] = GEN6_FORMAT_R8G8_SSCALED,
+ [XGL_FMT_R8G8_UINT] = GEN6_FORMAT_R8G8_UINT,
+ [XGL_FMT_R8G8_SINT] = GEN6_FORMAT_R8G8_SINT,
+ [XGL_FMT_R8G8_SRGB] = 0,
+ [XGL_FMT_R8G8B8_UNORM] = GEN6_FORMAT_R8G8B8_UNORM,
+ [XGL_FMT_R8G8B8_SNORM] = GEN6_FORMAT_R8G8B8_SNORM,
+ [XGL_FMT_R8G8B8_USCALED] = GEN6_FORMAT_R8G8B8_USCALED,
+ [XGL_FMT_R8G8B8_SSCALED] = GEN6_FORMAT_R8G8B8_SSCALED,
+ [XGL_FMT_R8G8B8_UINT] = GEN6_FORMAT_R8G8B8_UINT,
+ [XGL_FMT_R8G8B8_SINT] = GEN6_FORMAT_R8G8B8_SINT,
+ [XGL_FMT_R8G8B8_SRGB] = GEN6_FORMAT_R8G8B8_UNORM_SRGB,
+ [XGL_FMT_R8G8B8A8_UNORM] = GEN6_FORMAT_R8G8B8A8_UNORM,
+ [XGL_FMT_R8G8B8A8_SNORM] = GEN6_FORMAT_R8G8B8A8_SNORM,
+ [XGL_FMT_R8G8B8A8_USCALED] = GEN6_FORMAT_R8G8B8A8_USCALED,
+ [XGL_FMT_R8G8B8A8_SSCALED] = GEN6_FORMAT_R8G8B8A8_SSCALED,
+ [XGL_FMT_R8G8B8A8_UINT] = GEN6_FORMAT_R8G8B8A8_UINT,
+ [XGL_FMT_R8G8B8A8_SINT] = GEN6_FORMAT_R8G8B8A8_SINT,
+ [XGL_FMT_R8G8B8A8_SRGB] = GEN6_FORMAT_R8G8B8A8_UNORM_SRGB,
+ [XGL_FMT_R10G10B10A2_UNORM] = GEN6_FORMAT_R10G10B10A2_UNORM,
+ [XGL_FMT_R10G10B10A2_SNORM] = GEN6_FORMAT_R10G10B10A2_SNORM,
+ [XGL_FMT_R10G10B10A2_USCALED] = GEN6_FORMAT_R10G10B10A2_USCALED,
+ [XGL_FMT_R10G10B10A2_SSCALED] = GEN6_FORMAT_R10G10B10A2_SSCALED,
+ [XGL_FMT_R10G10B10A2_UINT] = GEN6_FORMAT_R10G10B10A2_UINT,
+ [XGL_FMT_R10G10B10A2_SINT] = GEN6_FORMAT_R10G10B10A2_SINT,
+ [XGL_FMT_R16_UNORM] = GEN6_FORMAT_R16_UNORM,
+ [XGL_FMT_R16_SNORM] = GEN6_FORMAT_R16_SNORM,
+ [XGL_FMT_R16_USCALED] = GEN6_FORMAT_R16_USCALED,
+ [XGL_FMT_R16_SSCALED] = GEN6_FORMAT_R16_SSCALED,
+ [XGL_FMT_R16_UINT] = GEN6_FORMAT_R16_UINT,
+ [XGL_FMT_R16_SINT] = GEN6_FORMAT_R16_SINT,
+ [XGL_FMT_R16_SFLOAT] = GEN6_FORMAT_R16_FLOAT,
+ [XGL_FMT_R16G16_UNORM] = GEN6_FORMAT_R16G16_UNORM,
+ [XGL_FMT_R16G16_SNORM] = GEN6_FORMAT_R16G16_SNORM,
+ [XGL_FMT_R16G16_USCALED] = GEN6_FORMAT_R16G16_USCALED,
+ [XGL_FMT_R16G16_SSCALED] = GEN6_FORMAT_R16G16_SSCALED,
+ [XGL_FMT_R16G16_UINT] = GEN6_FORMAT_R16G16_UINT,
+ [XGL_FMT_R16G16_SINT] = GEN6_FORMAT_R16G16_SINT,
+ [XGL_FMT_R16G16_SFLOAT] = GEN6_FORMAT_R16G16_FLOAT,
+ [XGL_FMT_R16G16B16_UNORM] = GEN6_FORMAT_R16G16B16_UNORM,
+ [XGL_FMT_R16G16B16_SNORM] = GEN6_FORMAT_R16G16B16_SNORM,
+ [XGL_FMT_R16G16B16_USCALED] = GEN6_FORMAT_R16G16B16_USCALED,
+ [XGL_FMT_R16G16B16_SSCALED] = GEN6_FORMAT_R16G16B16_SSCALED,
+ [XGL_FMT_R16G16B16_UINT] = GEN6_FORMAT_R16G16B16_UINT,
+ [XGL_FMT_R16G16B16_SINT] = GEN6_FORMAT_R16G16B16_SINT,
+ [XGL_FMT_R16G16B16_SFLOAT] = 0,
+ [XGL_FMT_R16G16B16A16_UNORM] = GEN6_FORMAT_R16G16B16A16_UNORM,
+ [XGL_FMT_R16G16B16A16_SNORM] = GEN6_FORMAT_R16G16B16A16_SNORM,
+ [XGL_FMT_R16G16B16A16_USCALED] = GEN6_FORMAT_R16G16B16A16_USCALED,
+ [XGL_FMT_R16G16B16A16_SSCALED] = GEN6_FORMAT_R16G16B16A16_SSCALED,
+ [XGL_FMT_R16G16B16A16_UINT] = GEN6_FORMAT_R16G16B16A16_UINT,
+ [XGL_FMT_R16G16B16A16_SINT] = GEN6_FORMAT_R16G16B16A16_SINT,
+ [XGL_FMT_R16G16B16A16_SFLOAT] = GEN6_FORMAT_R16G16B16A16_FLOAT,
+ [XGL_FMT_R32_UINT] = GEN6_FORMAT_R32_UINT,
+ [XGL_FMT_R32_SINT] = GEN6_FORMAT_R32_SINT,
+ [XGL_FMT_R32_SFLOAT] = GEN6_FORMAT_R32_FLOAT,
+ [XGL_FMT_R32G32_UINT] = GEN6_FORMAT_R32G32_UINT,
+ [XGL_FMT_R32G32_SINT] = GEN6_FORMAT_R32G32_SINT,
+ [XGL_FMT_R32G32_SFLOAT] = GEN6_FORMAT_R32G32_FLOAT,
+ [XGL_FMT_R32G32B32_UINT] = GEN6_FORMAT_R32G32B32_UINT,
+ [XGL_FMT_R32G32B32_SINT] = GEN6_FORMAT_R32G32B32_SINT,
+ [XGL_FMT_R32G32B32_SFLOAT] = GEN6_FORMAT_R32G32B32_FLOAT,
+ [XGL_FMT_R32G32B32A32_UINT] = GEN6_FORMAT_R32G32B32A32_UINT,
+ [XGL_FMT_R32G32B32A32_SINT] = GEN6_FORMAT_R32G32B32A32_SINT,
+ [XGL_FMT_R32G32B32A32_SFLOAT] = GEN6_FORMAT_R32G32B32A32_FLOAT,
+ [XGL_FMT_R64_SFLOAT] = GEN6_FORMAT_R64_FLOAT,
+ [XGL_FMT_R64G64_SFLOAT] = GEN6_FORMAT_R64G64_FLOAT,
+ [XGL_FMT_R64G64B64_SFLOAT] = GEN6_FORMAT_R64G64B64_FLOAT,
+ [XGL_FMT_R64G64B64A64_SFLOAT] = GEN6_FORMAT_R64G64B64A64_FLOAT,
+ [XGL_FMT_R11G11B10_UFLOAT] = GEN6_FORMAT_R11G11B10_FLOAT,
+ [XGL_FMT_R9G9B9E5_UFLOAT] = GEN6_FORMAT_R9G9B9E5_SHAREDEXP,
+ [XGL_FMT_BC1_UNORM] = GEN6_FORMAT_BC1_UNORM,
+ [XGL_FMT_BC1_SRGB] = GEN6_FORMAT_BC1_UNORM_SRGB,
+ [XGL_FMT_BC2_UNORM] = GEN6_FORMAT_BC2_UNORM,
+ [XGL_FMT_BC2_SRGB] = GEN6_FORMAT_BC2_UNORM_SRGB,
+ [XGL_FMT_BC3_UNORM] = GEN6_FORMAT_BC3_UNORM,
+ [XGL_FMT_BC3_SRGB] = GEN6_FORMAT_BC3_UNORM_SRGB,
+ [XGL_FMT_BC4_UNORM] = GEN6_FORMAT_BC4_UNORM,
+ [XGL_FMT_BC4_SNORM] = GEN6_FORMAT_BC4_SNORM,
+ [XGL_FMT_BC5_UNORM] = GEN6_FORMAT_BC5_UNORM,
+ [XGL_FMT_BC5_SNORM] = GEN6_FORMAT_BC5_SNORM,
+ [XGL_FMT_BC6H_UFLOAT] = GEN6_FORMAT_BC6H_UF16,
+ [XGL_FMT_BC6H_SFLOAT] = GEN6_FORMAT_BC6H_SF16,
+ [XGL_FMT_BC7_UNORM] = GEN6_FORMAT_BC7_UNORM,
+ [XGL_FMT_BC7_SRGB] = GEN6_FORMAT_BC7_UNORM_SRGB,
+ /* TODO: Implement for remaining compressed formats. */
+ [XGL_FMT_ETC2_R8G8B8_UNORM] = 0,
+ [XGL_FMT_ETC2_R8G8B8A1_UNORM] = 0,
+ [XGL_FMT_ETC2_R8G8B8A8_UNORM] = 0,
+ [XGL_FMT_EAC_R11_UNORM] = 0,
+ [XGL_FMT_EAC_R11_SNORM] = 0,
+ [XGL_FMT_EAC_R11G11_UNORM] = 0,
+ [XGL_FMT_EAC_R11G11_SNORM] = 0,
+ [XGL_FMT_ASTC_4x4_UNORM] = 0,
+ [XGL_FMT_ASTC_4x4_SRGB] = 0,
+ [XGL_FMT_ASTC_4x5_UNORM] = 0,
+ [XGL_FMT_ASTC_4x5_SRGB] = 0,
+ [XGL_FMT_ASTC_5x5_UNORM] = 0,
+ [XGL_FMT_ASTC_5x5_SRGB] = 0,
+ [XGL_FMT_ASTC_6x5_UNORM] = 0,
+ [XGL_FMT_ASTC_6x5_SRGB] = 0,
+ [XGL_FMT_ASTC_6x6_UNORM] = 0,
+ [XGL_FMT_ASTC_6x6_SRGB] = 0,
+ [XGL_FMT_ASTC_8x5_UNORM] = 0,
+ [XGL_FMT_ASTC_8x5_SRGB] = 0,
+ [XGL_FMT_ASTC_8x6_UNORM] = 0,
+ [XGL_FMT_ASTC_8x6_SRGB] = 0,
+ [XGL_FMT_ASTC_8x8_UNORM] = 0,
+ [XGL_FMT_ASTC_8x8_SRGB] = 0,
+ [XGL_FMT_ASTC_10x5_UNORM] = 0,
+ [XGL_FMT_ASTC_10x5_SRGB] = 0,
+ [XGL_FMT_ASTC_10x6_UNORM] = 0,
+ [XGL_FMT_ASTC_10x6_SRGB] = 0,
+ [XGL_FMT_ASTC_10x8_UNORM] = 0,
+ [XGL_FMT_ASTC_10x8_SRGB] = 0,
+ [XGL_FMT_ASTC_10x10_UNORM] = 0,
+ [XGL_FMT_ASTC_10x10_SRGB] = 0,
+ [XGL_FMT_ASTC_12x10_UNORM] = 0,
+ [XGL_FMT_ASTC_12x10_SRGB] = 0,
+ [XGL_FMT_ASTC_12x12_UNORM] = 0,
+ [XGL_FMT_ASTC_12x12_SRGB] = 0,
+ [XGL_FMT_B5G6R5_UNORM] = GEN6_FORMAT_B5G6R5_UNORM,
+ [XGL_FMT_B5G6R5_USCALED] = 0,
+ [XGL_FMT_B8G8R8_UNORM] = 0,
+ [XGL_FMT_B8G8R8_SNORM] = 0,
+ [XGL_FMT_B8G8R8_USCALED] = 0,
+ [XGL_FMT_B8G8R8_SSCALED] = 0,
+ [XGL_FMT_B8G8R8_UINT] = 0,
+ [XGL_FMT_B8G8R8_SINT] = 0,
+ [XGL_FMT_B8G8R8_SRGB] = GEN6_FORMAT_B5G6R5_UNORM_SRGB,
+ [XGL_FMT_B8G8R8A8_UNORM] = GEN6_FORMAT_B8G8R8A8_UNORM,
+ [XGL_FMT_B8G8R8A8_SNORM] = 0,
+ [XGL_FMT_B8G8R8A8_USCALED] = 0,
+ [XGL_FMT_B8G8R8A8_SSCALED] = 0,
+ [XGL_FMT_B8G8R8A8_UINT] = 0,
+ [XGL_FMT_B8G8R8A8_SINT] = 0,
+ [XGL_FMT_B8G8R8A8_SRGB] = GEN6_FORMAT_B8G8R8A8_UNORM_SRGB,
+ [XGL_FMT_B10G10R10A2_UNORM] = GEN6_FORMAT_B10G10R10A2_UNORM,
+ [XGL_FMT_B10G10R10A2_SNORM] = GEN6_FORMAT_B10G10R10A2_SNORM,
+ [XGL_FMT_B10G10R10A2_USCALED] = GEN6_FORMAT_B10G10R10A2_USCALED,
+ [XGL_FMT_B10G10R10A2_SSCALED] = GEN6_FORMAT_B10G10R10A2_SSCALED,
+ [XGL_FMT_B10G10R10A2_UINT] = GEN6_FORMAT_B10G10R10A2_UINT,
+ [XGL_FMT_B10G10R10A2_SINT] = GEN6_FORMAT_B10G10R10A2_SINT
};
int intel_format_translate_color(const struct intel_gpu *gpu,
{
int fmt;
- assert(format.numericFormat != XGL_NUM_FMT_UNDEFINED &&
- format.numericFormat != XGL_NUM_FMT_DS);
+ assert(!icd_format_is_undef(format));
+ assert(!icd_format_is_ds(format));
- fmt = intel_color_mapping[format.channelFormat][format.numericFormat - 1];
+ fmt = intel_color_mapping[format];
+ /* TODO: Implement for remaining compressed formats. */
/* GEN6_FORMAT_R32G32B32A32_FLOAT happens to be 0 */
- if (format.channelFormat == XGL_CH_FMT_R32G32B32A32 &&
- format.numericFormat == XGL_NUM_FMT_FLOAT)
+ if (format == XGL_FMT_R32G32B32A32_SFLOAT)
assert(fmt == 0);
else if (!fmt)
fmt = -1;
}
if (TEST(dev, sampler, sampling)) {
- if (format.numericFormat == XGL_NUM_FMT_UINT ||
- format.numericFormat == XGL_NUM_FMT_SINT ||
+ if (icd_format_is_int(format) ||
TEST(dev, sampler, filtering))
features |= XGL_FORMAT_IMAGE_SHADER_READ_BIT;
}
{
XGL_FLAGS features;
- assert(format.numericFormat == XGL_NUM_FMT_DS);
+ assert(icd_format_is_ds(format));
- switch (format.channelFormat) {
- case XGL_CH_FMT_R8:
+ switch (format) {
+ case XGL_FMT_S8_UINT:
features = XGL_FORMAT_STENCIL_ATTACHMENT_BIT;;
break;
- case XGL_CH_FMT_R16:
- case XGL_CH_FMT_R32:
+ case XGL_FMT_D16_UNORM:
+ case XGL_FMT_D24_UNORM:
+ case XGL_FMT_D32_SFLOAT:
features = XGL_FORMAT_DEPTH_ATTACHMENT_BIT;
break;
- case XGL_CH_FMT_R32G8:
+ case XGL_FMT_D16_UNORM_S8_UINT:
+ case XGL_FMT_D24_UNORM_S8_UINT:
+ case XGL_FMT_D32_SFLOAT_S8_UINT:
features = XGL_FORMAT_DEPTH_ATTACHMENT_BIT |
XGL_FORMAT_STENCIL_ATTACHMENT_BIT;
break;
static XGL_FLAGS intel_format_get_raw_features(const struct intel_dev *dev,
XGL_FORMAT format)
{
- assert(format.numericFormat == XGL_NUM_FMT_UNDEFINED);
-
- return (format.channelFormat == XGL_CH_FMT_UNDEFINED) ?
+ return (format == XGL_FMT_UNDEFINED) ?
XGL_FORMAT_MEMORY_SHADER_ACCESS_BIT : 0;
}
XGL_FORMAT format,
XGL_FORMAT_PROPERTIES *props)
{
- switch (format.numericFormat) {
- case XGL_NUM_FMT_UNDEFINED:
+ if (icd_format_is_undef(format)) {
props->linearTilingFeatures =
intel_format_get_raw_features(dev, format);
props->optimalTilingFeatures = 0;
- break;
- case XGL_NUM_FMT_UNORM:
- case XGL_NUM_FMT_SNORM:
- case XGL_NUM_FMT_UINT:
- case XGL_NUM_FMT_SINT:
- case XGL_NUM_FMT_FLOAT:
- case XGL_NUM_FMT_SRGB:
- case XGL_NUM_FMT_USCALED:
- case XGL_NUM_FMT_SSCALED:
+ } else if(icd_format_is_color(format)) {
props->linearTilingFeatures =
intel_format_get_color_features(dev, format);
props->optimalTilingFeatures = props->linearTilingFeatures;
- break;
- case XGL_NUM_FMT_DS:
+ } else if(icd_format_is_ds(format)) {
props->linearTilingFeatures = 0;
props->optimalTilingFeatures =
intel_format_get_ds_features(dev, format);
- break;
- default:
+ } else {
props->linearTilingFeatures = 0;
props->optimalTilingFeatures = 0;
- break;
}
}
static inline bool intel_format_is_depth(const struct intel_gpu *gpu,
XGL_FORMAT format)
{
- return (format.numericFormat == XGL_NUM_FMT_DS &&
- (format.channelFormat == XGL_CH_FMT_R16 ||
- format.channelFormat == XGL_CH_FMT_R32));
+ bool is_depth = false;
+
+ switch (format) {
+ case XGL_FMT_D16_UNORM:
+ case XGL_FMT_D24_UNORM:
+ case XGL_FMT_D32_SFLOAT:
+ is_depth = true;
+ break;
+ default:
+ break;
+ }
+
+ return is_depth;
}
static inline bool intel_format_is_stencil(const struct intel_gpu *gpu,
XGL_FORMAT format)
{
- return (format.numericFormat == XGL_NUM_FMT_DS &&
- format.channelFormat == XGL_CH_FMT_R8);
+ return format == XGL_FMT_S8_UINT;
}
int intel_format_translate_color(const struct intel_gpu *gpu,
}
s8_info = *info;
- s8_info.format.channelFormat = XGL_CH_FMT_R8;
- assert(info->format.numericFormat == XGL_NUM_FMT_DS);
+ s8_info.format = XGL_FMT_S8_UINT;
+ assert(icd_format_is_ds(info->format));
intel_layout_init(img->s8_layout, dev, &s8_info, scanout);
layout->align_j = layout->block_height;
} else if (info->usage & XGL_IMAGE_USAGE_DEPTH_STENCIL_BIT) {
if (intel_gpu_gen(params->gpu) >= INTEL_GEN(7)) {
- switch (layout->format.channelFormat) {
- case XGL_CH_FMT_R16:
+ switch (layout->format) {
+ case XGL_FMT_D16_UNORM:
layout->align_i = 8;
layout->align_j = 4;
break;
- case XGL_CH_FMT_R8:
+ case XGL_FMT_S8_UINT:
layout->align_i = 8;
layout->align_j = 8;
break;
break;
}
} else {
- switch (layout->format.channelFormat) {
- case XGL_CH_FMT_R8:
+ switch (layout->format) {
+ case XGL_FMT_S8_UINT:
layout->align_i = 4;
layout->align_j = 2;
break;
* "W-Major Tile Format is used for separate stencil."
*/
if (info->usage & XGL_IMAGE_USAGE_DEPTH_STENCIL_BIT) {
- switch (format.channelFormat) {
- case XGL_CH_FMT_R8:
+ switch (format) {
+ case XGL_FMT_S8_UINT:
valid_tilings &= LAYOUT_TILING_W;
break;
default:
require_separate_stencil = (layout->aux == INTEL_LAYOUT_AUX_HIZ);
}
- if (format.numericFormat == XGL_NUM_FMT_DS) {
- switch (format.channelFormat) {
- case XGL_CH_FMT_R32G8:
+ if (icd_format_is_ds(format)) {
+ switch (format) {
+ case XGL_FMT_D32_SFLOAT_S8_UINT:
if (require_separate_stencil) {
- format.channelFormat = XGL_CH_FMT_R32;
+ format = XGL_FMT_D32_SFLOAT;
layout->separate_stencil = true;
}
break;
* can result in incompatible formats.
*/
if (intel_gpu_gen(params->gpu) == INTEL_GEN(6) &&
- info->format.channelFormat == XGL_CH_FMT_R32G8 &&
+ info->format == XGL_FMT_D32_SFLOAT_S8_UINT &&
info->mipLevels > 1)
return false;
switch (layout->tiling) {
case INTEL_TILING_NONE:
/* W-tiled */
- if (layout->format.numericFormat == XGL_NUM_FMT_DS &&
- layout->format.channelFormat == XGL_CH_FMT_R8) {
+ if (layout->format == XGL_FMT_S8_UINT) {
tile_w = 64;
tile_h = 64;
}
switch (layout->tiling) {
case INTEL_TILING_NONE:
- if (layout->format.numericFormat == XGL_NUM_FMT_DS &&
- layout->format.channelFormat == XGL_CH_FMT_R8) {
+ if (layout->format == XGL_FMT_S8_UINT) {
/* W-tile */
tile_w = 64;
tile_h = 64;
*
* As for GEN7+, separate_stencil is always true.
*/
- switch (format.channelFormat) {
- case XGL_CH_FMT_R16:
+ switch (format) {
+ case XGL_FMT_D16_UNORM:
info->format = GEN6_ZFORMAT_D16_UNORM;
break;
- case XGL_CH_FMT_R32:
+ case XGL_FMT_D32_SFLOAT:
info->format = GEN6_ZFORMAT_D32_FLOAT;
break;
- case XGL_CH_FMT_R32G8:
+ case XGL_FMT_D32_SFLOAT_S8_UINT:
info->format = (separate_stencil) ?
GEN6_ZFORMAT_D32_FLOAT :
GEN6_ZFORMAT_D32_FLOAT_S8X24_UINT;
break;
- case XGL_CH_FMT_R8:
+ case XGL_FMT_S8_UINT:
if (separate_stencil) {
info->format = GEN6_ZFORMAT_D32_FLOAT;
break;
break;
}
- if (format.channelFormat != XGL_CH_FMT_R8)
+ if (format != XGL_FMT_S8_UINT)
info->zs.stride = img->layout.bo_stride;
if (img->s8_layout) {
intel_layout_pos_to_mem(img->s8_layout, x, y, &x, &y);
info->stencil.offset = intel_layout_mem_to_raw(img->s8_layout, x, y);
}
- } else if (format.channelFormat == XGL_CH_FMT_R8) {
+ } else if (format == XGL_FMT_S8_UINT) {
info->stencil.stride = img->layout.bo_stride * 2;
}
* must be XGL_FMT_R32G32B32A32_SFLOAT.
*/
if (info->viewType == XGL_BUFFER_VIEW_RAW) {
- format.channelFormat = XGL_CH_FMT_R32G32B32A32;
- format.numericFormat = XGL_NUM_FMT_FLOAT;
+ format = XGL_FMT_R32G32B32A32_SFLOAT;
stride = 16;
} else {
format = info->format;
XGL_FORMAT format)
{
/* this is what DDX expects */
- switch (format.channelFormat) {
- case XGL_CH_FMT_B5G6R5:
- if (format.numericFormat == XGL_NUM_FMT_UNORM)
- return true;
- break;
- case XGL_CH_FMT_B8G8R8A8:
- if (format.numericFormat == XGL_NUM_FMT_UNORM ||
- format.numericFormat == XGL_NUM_FMT_SRGB)
- return true;
- break;
+ switch (format) {
+ case XGL_FMT_B5G6R5_UNORM:
+ case XGL_FMT_B8G8R8A8_UNORM:
+ case XGL_FMT_B8G8R8A8_SRGB:
+ return true;
default:
- break;
+ return false;
}
-
- return false;
}
/**
#include "xglPlatform.h"
// XGL API version supported by this file
-#define XGL_API_VERSION XGL_MAKE_VERSION(0, 30, 7)
+#define XGL_API_VERSION XGL_MAKE_VERSION(0, 30, 8)
#ifdef __cplusplus
extern "C"
// ------------------------------------------------------------------------------------------------
// XGL format definitions
-typedef enum _XGL_CHANNEL_FORMAT
-{
- XGL_CH_FMT_UNDEFINED = 0,
- XGL_CH_FMT_R4G4 = 1,
- XGL_CH_FMT_R4G4B4A4 = 2,
- XGL_CH_FMT_R5G6B5 = 3,
- XGL_CH_FMT_B5G6R5 = 4,
- XGL_CH_FMT_R5G5B5A1 = 5,
- XGL_CH_FMT_R8 = 6,
- XGL_CH_FMT_R8G8 = 7,
- XGL_CH_FMT_R8G8B8A8 = 8,
- XGL_CH_FMT_B8G8R8A8 = 9,
- XGL_CH_FMT_R10G11B11 = 10,
- XGL_CH_FMT_R11G11B10 = 11,
- XGL_CH_FMT_R10G10B10A2 = 12,
- XGL_CH_FMT_R16 = 13,
- XGL_CH_FMT_R16G16 = 14,
- XGL_CH_FMT_R16G16B16A16 = 15,
- XGL_CH_FMT_R32 = 16,
- XGL_CH_FMT_R32G32 = 17,
- XGL_CH_FMT_R32G32B32 = 18,
- XGL_CH_FMT_R32G32B32A32 = 19,
- XGL_CH_FMT_R16G8 = 20,
- XGL_CH_FMT_R32G8 = 21,
- XGL_CH_FMT_R9G9B9E5 = 22,
- XGL_CH_FMT_BC1 = 23,
- XGL_CH_FMT_BC2 = 24,
- XGL_CH_FMT_BC3 = 25,
- XGL_CH_FMT_BC4 = 26,
- XGL_CH_FMT_BC5 = 27,
- XGL_CH_FMT_BC6U = 28,
- XGL_CH_FMT_BC6S = 29,
- XGL_CH_FMT_BC7 = 30,
- XGL_CH_FMT_R8G8B8 = 31,
- XGL_CH_FMT_R16G16B16 = 32,
- XGL_CH_FMT_B10G10R10A2 = 33,
- XGL_CH_FMT_R64 = 34, // Optional
- XGL_CH_FMT_R64G64 = 35, // Optional
- XGL_CH_FMT_R64G64B64 = 36, // Optional
- XGL_CH_FMT_R64G64B64A64 = 37, // Optional
- XGL_MAX_CH_FMT = XGL_CH_FMT_R64G64B64A64,
- XGL_MAX_ENUM(_XGL_CHANNEL_FORMAT)
-} XGL_CHANNEL_FORMAT;
-
-typedef enum _XGL_NUM_FORMAT
-{
- XGL_NUM_FMT_UNDEFINED = 0,
- XGL_NUM_FMT_UNORM = 1,
- XGL_NUM_FMT_SNORM = 2,
- XGL_NUM_FMT_UINT = 3,
- XGL_NUM_FMT_SINT = 4,
- XGL_NUM_FMT_FLOAT = 5,
- XGL_NUM_FMT_SRGB = 6,
- XGL_NUM_FMT_DS = 7,
- XGL_NUM_FMT_USCALED = 8,
- XGL_NUM_FMT_SSCALED = 9,
- XGL_MAX_NUM_FMT = XGL_NUM_FMT_SSCALED,
- XGL_MAX_ENUM(_XGL_NUM_FORMAT)
-} XGL_NUM_FORMAT;
typedef enum _XGL_VERTEX_INPUT_STEP_RATE
{
XGL_MAX_ENUM(_XGL_VERTEX_INPUT_STEP_RATE)
} XGL_VERTEX_INPUT_STEP_RATE;
-typedef struct _XGL_FORMAT
-{
- XGL_CHANNEL_FORMAT channelFormat;
- XGL_NUM_FORMAT numericFormat;
-
-// XGL_FMT_BEGIN_RANGE = XGL_FMT_UNDEFINED, ////LUGMAL
-// XGL_FMT_END_RANGE = XGL_FMT_ASTC_12x12_SRGB,
-// XGL_NUM_FMT = (XGL_FMT_END_RANGE - XGL_FMT_BEGIN_RANGE + 1),
+typedef enum _XGL_FORMAT
+{
+ XGL_FMT_UNDEFINED = 0x00000000,
+ XGL_FMT_R4G4_UNORM = 0x00000001,
+ XGL_FMT_R4G4_USCALED = 0x00000002,
+ XGL_FMT_R4G4B4A4_UNORM = 0x00000003,
+ XGL_FMT_R4G4B4A4_USCALED = 0x00000004,
+ XGL_FMT_R5G6B5_UNORM = 0x00000005,
+ XGL_FMT_R5G6B5_USCALED = 0x00000006,
+ XGL_FMT_R5G5B5A1_UNORM = 0x00000007,
+ XGL_FMT_R5G5B5A1_USCALED = 0x00000008,
+ XGL_FMT_R8_UNORM = 0x00000009,
+ XGL_FMT_R8_SNORM = 0x0000000A,
+ XGL_FMT_R8_USCALED = 0x0000000B,
+ XGL_FMT_R8_SSCALED = 0x0000000C,
+ XGL_FMT_R8_UINT = 0x0000000D,
+ XGL_FMT_R8_SINT = 0x0000000E,
+ XGL_FMT_R8_SRGB = 0x0000000F,
+ XGL_FMT_R8G8_UNORM = 0x00000010,
+ XGL_FMT_R8G8_SNORM = 0x00000011,
+ XGL_FMT_R8G8_USCALED = 0x00000012,
+ XGL_FMT_R8G8_SSCALED = 0x00000013,
+ XGL_FMT_R8G8_UINT = 0x00000014,
+ XGL_FMT_R8G8_SINT = 0x00000015,
+ XGL_FMT_R8G8_SRGB = 0x00000016,
+ XGL_FMT_R8G8B8_UNORM = 0x00000017,
+ XGL_FMT_R8G8B8_SNORM = 0x00000018,
+ XGL_FMT_R8G8B8_USCALED = 0x00000019,
+ XGL_FMT_R8G8B8_SSCALED = 0x0000001A,
+ XGL_FMT_R8G8B8_UINT = 0x0000001B,
+ XGL_FMT_R8G8B8_SINT = 0x0000001C,
+ XGL_FMT_R8G8B8_SRGB = 0x0000001D,
+ XGL_FMT_R8G8B8A8_UNORM = 0x0000001E,
+ XGL_FMT_R8G8B8A8_SNORM = 0x0000001F,
+ XGL_FMT_R8G8B8A8_USCALED = 0x00000020,
+ XGL_FMT_R8G8B8A8_SSCALED = 0x00000021,
+ XGL_FMT_R8G8B8A8_UINT = 0x00000022,
+ XGL_FMT_R8G8B8A8_SINT = 0x00000023,
+ XGL_FMT_R8G8B8A8_SRGB = 0x00000024,
+ XGL_FMT_R10G10B10A2_UNORM = 0x00000025,
+ XGL_FMT_R10G10B10A2_SNORM = 0x00000026,
+ XGL_FMT_R10G10B10A2_USCALED = 0x00000027,
+ XGL_FMT_R10G10B10A2_SSCALED = 0x00000028,
+ XGL_FMT_R10G10B10A2_UINT = 0x00000029,
+ XGL_FMT_R10G10B10A2_SINT = 0x0000002A,
+ XGL_FMT_R16_UNORM = 0x0000002B,
+ XGL_FMT_R16_SNORM = 0x0000002C,
+ XGL_FMT_R16_USCALED = 0x0000002D,
+ XGL_FMT_R16_SSCALED = 0x0000002E,
+ XGL_FMT_R16_UINT = 0x0000002F,
+ XGL_FMT_R16_SINT = 0x00000030,
+ XGL_FMT_R16_SFLOAT = 0x00000031,
+ XGL_FMT_R16G16_UNORM = 0x00000032,
+ XGL_FMT_R16G16_SNORM = 0x00000033,
+ XGL_FMT_R16G16_USCALED = 0x00000034,
+ XGL_FMT_R16G16_SSCALED = 0x00000035,
+ XGL_FMT_R16G16_UINT = 0x00000036,
+ XGL_FMT_R16G16_SINT = 0x00000037,
+ XGL_FMT_R16G16_SFLOAT = 0x00000038,
+ XGL_FMT_R16G16B16_UNORM = 0x00000039,
+ XGL_FMT_R16G16B16_SNORM = 0x0000003A,
+ XGL_FMT_R16G16B16_USCALED = 0x0000003B,
+ XGL_FMT_R16G16B16_SSCALED = 0x0000003C,
+ XGL_FMT_R16G16B16_UINT = 0x0000003D,
+ XGL_FMT_R16G16B16_SINT = 0x0000003E,
+ XGL_FMT_R16G16B16_SFLOAT = 0x0000003F,
+ XGL_FMT_R16G16B16A16_UNORM = 0x00000040,
+ XGL_FMT_R16G16B16A16_SNORM = 0x00000041,
+ XGL_FMT_R16G16B16A16_USCALED = 0x00000042,
+ XGL_FMT_R16G16B16A16_SSCALED = 0x00000043,
+ XGL_FMT_R16G16B16A16_UINT = 0x00000044,
+ XGL_FMT_R16G16B16A16_SINT = 0x00000045,
+ XGL_FMT_R16G16B16A16_SFLOAT = 0x00000046,
+ XGL_FMT_R32_UINT = 0x00000047,
+ XGL_FMT_R32_SINT = 0x00000048,
+ XGL_FMT_R32_SFLOAT = 0x00000049,
+ XGL_FMT_R32G32_UINT = 0x0000004A,
+ XGL_FMT_R32G32_SINT = 0x0000004B,
+ XGL_FMT_R32G32_SFLOAT = 0x0000004C,
+ XGL_FMT_R32G32B32_UINT = 0x0000004D,
+ XGL_FMT_R32G32B32_SINT = 0x0000004E,
+ XGL_FMT_R32G32B32_SFLOAT = 0x0000004F,
+ XGL_FMT_R32G32B32A32_UINT = 0x00000050,
+ XGL_FMT_R32G32B32A32_SINT = 0x00000051,
+ XGL_FMT_R32G32B32A32_SFLOAT = 0x00000052,
+ XGL_FMT_R64_SFLOAT = 0x00000053,
+ XGL_FMT_R64G64_SFLOAT = 0x00000054,
+ XGL_FMT_R64G64B64_SFLOAT = 0x00000055,
+ XGL_FMT_R64G64B64A64_SFLOAT = 0x00000056,
+ XGL_FMT_R11G11B10_UFLOAT = 0x00000057,
+ XGL_FMT_R9G9B9E5_UFLOAT = 0x00000058,
+ XGL_FMT_D16_UNORM = 0x00000059,
+ XGL_FMT_D24_UNORM = 0x0000005A,
+ XGL_FMT_D32_SFLOAT = 0x0000005B,
+ XGL_FMT_S8_UINT = 0x0000005C,
+ XGL_FMT_D16_UNORM_S8_UINT = 0x0000005D,
+ XGL_FMT_D24_UNORM_S8_UINT = 0x0000005E,
+ XGL_FMT_D32_SFLOAT_S8_UINT = 0x0000005F,
+ XGL_FMT_BC1_UNORM = 0x00000060,
+ XGL_FMT_BC1_SRGB = 0x00000061,
+ XGL_FMT_BC2_UNORM = 0x00000062,
+ XGL_FMT_BC2_SRGB = 0x00000063,
+ XGL_FMT_BC3_UNORM = 0x00000064,
+ XGL_FMT_BC3_SRGB = 0x00000065,
+ XGL_FMT_BC4_UNORM = 0x00000066,
+ XGL_FMT_BC4_SNORM = 0x00000067,
+ XGL_FMT_BC5_UNORM = 0x00000068,
+ XGL_FMT_BC5_SNORM = 0x00000069,
+ XGL_FMT_BC6H_UFLOAT = 0x0000006A,
+ XGL_FMT_BC6H_SFLOAT = 0x0000006B,
+ XGL_FMT_BC7_UNORM = 0x0000006C,
+ XGL_FMT_BC7_SRGB = 0x0000006D,
+ XGL_FMT_ETC2_R8G8B8_UNORM = 0x0000006E,
+ XGL_FMT_ETC2_R8G8B8A1_UNORM = 0x0000006F,
+ XGL_FMT_ETC2_R8G8B8A8_UNORM = 0x00000070,
+ XGL_FMT_EAC_R11_UNORM = 0x00000071,
+ XGL_FMT_EAC_R11_SNORM = 0x00000072,
+ XGL_FMT_EAC_R11G11_UNORM = 0x00000073,
+ XGL_FMT_EAC_R11G11_SNORM = 0x00000074,
+ XGL_FMT_ASTC_4x4_UNORM = 0x00000075,
+ XGL_FMT_ASTC_4x4_SRGB = 0x00000076,
+ XGL_FMT_ASTC_4x5_UNORM = 0x00000077,
+ XGL_FMT_ASTC_4x5_SRGB = 0x00000078,
+ XGL_FMT_ASTC_5x5_UNORM = 0x00000079,
+ XGL_FMT_ASTC_5x5_SRGB = 0x0000007A,
+ XGL_FMT_ASTC_6x5_UNORM = 0x0000007B,
+ XGL_FMT_ASTC_6x5_SRGB = 0x0000007C,
+ XGL_FMT_ASTC_6x6_UNORM = 0x0000007D,
+ XGL_FMT_ASTC_6x6_SRGB = 0x0000007E,
+ XGL_FMT_ASTC_8x5_UNORM = 0x0000007F,
+ XGL_FMT_ASTC_8x5_SRGB = 0x00000080,
+ XGL_FMT_ASTC_8x6_UNORM = 0x00000081,
+ XGL_FMT_ASTC_8x6_SRGB = 0x00000082,
+ XGL_FMT_ASTC_8x8_UNORM = 0x00000083,
+ XGL_FMT_ASTC_8x8_SRGB = 0x00000084,
+ XGL_FMT_ASTC_10x5_UNORM = 0x00000085,
+ XGL_FMT_ASTC_10x5_SRGB = 0x00000086,
+ XGL_FMT_ASTC_10x6_UNORM = 0x00000087,
+ XGL_FMT_ASTC_10x6_SRGB = 0x00000088,
+ XGL_FMT_ASTC_10x8_UNORM = 0x00000089,
+ XGL_FMT_ASTC_10x8_SRGB = 0x0000008A,
+ XGL_FMT_ASTC_10x10_UNORM = 0x0000008B,
+ XGL_FMT_ASTC_10x10_SRGB = 0x0000008C,
+ XGL_FMT_ASTC_12x10_UNORM = 0x0000008D,
+ XGL_FMT_ASTC_12x10_SRGB = 0x0000008E,
+ XGL_FMT_ASTC_12x12_UNORM = 0x0000008F,
+ XGL_FMT_ASTC_12x12_SRGB = 0x00000090,
+ XGL_FMT_B5G6R5_UNORM = 0x00000091,
+ XGL_FMT_B5G6R5_USCALED = 0x00000092,
+ XGL_FMT_B8G8R8_UNORM = 0x00000093,
+ XGL_FMT_B8G8R8_SNORM = 0x00000094,
+ XGL_FMT_B8G8R8_USCALED = 0x00000095,
+ XGL_FMT_B8G8R8_SSCALED = 0x00000096,
+ XGL_FMT_B8G8R8_UINT = 0x00000097,
+ XGL_FMT_B8G8R8_SINT = 0x00000098,
+ XGL_FMT_B8G8R8_SRGB = 0x00000099,
+ XGL_FMT_B8G8R8A8_UNORM = 0x0000009A,
+ XGL_FMT_B8G8R8A8_SNORM = 0x0000009B,
+ XGL_FMT_B8G8R8A8_USCALED = 0x0000009C,
+ XGL_FMT_B8G8R8A8_SSCALED = 0x0000009D,
+ XGL_FMT_B8G8R8A8_UINT = 0x0000009E,
+ XGL_FMT_B8G8R8A8_SINT = 0x0000009F,
+ XGL_FMT_B8G8R8A8_SRGB = 0x000000A0,
+ XGL_FMT_B10G10R10A2_UNORM = 0x000000A1,
+ XGL_FMT_B10G10R10A2_SNORM = 0x000000A2,
+ XGL_FMT_B10G10R10A2_USCALED = 0x000000A3,
+ XGL_FMT_B10G10R10A2_SSCALED = 0x000000A4,
+ XGL_FMT_B10G10R10A2_UINT = 0x000000A5,
+ XGL_FMT_B10G10R10A2_SINT = 0x000000A6,
+
+ XGL_FMT_BEGIN_RANGE = XGL_FMT_UNDEFINED,
+ XGL_FMT_END_RANGE = XGL_FMT_B10G10R10A2_SINT,
+ XGL_NUM_FMT = (XGL_FMT_END_RANGE - XGL_FMT_BEGIN_RANGE + 1),
+ XGL_MAX_ENUM(_XGL_FORMAT)
} XGL_FORMAT;
// Shader stage enumerant
region.imageExtent = Image::extent(info_.extent, lv);
if (info_.usage & XGL_IMAGE_USAGE_DEPTH_STENCIL_BIT) {
- if (info_.format.channelFormat != XGL_CH_FMT_R8) {
+ if (info_.format != XGL_FMT_S8_UINT) {
region.imageSubresource.aspect = XGL_IMAGE_ASPECT_DEPTH;
regions_.push_back(region);
}
- if (info_.format.channelFormat == XGL_CH_FMT_R16G8 ||
- info_.format.channelFormat == XGL_CH_FMT_R32G8 ||
- info_.format.channelFormat == XGL_CH_FMT_R8) {
+ if (info_.format == XGL_FMT_D16_UNORM_S8_UINT ||
+ info_.format == XGL_FMT_D32_SFLOAT_S8_UINT ||
+ info_.format == XGL_FMT_S8_UINT) {
region.imageSubresource.aspect = XGL_IMAGE_ASPECT_STENCIL;
regions_.push_back(region);
}
static const struct format_info {
XGL_SIZE size;
XGL_UINT channel_count;
- } format_table[XGL_MAX_CH_FMT + 1] = {
- [XGL_CH_FMT_UNDEFINED] = { 0, 0 },
- [XGL_CH_FMT_R4G4] = { 1, 2 },
- [XGL_CH_FMT_R4G4B4A4] = { 2, 4 },
- [XGL_CH_FMT_R5G6B5] = { 2, 3 },
- [XGL_CH_FMT_B5G6R5] = { 2, 3 },
- [XGL_CH_FMT_R5G5B5A1] = { 2, 4 },
- [XGL_CH_FMT_R8] = { 1, 1 },
- [XGL_CH_FMT_R8G8] = { 2, 2 },
- [XGL_CH_FMT_R8G8B8A8] = { 4, 4 },
- [XGL_CH_FMT_B8G8R8A8] = { 4, 4 },
- [XGL_CH_FMT_R10G11B11] = { 4, 3 },
- [XGL_CH_FMT_R11G11B10] = { 4, 3 },
- [XGL_CH_FMT_R10G10B10A2] = { 4, 4 },
- [XGL_CH_FMT_R16] = { 2, 1 },
- [XGL_CH_FMT_R16G16] = { 4, 2 },
- [XGL_CH_FMT_R16G16B16A16] = { 8, 4 },
- [XGL_CH_FMT_R32] = { 4, 1 },
- [XGL_CH_FMT_R32G32] = { 8, 2 },
- [XGL_CH_FMT_R32G32B32] = { 12, 3 },
- [XGL_CH_FMT_R32G32B32A32] = { 16, 4 },
- [XGL_CH_FMT_R16G8] = { 3, 2 },
- [XGL_CH_FMT_R32G8] = { 5, 2 },
- [XGL_CH_FMT_R9G9B9E5] = { 4, 3 },
- [XGL_CH_FMT_BC1] = { 8, 4 },
- [XGL_CH_FMT_BC2] = { 16, 4 },
- [XGL_CH_FMT_BC3] = { 16, 4 },
- [XGL_CH_FMT_BC4] = { 8, 4 },
- [XGL_CH_FMT_BC5] = { 16, 4 },
- [XGL_CH_FMT_BC6U] = { 16, 4 },
- [XGL_CH_FMT_BC6S] = { 16, 4 },
- [XGL_CH_FMT_BC7] = { 16, 4 },
- [XGL_CH_FMT_R8G8B8] = { 3, 3 },
- [XGL_CH_FMT_R16G16B16] = { 6, 3 },
- [XGL_CH_FMT_B10G10R10A2] = { 4, 4 },
- [XGL_CH_FMT_R64] = { 8, 1 },
- [XGL_CH_FMT_R64G64] = { 16, 2 },
- [XGL_CH_FMT_R64G64B64] = { 24, 3 },
- [XGL_CH_FMT_R64G64B64A64] = { 32, 4 },
+ } format_table[XGL_NUM_FMT] = {
+ [XGL_FMT_UNDEFINED] = { 0, 0 },
+ [XGL_FMT_R4G4_UNORM] = { 1, 2 },
+ [XGL_FMT_R4G4_USCALED] = { 1, 2 },
+ [XGL_FMT_R4G4B4A4_UNORM] = { 2, 4 },
+ [XGL_FMT_R4G4B4A4_USCALED] = { 2, 4 },
+ [XGL_FMT_R5G6B5_UNORM] = { 2, 3 },
+ [XGL_FMT_R5G6B5_USCALED] = { 2, 3 },
+ [XGL_FMT_R5G5B5A1_UNORM] = { 2, 4 },
+ [XGL_FMT_R5G5B5A1_USCALED] = { 2, 4 },
+ [XGL_FMT_R8_UNORM] = { 1, 1 },
+ [XGL_FMT_R8_SNORM] = { 1, 1 },
+ [XGL_FMT_R8_USCALED] = { 1, 1 },
+ [XGL_FMT_R8_SSCALED] = { 1, 1 },
+ [XGL_FMT_R8_UINT] = { 1, 1 },
+ [XGL_FMT_R8_SINT] = { 1, 1 },
+ [XGL_FMT_R8_SRGB] = { 1, 1 },
+ [XGL_FMT_R8G8_UNORM] = { 2, 2 },
+ [XGL_FMT_R8G8_SNORM] = { 2, 2 },
+ [XGL_FMT_R8G8_USCALED] = { 2, 2 },
+ [XGL_FMT_R8G8_SSCALED] = { 2, 2 },
+ [XGL_FMT_R8G8_UINT] = { 2, 2 },
+ [XGL_FMT_R8G8_SINT] = { 2, 2 },
+ [XGL_FMT_R8G8_SRGB] = { 2, 2 },
+ [XGL_FMT_R8G8B8_UNORM] = { 3, 3 },
+ [XGL_FMT_R8G8B8_SNORM] = { 3, 3 },
+ [XGL_FMT_R8G8B8_USCALED] = { 3, 3 },
+ [XGL_FMT_R8G8B8_SSCALED] = { 3, 3 },
+ [XGL_FMT_R8G8B8_UINT] = { 3, 3 },
+ [XGL_FMT_R8G8B8_SINT] = { 3, 3 },
+ [XGL_FMT_R8G8B8_SRGB] = { 3, 3 },
+ [XGL_FMT_R8G8B8A8_UNORM] = { 4, 4 },
+ [XGL_FMT_R8G8B8A8_SNORM] = { 4, 4 },
+ [XGL_FMT_R8G8B8A8_USCALED] = { 4, 4 },
+ [XGL_FMT_R8G8B8A8_SSCALED] = { 4, 4 },
+ [XGL_FMT_R8G8B8A8_UINT] = { 4, 4 },
+ [XGL_FMT_R8G8B8A8_SINT] = { 4, 4 },
+ [XGL_FMT_R8G8B8A8_SRGB] = { 4, 4 },
+ [XGL_FMT_R10G10B10A2_UNORM] = { 4, 4 },
+ [XGL_FMT_R10G10B10A2_SNORM] = { 4, 4 },
+ [XGL_FMT_R10G10B10A2_USCALED] = { 4, 4 },
+ [XGL_FMT_R10G10B10A2_SSCALED] = { 4, 4 },
+ [XGL_FMT_R10G10B10A2_UINT] = { 4, 4 },
+ [XGL_FMT_R10G10B10A2_SINT] = { 4, 4 },
+ [XGL_FMT_R16_UNORM] = { 2, 1 },
+ [XGL_FMT_R16_SNORM] = { 2, 1 },
+ [XGL_FMT_R16_USCALED] = { 2, 1 },
+ [XGL_FMT_R16_SSCALED] = { 2, 1 },
+ [XGL_FMT_R16_UINT] = { 2, 1 },
+ [XGL_FMT_R16_SINT] = { 2, 1 },
+ [XGL_FMT_R16_SFLOAT] = { 2, 1 },
+ [XGL_FMT_R16G16_UNORM] = { 4, 2 },
+ [XGL_FMT_R16G16_SNORM] = { 4, 2 },
+ [XGL_FMT_R16G16_USCALED] = { 4, 2 },
+ [XGL_FMT_R16G16_SSCALED] = { 4, 2 },
+ [XGL_FMT_R16G16_UINT] = { 4, 2 },
+ [XGL_FMT_R16G16_SINT] = { 4, 2 },
+ [XGL_FMT_R16G16_SFLOAT] = { 4, 2 },
+ [XGL_FMT_R16G16B16_UNORM] = { 6, 3 },
+ [XGL_FMT_R16G16B16_SNORM] = { 6, 3 },
+ [XGL_FMT_R16G16B16_USCALED] = { 6, 3 },
+ [XGL_FMT_R16G16B16_SSCALED] = { 6, 3 },
+ [XGL_FMT_R16G16B16_UINT] = { 6, 3 },
+ [XGL_FMT_R16G16B16_SINT] = { 6, 3 },
+ [XGL_FMT_R16G16B16_SFLOAT] = { 6, 3 },
+ [XGL_FMT_R16G16B16A16_UNORM] = { 8, 4 },
+ [XGL_FMT_R16G16B16A16_SNORM] = { 8, 4 },
+ [XGL_FMT_R16G16B16A16_USCALED] = { 8, 4 },
+ [XGL_FMT_R16G16B16A16_SSCALED] = { 8, 4 },
+ [XGL_FMT_R16G16B16A16_UINT] = { 8, 4 },
+ [XGL_FMT_R16G16B16A16_SINT] = { 8, 4 },
+ [XGL_FMT_R16G16B16A16_SFLOAT] = { 8, 4 },
+ [XGL_FMT_R32_UINT] = { 4, 1 },
+ [XGL_FMT_R32_SINT] = { 4, 1 },
+ [XGL_FMT_R32_SFLOAT] = { 4, 1 },
+ [XGL_FMT_R32G32_UINT] = { 8, 2 },
+ [XGL_FMT_R32G32_SINT] = { 8, 2 },
+ [XGL_FMT_R32G32_SFLOAT] = { 8, 2 },
+ [XGL_FMT_R32G32B32_UINT] = { 12, 3 },
+ [XGL_FMT_R32G32B32_SINT] = { 12, 3 },
+ [XGL_FMT_R32G32B32_SFLOAT] = { 12, 3 },
+ [XGL_FMT_R32G32B32A32_UINT] = { 16, 4 },
+ [XGL_FMT_R32G32B32A32_SINT] = { 16, 4 },
+ [XGL_FMT_R32G32B32A32_SFLOAT] = { 16, 4 },
+ [XGL_FMT_R64_SFLOAT] = { 8, 1 },
+ [XGL_FMT_R64G64_SFLOAT] = { 16, 2 },
+ [XGL_FMT_R64G64B64_SFLOAT] = { 24, 3 },
+ [XGL_FMT_R64G64B64A64_SFLOAT] = { 32, 4 },
+ [XGL_FMT_R11G11B10_UFLOAT] = { 4, 3 },
+ [XGL_FMT_R9G9B9E5_UFLOAT] = { 4, 3 },
+ [XGL_FMT_D16_UNORM] = { 2, 1 },
+ [XGL_FMT_D24_UNORM] = { 3, 1 },
+ [XGL_FMT_D32_SFLOAT] = { 4, 1 },
+ [XGL_FMT_S8_UINT] = { 1, 1 },
+ [XGL_FMT_D16_UNORM_S8_UINT] = { 3, 2 },
+ [XGL_FMT_D24_UNORM_S8_UINT] = { 4, 2 },
+ [XGL_FMT_D32_SFLOAT_S8_UINT] = { 4, 2 },
+ [XGL_FMT_BC1_UNORM] = { 8, 4 },
+ [XGL_FMT_BC1_SRGB] = { 8, 4 },
+ [XGL_FMT_BC2_UNORM] = { 16, 4 },
+ [XGL_FMT_BC2_SRGB] = { 16, 4 },
+ [XGL_FMT_BC3_UNORM] = { 16, 4 },
+ [XGL_FMT_BC3_SRGB] = { 16, 4 },
+ [XGL_FMT_BC4_UNORM] = { 8, 4 },
+ [XGL_FMT_BC4_SNORM] = { 8, 4 },
+ [XGL_FMT_BC5_UNORM] = { 16, 4 },
+ [XGL_FMT_BC5_SNORM] = { 16, 4 },
+ [XGL_FMT_BC6H_UFLOAT] = { 16, 4 },
+ [XGL_FMT_BC6H_SFLOAT] = { 16, 4 },
+ [XGL_FMT_BC7_UNORM] = { 16, 4 },
+ [XGL_FMT_BC7_SRGB] = { 16, 4 },
+ // TODO: Initialize remaining compressed formats.
+ [XGL_FMT_ETC2_R8G8B8_UNORM] = { 0, 0 },
+ [XGL_FMT_ETC2_R8G8B8A1_UNORM] = { 0, 0 },
+ [XGL_FMT_ETC2_R8G8B8A8_UNORM] = { 0, 0 },
+ [XGL_FMT_EAC_R11_UNORM] = { 0, 0 },
+ [XGL_FMT_EAC_R11_SNORM] = { 0, 0 },
+ [XGL_FMT_EAC_R11G11_UNORM] = { 0, 0 },
+ [XGL_FMT_EAC_R11G11_SNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_4x4_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_4x4_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_4x5_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_4x5_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_5x5_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_5x5_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_6x5_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_6x5_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_6x6_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_6x6_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_8x5_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_8x5_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_8x6_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_8x6_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_8x8_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_8x8_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_10x5_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_10x5_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_10x6_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_10x6_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_10x8_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_10x8_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_10x10_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_10x10_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_12x10_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_12x10_SRGB] = { 0, 0 },
+ [XGL_FMT_ASTC_12x12_UNORM] = { 0, 0 },
+ [XGL_FMT_ASTC_12x12_SRGB] = { 0, 0 },
+ [XGL_FMT_B5G6R5_UNORM] = { 2, 3 },
+ [XGL_FMT_B5G6R5_USCALED] = { 2, 3 },
+ [XGL_FMT_B8G8R8_UNORM] = { 3, 3 },
+ [XGL_FMT_B8G8R8_SNORM] = { 3, 3 },
+ [XGL_FMT_B8G8R8_USCALED] = { 3, 3 },
+ [XGL_FMT_B8G8R8_SSCALED] = { 3, 3 },
+ [XGL_FMT_B8G8R8_UINT] = { 3, 3 },
+ [XGL_FMT_B8G8R8_SINT] = { 3, 3 },
+ [XGL_FMT_B8G8R8_SRGB] = { 3, 3 },
+ [XGL_FMT_B8G8R8A8_UNORM] = { 4, 4 },
+ [XGL_FMT_B8G8R8A8_SNORM] = { 4, 4 },
+ [XGL_FMT_B8G8R8A8_USCALED] = { 4, 4 },
+ [XGL_FMT_B8G8R8A8_SSCALED] = { 4, 4 },
+ [XGL_FMT_B8G8R8A8_UINT] = { 4, 4 },
+ [XGL_FMT_B8G8R8A8_SINT] = { 4, 4 },
+ [XGL_FMT_B8G8R8A8_SRGB] = { 4, 4 },
+ [XGL_FMT_B10G10R10A2_UNORM] = { 4, 4 },
+ [XGL_FMT_B10G10R10A2_SNORM] = { 4, 4 },
+ [XGL_FMT_B10G10R10A2_USCALED] = { 4, 4 },
+ [XGL_FMT_B10G10R10A2_SSCALED] = { 4, 4 },
+ [XGL_FMT_B10G10R10A2_UINT] = { 4, 4 },
+ [XGL_FMT_B10G10R10A2_SINT] = { 4, 4 },
};
- return format_table[format.channelFormat].size;
+ return format_table[format].size;
}
XGL_EXTENT3D get_mip_level_extent(const XGL_EXTENT3D &extent, XGL_UINT mip_level)
protected:
void init_test_formats(XGL_FLAGS features)
{
- first_linear_format_.channelFormat = XGL_CH_FMT_UNDEFINED;
- first_linear_format_.numericFormat = XGL_NUM_FMT_UNDEFINED;
- first_optimal_format_.channelFormat = XGL_CH_FMT_UNDEFINED;
- first_optimal_format_.numericFormat = XGL_NUM_FMT_UNDEFINED;
+ first_linear_format_ = XGL_FMT_UNDEFINED;
+ first_optimal_format_ = XGL_FMT_UNDEFINED;
for (std::vector<xgl_testing::Device::Format>::const_iterator it = dev_.formats().begin();
it != dev_.formats().end(); it++) {
test_formats_.push_back(*it);
if (it->tiling == XGL_LINEAR_TILING &&
- first_linear_format_.channelFormat == XGL_CH_FMT_UNDEFINED)
+ first_linear_format_ == XGL_FMT_UNDEFINED)
first_linear_format_ = it->format;
if (it->tiling == XGL_OPTIMAL_TILING &&
- first_optimal_format_.channelFormat == XGL_CH_FMT_UNDEFINED)
+ first_optimal_format_ == XGL_FMT_UNDEFINED)
first_optimal_format_ = it->format;
}
}
{
for (std::vector<xgl_testing::Device::Format>::const_iterator it = test_formats_.begin();
it != test_formats_.end(); it++) {
+
+ // not sure what to do here
+ if (it->format == XGL_FMT_UNDEFINED ||
+ (it->format >= XGL_FMT_B8G8R8_UNORM &&
+ it->format <= XGL_FMT_B8G8R8_SRGB))
+ continue;
+
XGL_IMAGE_CREATE_INFO img_info = xgl_testing::Image::create_info();
img_info.imageType = XGL_IMAGE_2D;
img_info.format = it->format;
{
for (std::vector<xgl_testing::Device::Format>::const_iterator it = test_formats_.begin();
it != test_formats_.end(); it++) {
+
+ // not sure what to do here
+ if (it->format == XGL_FMT_UNDEFINED ||
+ (it->format >= XGL_FMT_B8G8R8_UNORM &&
+ it->format <= XGL_FMT_B8G8R8_SRGB))
+ continue;
+
XGL_IMAGE_CREATE_INFO img_info = xgl_testing::Image::create_info();
img_info.imageType = XGL_IMAGE_2D;
img_info.format = it->format;
{
for (std::vector<xgl_testing::Device::Format>::const_iterator it = test_formats_.begin();
it != test_formats_.end(); it++) {
+
+ // not sure what to do here
+ if (it->format == XGL_FMT_UNDEFINED ||
+ (it->format >= XGL_FMT_B8G8R8_UNORM &&
+ it->format <= XGL_FMT_B8G8R8_SRGB))
+ continue;
+
XGL_IMAGE_CREATE_INFO img_info = xgl_testing::Image::create_info();
img_info.imageType = XGL_IMAGE_2D;
img_info.format = it->format;
for (std::vector<xgl_testing::Device::Format>::const_iterator it = test_formats_.begin();
it != test_formats_.end(); it++) {
// not sure what to do here
- if (it->format.channelFormat == XGL_CH_FMT_UNDEFINED ||
- (it->format.channelFormat >= XGL_CH_FMT_BC1 &&
- it->format.channelFormat <= XGL_CH_FMT_BC7) ||
- it->format.channelFormat == XGL_CH_FMT_R64G64B64 ||
- it->format.channelFormat == XGL_CH_FMT_R64G64B64A64 ||
- it->format.numericFormat == XGL_NUM_FMT_DS)
+ if (it->format == XGL_FMT_UNDEFINED ||
+ (it->format >= XGL_FMT_R32G32B32_UINT &&
+ it->format <= XGL_FMT_R32G32B32_SFLOAT) ||
+ (it->format >= XGL_FMT_B8G8R8_UNORM &&
+ it->format <= XGL_FMT_B8G8R8_SRGB) ||
+ (it->format >= XGL_FMT_BC1_UNORM &&
+ it->format <= XGL_FMT_ASTC_12x12_SRGB) ||
+ (it->format >= XGL_FMT_D16_UNORM &&
+ it->format <= XGL_FMT_D32_SFLOAT_S8_UINT) ||
+ it->format == XGL_FMT_R64G64B64_SFLOAT ||
+ it->format == XGL_FMT_R64G64B64A64_SFLOAT)
continue;
XGL_IMAGE_CREATE_INFO img_info = xgl_testing::Image::create_info();
std::vector<uint8_t> raw;
// TODO support all formats
- if (format.numericFormat == XGL_NUM_FMT_UNORM) {
- switch (format.channelFormat) {
- case XGL_CH_FMT_R8G8B8A8:
- raw.push_back(color[0] * 255.0f);
- raw.push_back(color[1] * 255.0f);
- raw.push_back(color[2] * 255.0f);
- raw.push_back(color[3] * 255.0f);
- break;
- case XGL_CH_FMT_B8G8R8A8:
- raw.push_back(color[2] * 255.0f);
- raw.push_back(color[1] * 255.0f);
- raw.push_back(color[0] * 255.0f);
- raw.push_back(color[3] * 255.0f);
- break;
- default:
- break;
- }
+ switch (format) {
+ case XGL_FMT_R8G8B8A8_UNORM:
+ raw.push_back(color[0] * 255.0f);
+ raw.push_back(color[1] * 255.0f);
+ raw.push_back(color[2] * 255.0f);
+ raw.push_back(color[3] * 255.0f);
+ break;
+ case XGL_FMT_B8G8R8A8_UNORM:
+ raw.push_back(color[2] * 255.0f);
+ raw.push_back(color[1] * 255.0f);
+ raw.push_back(color[0] * 255.0f);
+ raw.push_back(color[3] * 255.0f);
+ break;
+ default:
+ break;
}
return raw;
std::vector<uint8_t> raw;
// TODO support all formats
- if (format.numericFormat == XGL_NUM_FMT_UNORM) {
- switch (format.channelFormat) {
- case XGL_CH_FMT_R8G8B8A8:
- raw.push_back(static_cast<uint8_t>(color[0]));
- raw.push_back(static_cast<uint8_t>(color[1]));
- raw.push_back(static_cast<uint8_t>(color[2]));
- raw.push_back(static_cast<uint8_t>(color[3]));
- break;
- case XGL_CH_FMT_B8G8R8A8:
- raw.push_back(static_cast<uint8_t>(color[2]));
- raw.push_back(static_cast<uint8_t>(color[1]));
- raw.push_back(static_cast<uint8_t>(color[0]));
- raw.push_back(static_cast<uint8_t>(color[3]));
- break;
- default:
- break;
- }
+ switch (format) {
+ case XGL_FMT_R8G8B8A8_UNORM:
+ raw.push_back(static_cast<uint8_t>(color[0]));
+ raw.push_back(static_cast<uint8_t>(color[1]));
+ raw.push_back(static_cast<uint8_t>(color[2]));
+ raw.push_back(static_cast<uint8_t>(color[3]));
+ break;
+ case XGL_FMT_B8G8R8A8_UNORM:
+ raw.push_back(static_cast<uint8_t>(color[2]));
+ raw.push_back(static_cast<uint8_t>(color[1]));
+ raw.push_back(static_cast<uint8_t>(color[0]));
+ raw.push_back(static_cast<uint8_t>(color[3]));
+ break;
+ default:
+ break;
}
return raw;
const XGL_UINT32 color[4] = { 0x11111111, 0x22222222, 0x33333333, 0x44444444 };
// not sure what to do here
- if (it->format.channelFormat == XGL_CH_FMT_UNDEFINED ||
- it->format.channelFormat == XGL_CH_FMT_R32G32B32 ||
- it->format.channelFormat == XGL_CH_FMT_R8G8B8 ||
- it->format.channelFormat == XGL_CH_FMT_R16G16B16 ||
- it->format.channelFormat == XGL_CH_FMT_R64G64B64 ||
- it->format.channelFormat == XGL_CH_FMT_R64G64B64A64 ||
- it->format.numericFormat == XGL_NUM_FMT_DS)
+ if (it->format == XGL_FMT_UNDEFINED ||
+ (it->format >= XGL_FMT_R8G8B8_UNORM &&
+ it->format <= XGL_FMT_R8G8B8_SRGB) ||
+ (it->format >= XGL_FMT_B8G8R8_UNORM &&
+ it->format <= XGL_FMT_B8G8R8_SRGB) ||
+ (it->format >= XGL_FMT_R16G16B16_UNORM &&
+ it->format <= XGL_FMT_R16G16B16_SFLOAT) ||
+ (it->format >= XGL_FMT_R32G32B32_UINT &&
+ it->format <= XGL_FMT_R32G32B32_SFLOAT) ||
+ it->format == XGL_FMT_R64G64B64_SFLOAT ||
+ it->format == XGL_FMT_R64G64B64A64_SFLOAT ||
+ (it->format >= XGL_FMT_D16_UNORM &&
+ it->format <= XGL_FMT_D32_SFLOAT_S8_UINT))
continue;
XGL_IMAGE_CREATE_INFO img_info = xgl_testing::Image::create_info();
std::vector<uint8_t> raw;
// depth
- switch (format.channelFormat) {
- case XGL_CH_FMT_R16:
- case XGL_CH_FMT_R16G8:
+ switch (format) {
+ case XGL_FMT_D16_UNORM:
+ case XGL_FMT_D16_UNORM_S8_UINT:
{
const uint16_t unorm = depth * 65535.0f;
raw.push_back(unorm & 0xff);
raw.push_back(unorm >> 8);
}
break;
- case XGL_CH_FMT_R32:
- case XGL_CH_FMT_R32G8:
+ case XGL_FMT_D32_SFLOAT:
+ case XGL_FMT_D32_SFLOAT_S8_UINT:
{
const union {
XGL_FLOAT depth;
}
// stencil
- switch (format.channelFormat) {
- case XGL_CH_FMT_R8:
+ switch (format) {
+ case XGL_FMT_S8_UINT:
raw.push_back(stencil);
break;
- case XGL_CH_FMT_R16G8:
+ case XGL_FMT_D16_UNORM_S8_UINT:
raw.push_back(stencil);
raw.push_back(0);
break;
- case XGL_CH_FMT_R32G8:
+ case XGL_FMT_D32_SFLOAT_S8_UINT:
raw.push_back(stencil);
raw.push_back(0);
raw.push_back(0);
for (std::vector<xgl_testing::Device::Format>::const_iterator it = test_formats_.begin();
it != test_formats_.end(); it++) {
// known driver issues
- if (it->format.channelFormat == XGL_CH_FMT_R8)
+ if (it->format == XGL_FMT_S8_UINT ||
+ it->format == XGL_FMT_D24_UNORM ||
+ it->format == XGL_FMT_D16_UNORM_S8_UINT ||
+ it->format == XGL_FMT_D24_UNORM_S8_UINT)
continue;
XGL_IMAGE_CREATE_INFO img_info = xgl_testing::Image::create_info();
mipCount++;
}
- fmt.channelFormat = XGL_CH_FMT_R8G8B8A8;
- fmt.numericFormat = XGL_NUM_FMT_UINT;
+ fmt = XGL_FMT_R8G8B8A8_UINT;
// TODO: Pick known good format rather than just expect common format
/*
* XXX: What should happen if given NULL HANDLE for the pData argument?
XGL_FORMAT fmt;
XGL_IMAGE_VIEW imageView;
- fmt.channelFormat = XGL_CH_FMT_R8G8B8A8;
- fmt.numericFormat = XGL_NUM_FMT_UINT;
+ fmt = XGL_FMT_R8G8B8A8_UINT;
CreateImage(512, 256);
mipCount++;
}
- fmt.channelFormat = XGL_CH_FMT_R8G8B8A8;
- fmt.numericFormat = XGL_NUM_FMT_UINT;
+ fmt = XGL_FMT_R8G8B8A8_UINT;
// TODO: Pick known good format rather than just expect common format
/*
* XXX: What should happen if given NULL HANDLE for the pData argument?
// Clean up default state created by framework
if (m_stateDepthStencil) xglDestroyObject(m_stateDepthStencil);
- m_depth_stencil_fmt.channelFormat = XGL_CH_FMT_R16;
- m_depth_stencil_fmt.numericFormat = XGL_NUM_FMT_DS;
+ m_depth_stencil_fmt = XGL_FMT_D16_UNORM;
image.sType = XGL_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
image.pNext = NULL;
XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION vi_attribs[2];
vi_attribs[0].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[0].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[0].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[0].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[0].offsetInBytes = 0; // Offset of first element in bytes from base of vertex
vi_attribs[1].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[1].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[1].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[1].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[1].offsetInBytes = 16; // Offset of first element in bytes from base of vertex
pipelineobj.AddVertexInputAttribs(vi_attribs,2);
XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION vi_attrib;
vi_attrib.binding = 0; // index into vertexBindingDescriptions
- vi_attrib.format.channelFormat = XGL_CH_FMT_R32G32; // format of source data
- vi_attrib.format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attrib.format = XGL_FMT_R32G32_SFLOAT; // format of source data
vi_attrib.offsetInBytes = 0; // Offset of first element in bytes from base of vertex
pipelineobj.AddVertexInputAttribs(&vi_attrib, 1);
XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION vi_attribs[2];
vi_attribs[0].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[0].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[0].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[0].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[0].offsetInBytes = 0; // Offset of first element in bytes from base of vertex
vi_attribs[1].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[1].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[1].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[1].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[1].offsetInBytes = 16; // Offset of first element in bytes from base of vertex
pipelineobj.AddVertexInputAttribs(vi_attribs,2);
XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION vi_attribs[2];
vi_attribs[0].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[0].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[0].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[0].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[0].offsetInBytes = 0; // Offset of first element in bytes from base of vertex
vi_attribs[1].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[1].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[1].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[1].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[1].offsetInBytes = 16; // Offset of first element in bytes from base of vertex
pipelineobj.AddVertexInputAttribs(vi_attribs,2);
XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION vi_attribs[2];
vi_attribs[0].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[0].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[0].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[0].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[0].offsetInBytes = 0; // Offset of first element in bytes from base of vertex
vi_attribs[1].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[1].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[1].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[1].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[1].offsetInBytes = 16; // Offset of first element in bytes from base of vertex
pipelineobj.AddVertexInputAttribs(vi_attribs,2);
XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION vi_attribs[2];
vi_attribs[0].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[0].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[0].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[0].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[0].offsetInBytes = 0; // Offset of first element in bytes from base of vertex
vi_attribs[1].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[1].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[1].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[1].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[1].offsetInBytes = 16; // Offset of first element in bytes from base of vertex
pipelineobj.AddVertexInputAttribs(vi_attribs,2);
XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION vi_attribs[2];
vi_attribs[0].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[0].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[0].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[0].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[0].offsetInBytes = 0; // Offset of first element in bytes from base of vertex
vi_attribs[1].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[1].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[1].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[1].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[1].offsetInBytes = 16; // Offset of first element in bytes from base of vertex
pipelineobj.AddVertexInputAttribs(vi_attribs,2);
XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION vi_attribs[2];
vi_attribs[0].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[0].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[0].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[0].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[0].offsetInBytes = 0; // Offset of first element in bytes from base of vertex
vi_attribs[1].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[1].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[1].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[1].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[1].offsetInBytes = 16; // Offset of first element in bytes from base of vertex
pipelineobj.AddVertexInputAttribs(vi_attribs,2);
XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION vi_attribs[2];
vi_attribs[0].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[0].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[0].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[0].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[0].offsetInBytes = 0; // Offset of first element in bytes from base of vertex
vi_attribs[1].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[1].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[1].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[1].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[1].offsetInBytes = 16; // Offset of first element in bytes from base of vertex
pipelineobj.AddVertexInputAttribs(vi_attribs,2);
ds_state.back.stencilFailOp = XGL_STENCIL_OP_KEEP;
ds_state.back.stencilPassOp = XGL_STENCIL_OP_KEEP;
ds_state.back.stencilFunc = XGL_COMPARE_ALWAYS;
- ds_state.format.channelFormat = XGL_CH_FMT_R32;
- ds_state.format.numericFormat = XGL_NUM_FMT_DS;
+ ds_state.format = XGL_FMT_D32_SFLOAT;
ds_state.front = ds_state.back;
pipelineobj.SetDepthStencil(&ds_state);
// this is the current description of g_vbData
XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION vi_attribs[2];
vi_attribs[0].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[0].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[0].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[0].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[0].offsetInBytes = 0; // Offset of first element in bytes from base of vertex
vi_attribs[1].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[1].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[1].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[1].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[1].offsetInBytes = 16; // Offset of first element in bytes from base of vertex
pipelineobj.AddVertexInputBindings(&vi_binding,1);
// this is the current description of g_vbData
XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION vi_attribs[2];
vi_attribs[0].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[0].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[0].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[0].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[0].offsetInBytes = 0; // Offset of first element in bytes from base of vertex
vi_attribs[1].binding = 0; // index into vertexBindingDescriptions
- vi_attribs[1].format.channelFormat = XGL_CH_FMT_R32G32B32A32; // format of source data
- vi_attribs[1].format.numericFormat = XGL_NUM_FMT_FLOAT;
+ vi_attribs[1].format = XGL_FMT_R32G32B32A32_SFLOAT; // format of source data
vi_attribs[1].offsetInBytes = 16; // Offset of first element in bytes from base of vertex
pipelineobj.AddVertexInputBindings(&vi_binding,1);
ds_state.back.stencilFailOp = XGL_STENCIL_OP_KEEP;
ds_state.back.stencilPassOp = XGL_STENCIL_OP_KEEP;
ds_state.back.stencilFunc = XGL_COMPARE_ALWAYS;
- ds_state.format.channelFormat = XGL_CH_FMT_R32;
- ds_state.format.numericFormat = XGL_NUM_FMT_DS;
+ ds_state.format = XGL_FMT_D32_SFLOAT;
ds_state.front = ds_state.back;
pipelineobj.SetDepthStencil(&ds_state);
{
m_renderTargetCount = 1;
- m_render_target_fmt.channelFormat = XGL_CH_FMT_R8G8B8A8;
- m_render_target_fmt.numericFormat = XGL_NUM_FMT_UNORM;
+ m_render_target_fmt = XGL_FMT_R8G8B8A8_UNORM;
m_depthStencilBinding.view = XGL_NULL_HANDLE;
}
{
XGL_RESULT err;
- m_render_target_fmt.channelFormat = XGL_CH_FMT_R8G8B8A8;
- m_render_target_fmt.numericFormat = XGL_NUM_FMT_UNORM;
+ m_render_target_fmt = XGL_FMT_R8G8B8A8_UNORM;
// create a raster state (solid, back-face culling)
XGL_DYNAMIC_RS_STATE_CREATE_INFO raster = {};
XGL_STRUCTURE_TYPE_COLOR_ATTACHMENT_VIEW_CREATE_INFO,
XGL_NULL_HANDLE,
obj(),
- {XGL_CH_FMT_R8G8B8A8, XGL_NUM_FMT_UNORM},
+ XGL_FMT_R8G8B8A8_UNORM,
0,
0,
1
XglTextureObj::XglTextureObj(XglDevice *device)
{
m_device = device;
- const XGL_FORMAT tex_format = { XGL_CH_FMT_B8G8R8A8, XGL_NUM_FMT_UNORM };
+ const XGL_FORMAT tex_format = XGL_FMT_B8G8R8A8_UNORM;
const uint32_t tex_colors[2] = { 0xffff0000, 0xff00ff00 };
memset(&m_textureViewInfo,0,sizeof(m_textureViewInfo));
m_numVertices = numIndexes;
m_indexType = indexType;
- viewFormat.numericFormat = XGL_NUM_FMT_UINT;
switch (indexType) {
case XGL_INDEX_8:
m_stride = 1;
- viewFormat.channelFormat = XGL_CH_FMT_R8;
+ viewFormat = XGL_FMT_R8_UINT;
break;
case XGL_INDEX_16:
m_stride = 2;
- viewFormat.channelFormat = XGL_CH_FMT_R16;
+ viewFormat = XGL_FMT_R16_UINT;
break;
case XGL_INDEX_32:
m_stride = 4;
- viewFormat.channelFormat = XGL_CH_FMT_R32;
+ viewFormat = XGL_FMT_R32_UINT;
break;
default:
assert(!"unknown index type");
view_info.buffer = obj();
view_info.viewType = XGL_BUFFER_VIEW_TYPED;
view_info.stride = m_stride;
- view_info.format.channelFormat = viewFormat.channelFormat;
- view_info.format.numericFormat = viewFormat.numericFormat;
+ view_info.format = viewFormat;
view_info.channels.r = XGL_CHANNEL_SWIZZLE_R;
view_info.channels.g = XGL_CHANNEL_SWIZZLE_G;
view_info.channels.b = XGL_CHANNEL_SWIZZLE_B;
m_ds_state.sType = XGL_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO;
m_ds_state.pNext = &m_ms_state,
- m_ds_state.format.channelFormat = XGL_CH_FMT_R32;
- m_ds_state.format.numericFormat = XGL_NUM_FMT_DS;
+ m_ds_state.format = XGL_FMT_D32_SFLOAT;
m_ds_state.depthTestEnable = XGL_FALSE;
m_ds_state.depthWriteEnable = XGL_FALSE;
m_ds_state.depthBoundsEnable = XGL_FALSE;
XGL_PIPELINE_CB_ATTACHMENT_STATE att = {};
att.blendEnable = XGL_FALSE;
- att.format.channelFormat = XGL_CH_FMT_R8G8B8A8;
- att.format.numericFormat = XGL_NUM_FMT_UNORM;
+ att.format = XGL_FMT_R8G8B8A8_UNORM;
att.channelWriteMask = 0xf;
AddColorAttachment(0, &att);
void Device::init_formats()
{
- for (int ch = XGL_CH_FMT_UNDEFINED; ch <= XGL_MAX_CH_FMT; ch++) {
- for (int num = XGL_NUM_FMT_UNDEFINED; num <= XGL_MAX_NUM_FMT; num++) {
- const XGL_FORMAT fmt = { static_cast<XGL_CHANNEL_FORMAT>(ch),
- static_cast<XGL_NUM_FORMAT>(num) };
- const XGL_FORMAT_PROPERTIES props = format_properties(fmt);
-
- if (props.linearTilingFeatures) {
- const Format tmp = { fmt, XGL_LINEAR_TILING, props.linearTilingFeatures };
- formats_.push_back(tmp);
- }
-
- if (props.optimalTilingFeatures) {
- const Format tmp = { fmt, XGL_OPTIMAL_TILING, props.optimalTilingFeatures };
- formats_.push_back(tmp);
- }
+ for (int f = XGL_FMT_BEGIN_RANGE; f <= XGL_FMT_END_RANGE; f++) {
+ const XGL_FORMAT fmt = static_cast<XGL_FORMAT>(f);
+ const XGL_FORMAT_PROPERTIES props = format_properties(fmt);
+
+ if (props.linearTilingFeatures) {
+ const Format tmp = { fmt, XGL_LINEAR_TILING, props.linearTilingFeatures };
+ formats_.push_back(tmp);
+ }
+
+ if (props.optimalTilingFeatures) {
+ const Format tmp = { fmt, XGL_OPTIMAL_TILING, props.optimalTilingFeatures };
+ formats_.push_back(tmp);
}
}