diff options
author | Jonathan Marek <[email protected]> | 2019-11-18 16:46:39 -0500 |
---|---|---|
committer | Jonathan Marek <[email protected]> | 2019-11-21 22:21:57 +0000 |
commit | 773d640efa2665fc50f86cbb7d1e6b9402ba44ad (patch) | |
tree | 1b345b4bffbbff002dcb226b930cd4f8a0336430 /src/freedreno/vulkan/tu_wsi.c | |
parent | 91fd83d1420c8e9f94b08356ab48f9ab15329645 (diff) |
turnip: implement UBWC
This enables UBWC for everything except 3D textures.
It breaks many image_to_image copies but those aren't important and it can
be worked around later (image_to_image copy needs to be done in two steps,
decode from the source format and then encode to the destination format).
Signed-off-by: Jonathan Marek <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/freedreno/vulkan/tu_wsi.c')
-rw-r--r-- | src/freedreno/vulkan/tu_wsi.c | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/freedreno/vulkan/tu_wsi.c b/src/freedreno/vulkan/tu_wsi.c index 21466108b20..c80e489399f 100644 --- a/src/freedreno/vulkan/tu_wsi.c +++ b/src/freedreno/vulkan/tu_wsi.c @@ -27,6 +27,7 @@ #include "vk_util.h" #include "wsi_common.h" +#include "drm-uapi/drm_fourcc.h" static PFN_vkVoidFunction tu_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName) @@ -34,13 +35,38 @@ tu_wsi_proc_addr(VkPhysicalDevice physicalDevice, const char *pName) return tu_lookup_entrypoint_unchecked(pName); } +static uint64_t +tu_wsi_image_get_modifier(VkImage _image) +{ + TU_FROM_HANDLE(tu_image, image, _image); + + if (!image->tile_mode) + return DRM_FORMAT_MOD_LINEAR; + + if (image->ubwc_size) + return DRM_FORMAT_MOD_QCOM_COMPRESSED; + + /* TODO invent a modifier for tiled but not UBWC buffers: */ + return DRM_FORMAT_MOD_INVALID; +} + VkResult tu_wsi_init(struct tu_physical_device *physical_device) { - return wsi_device_init(&physical_device->wsi_device, - tu_physical_device_to_handle(physical_device), - tu_wsi_proc_addr, &physical_device->instance->alloc, - physical_device->master_fd, NULL); + VkResult result; + + result = wsi_device_init(&physical_device->wsi_device, + tu_physical_device_to_handle(physical_device), + tu_wsi_proc_addr, + &physical_device->instance->alloc, + physical_device->master_fd, NULL); + if (result != VK_SUCCESS) + return result; + + physical_device->wsi_device.supports_modifiers = true; + physical_device->wsi_device.image_get_modifier = tu_wsi_image_get_modifier; + + return VK_SUCCESS; } void |