#include "util/format_rgb9e5.h"
#include "vulkan/util/vk_format.h"
-uint32_t radv_translate_buffer_dataformat(const struct vk_format_description *desc,
+uint32_t radv_translate_buffer_dataformat(const struct util_format_description *desc,
int first_non_void)
{
unsigned type;
assert(util_format_get_num_planes(desc->format) == 1);
- if (desc->format == VK_FORMAT_B10G11R11_UFLOAT_PACK32)
+ if (desc->format == PIPE_FORMAT_R11G11B10_FLOAT)
return V_008F0C_BUF_DATA_FORMAT_10_11_11;
if (first_non_void < 0)
return V_008F0C_BUF_DATA_FORMAT_INVALID;
type = desc->channel[first_non_void].type;
- if (type == VK_FORMAT_TYPE_FIXED)
+ if (type == UTIL_FORMAT_TYPE_FIXED)
return V_008F0C_BUF_DATA_FORMAT_INVALID;
if (desc->nr_channels == 4 &&
desc->channel[0].size == 10 &&
* 'Memory reads of data in memory that is 32 or 64 bits do not
* undergo any format conversion.'
*/
- if (type != VK_FORMAT_TYPE_FLOAT &&
+ if (type != UTIL_FORMAT_TYPE_FLOAT &&
!desc->channel[first_non_void].pure_integer)
return V_008F0C_BUF_DATA_FORMAT_INVALID;
return V_008F0C_BUF_DATA_FORMAT_INVALID;
}
-uint32_t radv_translate_buffer_numformat(const struct vk_format_description *desc,
+uint32_t radv_translate_buffer_numformat(const struct util_format_description *desc,
int first_non_void)
{
assert(util_format_get_num_planes(desc->format) == 1);
- if (desc->format == VK_FORMAT_B10G11R11_UFLOAT_PACK32)
+ if (desc->format == PIPE_FORMAT_R11G11B10_FLOAT)
return V_008F0C_BUF_NUM_FORMAT_FLOAT;
if (first_non_void < 0)
return ~0;
switch (desc->channel[first_non_void].type) {
- case VK_FORMAT_TYPE_SIGNED:
+ case UTIL_FORMAT_TYPE_SIGNED:
if (desc->channel[first_non_void].normalized)
return V_008F0C_BUF_NUM_FORMAT_SNORM;
else if (desc->channel[first_non_void].pure_integer)
else
return V_008F0C_BUF_NUM_FORMAT_SSCALED;
break;
- case VK_FORMAT_TYPE_UNSIGNED:
+ case UTIL_FORMAT_TYPE_UNSIGNED:
if (desc->channel[first_non_void].normalized)
return V_008F0C_BUF_NUM_FORMAT_UNORM;
else if (desc->channel[first_non_void].pure_integer)
else
return V_008F0C_BUF_NUM_FORMAT_USCALED;
break;
- case VK_FORMAT_TYPE_FLOAT:
+ case UTIL_FORMAT_TYPE_FLOAT:
default:
return V_008F0C_BUF_NUM_FORMAT_FLOAT;
}
}
uint32_t radv_translate_tex_dataformat(VkFormat format,
- const struct vk_format_description *desc,
+ const struct util_format_description *desc,
int first_non_void)
{
bool uniform = true;
/* Colorspace (return non-RGB formats directly). */
switch (desc->colorspace) {
/* Depth stencil formats */
- case VK_FORMAT_COLORSPACE_ZS:
+ case UTIL_FORMAT_COLORSPACE_ZS:
switch (format) {
case VK_FORMAT_D16_UNORM:
return V_008F14_IMG_DATA_FORMAT_16;
goto out_unknown;
}
- case VK_FORMAT_COLORSPACE_YUV:
+ case UTIL_FORMAT_COLORSPACE_YUV:
goto out_unknown; /* TODO */
- case VK_FORMAT_COLORSPACE_SRGB:
+ case UTIL_FORMAT_COLORSPACE_SRGB:
if (desc->nr_channels != 4 && desc->nr_channels != 1)
goto out_unknown;
break;
break;
}
- if (desc->layout == VK_FORMAT_LAYOUT_SUBSAMPLED) {
+ if (desc->layout == UTIL_FORMAT_LAYOUT_SUBSAMPLED) {
switch(format) {
/* Don't ask me why this looks inverted. PAL does the same. */
case VK_FORMAT_G8B8G8R8_422_UNORM:
}
}
- if (desc->layout == VK_FORMAT_LAYOUT_RGTC) {
+ if (desc->layout == UTIL_FORMAT_LAYOUT_RGTC) {
switch(format) {
case VK_FORMAT_BC4_UNORM_BLOCK:
case VK_FORMAT_BC4_SNORM_BLOCK:
}
}
- if (desc->layout == VK_FORMAT_LAYOUT_S3TC) {
+ if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
switch(format) {
case VK_FORMAT_BC1_RGB_UNORM_BLOCK:
case VK_FORMAT_BC1_RGB_SRGB_BLOCK:
}
}
- if (desc->layout == VK_FORMAT_LAYOUT_BPTC) {
+ if (desc->layout == UTIL_FORMAT_LAYOUT_BPTC) {
switch(format) {
case VK_FORMAT_BC6H_UFLOAT_BLOCK:
case VK_FORMAT_BC6H_SFLOAT_BLOCK:
}
}
- if (desc->layout == VK_FORMAT_LAYOUT_ETC) {
+ if (desc->layout == UTIL_FORMAT_LAYOUT_ETC) {
switch (format) {
case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK:
/* hw cannot support mixed formats (except depth/stencil, since only
* depth is read).*/
- if (desc->is_mixed && desc->colorspace != VK_FORMAT_COLORSPACE_ZS)
+ if (desc->is_mixed && desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS)
goto out_unknown;
/* See whether the components are of the same size. */
desc->channel[2].size == 10 &&
desc->channel[3].size == 2) {
/* Closed VK driver does this also no 2/10/10/10 snorm */
- if (desc->channel[0].type == VK_FORMAT_TYPE_SIGNED &&
+ if (desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED &&
desc->channel[0].normalized)
goto out_unknown;
return V_008F14_IMG_DATA_FORMAT_2_10_10_10;
}
uint32_t radv_translate_tex_numformat(VkFormat format,
- const struct vk_format_description *desc,
+ const struct util_format_description *desc,
int first_non_void)
{
assert(vk_format_get_plane_count(format) == 1);
default:
return V_008F14_IMG_NUM_FORMAT_UNORM;
}
- } else if (desc->layout == VK_FORMAT_LAYOUT_SUBSAMPLED) {
+ } else if (desc->layout == UTIL_FORMAT_LAYOUT_SUBSAMPLED) {
return V_008F14_IMG_NUM_FORMAT_UNORM;
} else {
return V_008F14_IMG_NUM_FORMAT_FLOAT;
}
- } else if (desc->colorspace == VK_FORMAT_COLORSPACE_SRGB) {
+ } else if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
return V_008F14_IMG_NUM_FORMAT_SRGB;
} else {
switch (desc->channel[first_non_void].type) {
- case VK_FORMAT_TYPE_FLOAT:
+ case UTIL_FORMAT_TYPE_FLOAT:
return V_008F14_IMG_NUM_FORMAT_FLOAT;
- case VK_FORMAT_TYPE_SIGNED:
+ case UTIL_FORMAT_TYPE_SIGNED:
if (desc->channel[first_non_void].normalized)
return V_008F14_IMG_NUM_FORMAT_SNORM;
else if (desc->channel[first_non_void].pure_integer)
return V_008F14_IMG_NUM_FORMAT_SINT;
else
return V_008F14_IMG_NUM_FORMAT_SSCALED;
- case VK_FORMAT_TYPE_UNSIGNED:
+ case UTIL_FORMAT_TYPE_UNSIGNED:
if (desc->channel[first_non_void].normalized)
return V_008F14_IMG_NUM_FORMAT_UNORM;
else if (desc->channel[first_non_void].pure_integer)
}
uint32_t radv_translate_color_numformat(VkFormat format,
- const struct vk_format_description *desc,
+ const struct util_format_description *desc,
int first_non_void)
{
unsigned ntype;
assert(vk_format_get_plane_count(format) == 1);
- if (first_non_void == -1 || desc->channel[first_non_void].type == VK_FORMAT_TYPE_FLOAT)
+ if (first_non_void == -1 || desc->channel[first_non_void].type == UTIL_FORMAT_TYPE_FLOAT)
ntype = V_028C70_NUMBER_FLOAT;
else {
ntype = V_028C70_NUMBER_UNORM;
- if (desc->colorspace == VK_FORMAT_COLORSPACE_SRGB)
+ if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB)
ntype = V_028C70_NUMBER_SRGB;
- else if (desc->channel[first_non_void].type == VK_FORMAT_TYPE_SIGNED) {
+ else if (desc->channel[first_non_void].type == UTIL_FORMAT_TYPE_SIGNED) {
if (desc->channel[first_non_void].pure_integer) {
ntype = V_028C70_NUMBER_SINT;
} else if (desc->channel[first_non_void].normalized) {
ntype = V_028C70_NUMBER_SNORM;
} else
ntype = ~0u;
- } else if (desc->channel[first_non_void].type == VK_FORMAT_TYPE_UNSIGNED) {
+ } else if (desc->channel[first_non_void].type == UTIL_FORMAT_TYPE_UNSIGNED) {
if (desc->channel[first_non_void].pure_integer) {
ntype = V_028C70_NUMBER_UINT;
} else if (desc->channel[first_non_void].normalized) {
static bool radv_is_sampler_format_supported(VkFormat format, bool *linear_sampling)
{
- const struct vk_format_description *desc = vk_format_description(format);
+ const struct util_format_description *desc = vk_format_description(format);
uint32_t num_format;
if (!desc || format == VK_FORMAT_UNDEFINED ||
format == VK_FORMAT_R64_UINT || format == VK_FORMAT_R64_SINT)
static bool radv_is_storage_image_format_supported(struct radv_physical_device *physical_device,
VkFormat format)
{
- const struct vk_format_description *desc = vk_format_description(format);
+ const struct util_format_description *desc = vk_format_description(format);
unsigned data_format, num_format;
if (!desc || format == VK_FORMAT_UNDEFINED)
return false;
bool radv_is_buffer_format_supported(VkFormat format, bool *scaled)
{
- const struct vk_format_description *desc = vk_format_description(format);
+ const struct util_format_description *desc = vk_format_description(format);
unsigned data_format, num_format;
if (!desc || format == VK_FORMAT_UNDEFINED)
return false;
bool radv_is_colorbuffer_format_supported(const struct radv_physical_device *pdevice,
VkFormat format, bool *blendable)
{
- const struct vk_format_description *desc = vk_format_description(format);
+ const struct util_format_description *desc = vk_format_description(format);
uint32_t color_format = radv_translate_colorformat(format);
uint32_t color_swap = radv_translate_colorswap(format, false);
uint32_t color_num_format = radv_translate_color_numformat(format,
VkFormatProperties *out_properties)
{
VkFormatFeatureFlags linear = 0, tiled = 0, buffer = 0;
- const struct vk_format_description *desc = vk_format_description(format);
+ const struct util_format_description *desc = vk_format_description(format);
bool blendable;
bool scaled = false;
/* TODO: implement some software emulation of SUBSAMPLED formats. */
if (!desc || vk_format_to_pipe_format(format) == PIPE_FORMAT_NONE ||
- desc->layout == VK_FORMAT_LAYOUT_SUBSAMPLED) {
+ desc->layout == UTIL_FORMAT_LAYOUT_SUBSAMPLED) {
out_properties->linearTilingFeatures = linear;
out_properties->optimalTilingFeatures = tiled;
out_properties->bufferFeatures = buffer;
return;
}
- if (desc->layout == VK_FORMAT_LAYOUT_ETC &&
+ if (desc->layout == UTIL_FORMAT_LAYOUT_ETC &&
!radv_device_supports_etc(physical_device)) {
out_properties->linearTilingFeatures = linear;
out_properties->optimalTilingFeatures = tiled;
}
if (vk_format_get_plane_count(format) > 1 ||
- desc->layout == VK_FORMAT_LAYOUT_SUBSAMPLED) {
+ desc->layout == UTIL_FORMAT_LAYOUT_SUBSAMPLED) {
uint32_t tiling = VK_FORMAT_FEATURE_TRANSFER_SRC_BIT |
VK_FORMAT_FEATURE_TRANSFER_DST_BIT |
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT |
VK_FORMAT_FEATURE_MIDPOINT_CHROMA_SAMPLES_BIT;
/* The subsampled formats have no support for linear filters. */
- if (desc->layout != VK_FORMAT_LAYOUT_SUBSAMPLED) {
+ if (desc->layout != UTIL_FORMAT_LAYOUT_SUBSAMPLED) {
tiling |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_YCBCR_CONVERSION_LINEAR_FILTER_BIT;
}
/* Fails for unknown reasons with linear tiling & subsampled formats. */
- out_properties->linearTilingFeatures = desc->layout == VK_FORMAT_LAYOUT_SUBSAMPLED ? 0 : tiling;
+ out_properties->linearTilingFeatures = desc->layout == UTIL_FORMAT_LAYOUT_SUBSAMPLED ? 0 : tiling;
out_properties->optimalTilingFeatures = tiling;
out_properties->bufferFeatures = 0;
return;
uint32_t radv_translate_colorformat(VkFormat format)
{
- const struct vk_format_description *desc = vk_format_description(format);
+ const struct util_format_description *desc = vk_format_description(format);
#define HAS_SIZE(x,y,z,w) \
(desc->channel[0].size == (x) && desc->channel[1].size == (y) && \
if (format == VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)
return V_028C70_COLOR_5_9_9_9;
- if (desc->layout != VK_FORMAT_LAYOUT_PLAIN)
+ if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN)
return V_028C70_COLOR_INVALID;
/* hw cannot support mixed formats (except depth/stencil, since
* stencil is not written to). */
- if (desc->is_mixed && desc->colorspace != VK_FORMAT_COLORSPACE_ZS)
+ if (desc->is_mixed && desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS)
return V_028C70_COLOR_INVALID;
switch (desc->nr_channels) {
unsigned radv_translate_colorswap(VkFormat format, bool do_endian_swap)
{
- const struct vk_format_description *desc = vk_format_description(format);
+ const struct util_format_description *desc = vk_format_description(format);
#define HAS_SWIZZLE(chan,swz) (desc->swizzle[chan] == PIPE_SWIZZLE_##swz)
if (format == VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)
return V_028C70_SWAP_STD;
- if (desc->layout != VK_FORMAT_LAYOUT_PLAIN)
+ if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN)
return ~0U;
switch (desc->nr_channels) {
uint32_t clear_vals[2],
VkClearColorValue *value)
{
- const struct vk_format_description *desc = vk_format_description(format);
+ const struct util_format_description *desc = vk_format_description(format);
if (format == VK_FORMAT_B10G11R11_UFLOAT_PACK32) {
clear_vals[0] = float3_to_r11g11b10f(value->float32);
return true;
}
- if (desc->layout != VK_FORMAT_LAYOUT_PLAIN) {
+ if (desc->layout != UTIL_FORMAT_LAYOUT_PLAIN) {
fprintf(stderr, "failed to fast clear for non-plain format %d\n", format);
return false;
}
* and we can skip swizzling checks as alpha always comes last for these and
* we do not care about the rest as they have to be the same.
*/
- if (desc->channel[0].type == VK_FORMAT_TYPE_FLOAT) {
+ if (desc->channel[0].type == UTIL_FORMAT_TYPE_FLOAT) {
if (value->float32[0] != value->float32[1] ||
value->float32[0] != value->float32[2])
return false;
if (desc->swizzle[c] >= 4)
continue;
- const struct vk_format_channel_description *channel = &desc->channel[desc->swizzle[c]];
+ const struct util_format_channel_description *channel = &desc->channel[desc->swizzle[c]];
assert(channel->size);
uint64_t v = 0;
if (channel->pure_integer) {
v = value->uint32[c] & ((1ULL << channel->size) - 1);
} else if (channel->normalized) {
- if (channel->type == VK_FORMAT_TYPE_UNSIGNED &&
+ if (channel->type == UTIL_FORMAT_TYPE_UNSIGNED &&
desc->swizzle[c] < 3 &&
- desc->colorspace == VK_FORMAT_COLORSPACE_SRGB) {
+ desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB) {
assert(channel->size == 8);
v = util_format_linear_float_to_srgb_8unorm(value->float32[c]);
} else {
float f = MIN2(value->float32[c], 1.0f);
- if (channel->type == VK_FORMAT_TYPE_UNSIGNED) {
+ if (channel->type == UTIL_FORMAT_TYPE_UNSIGNED) {
f = MAX2(f, 0.0f) * ((1ULL << channel->size) - 1);
} else {
f = MAX2(f, -1.0f) * ((1ULL << (channel->size - 1)) - 1);
v = (uint64_t)f;
}
- } else if (channel->type == VK_FORMAT_TYPE_FLOAT) {
+ } else if (channel->type == UTIL_FORMAT_TYPE_FLOAT) {
if (channel->size == 32) {
memcpy(&v, &value->float32[c], 4);
} else if(channel->size == 16) {
uint32_t maxMipLevels;
uint32_t maxArraySize;
VkSampleCountFlags sampleCounts = VK_SAMPLE_COUNT_1_BIT;
- const struct vk_format_description *desc = vk_format_description(format);
+ const struct util_format_description *desc = vk_format_description(format);
enum chip_class chip_class = physical_device->rad_info.chip_class;
VkImageTiling tiling = info->tiling;
const VkPhysicalDeviceImageDrmFormatModifierInfoEXT *mod_info =
break;
}
- if (desc->layout == VK_FORMAT_LAYOUT_SUBSAMPLED) {
+ if (desc->layout == UTIL_FORMAT_LAYOUT_SUBSAMPLED) {
/* Might be able to support but the entire format support is
* messy, so taking the lazy way out. */
maxArraySize = 1;
/* Return the type of DCC encoding. */
static enum dcc_channel_type
-radv_get_dcc_channel_type(const struct vk_format_description *desc)
+radv_get_dcc_channel_type(const struct util_format_description *desc)
{
int i;
/* Find the first non-void channel. */
for (i = 0; i < desc->nr_channels; i++)
- if (desc->channel[i].type != VK_FORMAT_TYPE_VOID)
+ if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID)
break;
if (i == desc->nr_channels)
return dcc_channel_incompatible;
switch (desc->channel[i].size) {
case 32:
- if (desc->channel[i].type == VK_FORMAT_TYPE_FLOAT)
+ if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)
return dcc_channel_float32;
- if (desc->channel[i].type == VK_FORMAT_TYPE_UNSIGNED)
+ if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
return dcc_channel_uint32;
return dcc_channel_sint32;
case 16:
- if (desc->channel[i].type == VK_FORMAT_TYPE_FLOAT)
+ if (desc->channel[i].type == UTIL_FORMAT_TYPE_FLOAT)
return dcc_channel_float16;
- if (desc->channel[i].type == VK_FORMAT_TYPE_UNSIGNED)
+ if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
return dcc_channel_uint16;
return dcc_channel_sint16;
case 10:
return dcc_channel_uint_10_10_10_2;
case 8:
- if (desc->channel[i].type == VK_FORMAT_TYPE_UNSIGNED)
+ if (desc->channel[i].type == UTIL_FORMAT_TYPE_UNSIGNED)
return dcc_channel_uint8;
return dcc_channel_sint8;
default:
bool radv_dcc_formats_compatible(VkFormat format1,
VkFormat format2)
{
- const struct vk_format_description *desc1, *desc2;
+ const struct util_format_description *desc1, *desc2;
enum dcc_channel_type type1, type2;
int i;