diff options
author | Bas Nieuwenhuizen <[email protected]> | 2019-09-19 23:34:36 +0200 |
---|---|---|
committer | Bas Nieuwenhuizen <[email protected]> | 2019-09-27 15:05:21 +0200 |
commit | fa522b8a4745e5a1e3f54528f18094775d7c597b (patch) | |
tree | 49d1d371201213fc8799414ab33074d8831579a0 /src/freedreno/vulkan/tu_formats.c | |
parent | 9e822957cd2c5d92b2b57c663aa153976119197d (diff) |
turnip: Disallow NPoT formats.
Copying is a mess for these formats for now.
Reviewed-by: Kristian H. Kristensen <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/freedreno/vulkan/tu_formats.c')
-rw-r--r-- | src/freedreno/vulkan/tu_formats.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/freedreno/vulkan/tu_formats.c b/src/freedreno/vulkan/tu_formats.c index 5ae04d1e6ad..095f77570ba 100644 --- a/src/freedreno/vulkan/tu_formats.c +++ b/src/freedreno/vulkan/tu_formats.c @@ -614,15 +614,26 @@ tu_physical_device_get_format_properties( const struct vk_format_description *desc = vk_format_description(format); const struct tu_native_format *native_fmt = tu6_get_native_format(format); if (!desc || !native_fmt) { - out_properties->linearTilingFeatures = linear; - out_properties->optimalTilingFeatures = tiled; - out_properties->bufferFeatures = buffer; - return; + goto end; } - linear |= VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT; - tiled |= VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT; buffer |= VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT; + if (native_fmt->vtx >= 0) { + buffer |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT; + } + + /* + * The non-power-of-two formats cannot be copied, so to make sure nothing + * broken is allowed don't allow these formats at all. + */ + if (!util_is_power_of_two_or_zero(vk_format_get_blocksizebits(format))) { + goto end; + } + + if (native_fmt->tex >= 0 || native_fmt->rb >= 0) { + linear |= VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT; + tiled |= VK_FORMAT_FEATURE_TRANSFER_SRC_BIT | VK_FORMAT_FEATURE_TRANSFER_DST_BIT; + } if (native_fmt->tex >= 0) { linear |= VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT; @@ -635,10 +646,7 @@ tu_physical_device_get_format_properties( tiled |= VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT; } - if (native_fmt->vtx >= 0) { - buffer |= VK_FORMAT_FEATURE_VERTEX_BUFFER_BIT; - } - +end: out_properties->linearTilingFeatures = linear; out_properties->optimalTilingFeatures = tiled; out_properties->bufferFeatures = buffer; |