freedreno+turnip: Add has_8bpp_ubwc

Newer a6xx devices seem to drop 8b/pixel UBWC support.

The turnip part was adapted from Jonathans patch on !10892

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11790>
This commit is contained in:
Rob Clark
2021-07-08 10:43:08 -07:00
committed by Marge Bot
parent e552784e68
commit a4559c9550
6 changed files with 24 additions and 10 deletions
@@ -94,6 +94,8 @@ struct fd_dev_info {
*/
bool has_cp_reg_write;
bool has_8bpp_ubwc;
struct {
uint32_t RB_UNKNOWN_8E04_blit;
uint32_t PC_UNKNOWN_9805;
@@ -115,6 +115,7 @@ class A6xxGPUInfo(GPUInfo):
# Things that earlier gens have and later gens remove, provide
# defaults here and let them be overridden by sub-gen template:
self.a6xx.has_cp_reg_write = True
self.a6xx.has_8bpp_ubwc = True
for name, val in template.items():
setattr(self.a6xx, name, val)
+2 -2
View File
@@ -508,7 +508,7 @@ tu_GetPhysicalDeviceFormatProperties2(
/* note: ubwc_possible() argument values to be ignored except for format */
if (pFormatProperties->formatProperties.optimalTilingFeatures &&
ubwc_possible(format, VK_IMAGE_TYPE_2D, 0, 0, false, VK_SAMPLE_COUNT_1_BIT)) {
ubwc_possible(format, VK_IMAGE_TYPE_2D, 0, 0, physical_device->info, VK_SAMPLE_COUNT_1_BIT)) {
vk_outarray_append(&out, mod_props) {
mod_props->drmFormatModifier = DRM_FORMAT_MOD_QCOM_COMPRESSED;
mod_props->drmFormatModifierPlaneCount = 1;
@@ -556,7 +556,7 @@ tu_get_image_format_properties(
return VK_ERROR_FORMAT_NOT_SUPPORTED;
if (!ubwc_possible(info->format, info->type, info->usage, info->usage, physical_device->info->a6xx.has_z24uint_s8uint, sampleCounts))
if (!ubwc_possible(info->format, info->type, info->usage, info->usage, physical_device->info, sampleCounts))
return VK_ERROR_FORMAT_NOT_SUPPORTED;
format_feature_flags = format_props.optimalTilingFeatures;
+12 -4
View File
@@ -449,7 +449,7 @@ tu_image_view_init(struct tu_image_view *iview,
bool
ubwc_possible(VkFormat format, VkImageType type, VkImageUsageFlags usage,
VkImageUsageFlags stencil_usage, bool has_z24uint_s8uint,
VkImageUsageFlags stencil_usage, const struct fd_dev_info *info,
VkSampleCountFlagBits samples)
{
/* no UBWC with compressed formats, E5B9G9R9, S8_UINT
@@ -460,6 +460,14 @@ ubwc_possible(VkFormat format, VkImageType type, VkImageUsageFlags usage,
format == VK_FORMAT_S8_UINT)
return false;
if (!info->a6xx.has_8bpp_ubwc &&
(format == VK_FORMAT_R8_UNORM ||
format == VK_FORMAT_R8_SNORM ||
format == VK_FORMAT_R8_UINT ||
format == VK_FORMAT_R8_SINT ||
format == VK_FORMAT_R8_SRGB))
return false;
if (type == VK_IMAGE_TYPE_3D) {
tu_finishme("UBWC with 3D textures");
return false;
@@ -488,12 +496,12 @@ ubwc_possible(VkFormat format, VkImageType type, VkImageUsageFlags usage,
* Additionally, the special AS_R8G8B8A8 format is broken without UBWC,
* so we have to fallback to 8_8_8_8_UNORM when UBWC is disabled
*/
if (!has_z24uint_s8uint &&
if (!info->a6xx.has_z24uint_s8uint &&
format == VK_FORMAT_D24_UNORM_S8_UINT &&
(stencil_usage & (VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT)))
return false;
if (!has_z24uint_s8uint && samples > VK_SAMPLE_COUNT_1_BIT)
if (!info->a6xx.has_z24uint_s8uint && samples > VK_SAMPLE_COUNT_1_BIT)
return false;
return true;
@@ -609,7 +617,7 @@ tu_CreateImage(VkDevice _device,
if (!ubwc_possible(image->vk_format, pCreateInfo->imageType, pCreateInfo->usage,
stencil_usage_info ? stencil_usage_info->stencilUsage : pCreateInfo->usage,
device->physical_device->info->a6xx.has_z24uint_s8uint, pCreateInfo->samples))
device->physical_device->info, pCreateInfo->samples))
ubwc_enabled = false;
/* expect UBWC enabled if we asked for it */
+2 -2
View File
@@ -1468,8 +1468,8 @@ tu_image_view_init(struct tu_image_view *iview,
bool limited_z24s8);
bool
ubwc_possible(VkFormat format, VkImageType type, VkImageUsageFlags usage, VkImageUsageFlags stencil_usage, bool limited_z24s8,
VkSampleCountFlagBits samples);
ubwc_possible(VkFormat format, VkImageType type, VkImageUsageFlags usage, VkImageUsageFlags stencil_usage,
const struct fd_dev_info *info, VkSampleCountFlagBits samples);
struct tu_buffer_view
{
@@ -39,6 +39,8 @@
static bool
ok_ubwc_format(struct pipe_screen *pscreen, enum pipe_format pfmt)
{
const struct fd_dev_info *info = fd_screen(pscreen)->info;
switch (pfmt) {
case PIPE_FORMAT_X24S8_UINT:
case PIPE_FORMAT_Z24_UNORM_S8_UINT:
@@ -47,7 +49,7 @@ ok_ubwc_format(struct pipe_screen *pscreen, enum pipe_format pfmt)
* fd_resource_uncompress() at the point of stencil sampling because
* that itself uses stencil sampling in the fd_blitter_blit path.
*/
return fd_screen(pscreen)->info->a6xx.has_z24uint_s8uint;
return info->a6xx.has_z24uint_s8uint;
case PIPE_FORMAT_R8_G8B8_420_UNORM:
return true;
@@ -81,10 +83,11 @@ ok_ubwc_format(struct pipe_screen *pscreen, enum pipe_format pfmt)
case FMT6_8_8_SINT:
case FMT6_8_8_UINT:
case FMT6_8_8_UNORM:
case FMT6_8_UNORM:
case FMT6_Z24_UNORM_S8_UINT:
case FMT6_Z24_UNORM_S8_UINT_AS_R8G8B8A8:
return true;
case FMT6_8_UNORM:
return info->a6xx.has_8bpp_ubwc;
default:
return false;
}