nvk: Remap 10 and 12 bit formats to 16 bit formats

Preserves the previous behavior while handling the new formats.

Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Signed-off-by: Valentine Burley <valentine.burley@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30821>
This commit is contained in:
Valentine Burley
2024-09-10 20:13:16 +02:00
committed by Marge Bot
parent ab298b9c3a
commit a33538cb9f
7 changed files with 33 additions and 15 deletions
+2 -2
View File
@@ -24,7 +24,7 @@ nvk_get_buffer_format_features(struct nvk_physical_device *pdev,
if (nvk_get_va_format(pdev, vk_format))
features |= VK_FORMAT_FEATURE_2_VERTEX_BUFFER_BIT;
enum pipe_format p_format = vk_format_to_pipe_format(vk_format);
enum pipe_format p_format = nvk_format_to_pipe_format(vk_format);
if (nil_format_supports_buffer(&pdev->info, p_format)) {
features |= VK_FORMAT_FEATURE_2_UNIFORM_TEXEL_BUFFER_BIT;
@@ -60,7 +60,7 @@ nvk_CreateBufferView(VkDevice _device,
return vk_error(dev, VK_ERROR_OUT_OF_HOST_MEMORY);
const uint64_t addr = nvk_buffer_address(buffer, view->vk.offset);
enum pipe_format format = vk_format_to_pipe_format(view->vk.format);
enum pipe_format format = nvk_format_to_pipe_format(view->vk.format);
if (nvk_use_edb_buffer_views(pdev)) {
view->edb_desc =
+2 -1
View File
@@ -6,6 +6,7 @@
#include "nvk_device.h"
#include "nvk_entrypoints.h"
#include "nvk_format.h"
#include "nvk_image.h"
#include "nvk_image_view.h"
#include "nvk_mme.h"
@@ -329,7 +330,7 @@ nvk_CmdClearColorImage(VkCommandBuffer commandBuffer,
if (vk_format == VK_FORMAT_R64_UINT || vk_format == VK_FORMAT_R64_SINT)
vk_format = VK_FORMAT_R32G32_UINT;
enum pipe_format p_format = vk_format_to_pipe_format(vk_format);
enum pipe_format p_format = nvk_format_to_pipe_format(vk_format);
assert(p_format != PIPE_FORMAT_NONE);
if (!nil_format_supports_color_targets(&pdev->info, p_format)) {
+4 -4
View File
@@ -989,7 +989,7 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer,
if (level->tiling.gob_type != NIL_GOB_TYPE_LINEAR) {
const enum pipe_format p_format =
vk_format_to_pipe_format(iview->vk.format);
nvk_format_to_pipe_format(iview->vk.format);
/* We use the stride for depth/stencil targets because the Z/S
* hardware has no concept of a tile width. Instead, we just set
@@ -1026,7 +1026,7 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer,
uint32_t pitch = level->row_stride_B;
const enum pipe_format p_format =
vk_format_to_pipe_format(iview->vk.format);
nvk_format_to_pipe_format(iview->vk.format);
/* When memory layout is set to LAYOUT_PITCH, the WIDTH field
* takes row pitch
*/
@@ -1104,7 +1104,7 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer,
P_NV9097_SET_ZT_A(p, addr >> 32);
P_NV9097_SET_ZT_B(p, addr);
const enum pipe_format p_format =
vk_format_to_pipe_format(iview->vk.format);
nvk_format_to_pipe_format(iview->vk.format);
const uint8_t zs_format = nil_format_to_depth_stencil(p_format);
P_NV9097_SET_ZT_FORMAT(p, zs_format);
assert(level->tiling.gob_type != NIL_GOB_TYPE_LINEAR);
@@ -1192,7 +1192,7 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer,
});
const enum pipe_format p_format =
vk_format_to_pipe_format(iview->vk.format);
nvk_format_to_pipe_format(iview->vk.format);
const uint32_t row_stride_el =
level->row_stride_B / util_format_get_blocksize(p_format);
P_NVC597_SET_SHADING_RATE_INDEX_SURFACE_ALLOCATED_SIZE(p, 0,
+2 -1
View File
@@ -9,6 +9,7 @@
#include "nvk_descriptor_set_layout.h"
#include "nvk_device.h"
#include "nvk_entrypoints.h"
#include "nvk_format.h"
#include "nvk_image_view.h"
#include "nvk_physical_device.h"
#include "nvk_sampler.h"
@@ -256,7 +257,7 @@ get_edb_buffer_view_desc(struct nvk_device *dev,
{
struct nvk_edb_buffer_view_descriptor desc = { };
if (info != NULL && info->address != 0) {
enum pipe_format format = vk_format_to_pipe_format(info->format);
enum pipe_format format = nvk_format_to_pipe_format(info->format);
desc = nvk_edb_bview_cache_get_descriptor(dev, &dev->edb_bview_cache,
info->address, info->range,
format);
+16
View File
@@ -6,6 +6,7 @@
#define NVK_FORMAT_H 1
#include "nvk_private.h"
#include "vk_format.h"
#include "util/format/u_formats.h"
#include "nv_device_info.h"
@@ -25,4 +26,19 @@ nvk_format_supports_atomics(const struct nv_device_info *dev,
const struct nvk_va_format *
nvk_get_va_format(const struct nvk_physical_device *pdev, VkFormat format);
static inline enum pipe_format
nvk_format_to_pipe_format(enum VkFormat vkformat)
{
switch (vkformat) {
case VK_FORMAT_R10X6_UNORM_PACK16:
case VK_FORMAT_R12X4_UNORM_PACK16:
return PIPE_FORMAT_R16_UNORM;
case VK_FORMAT_R10X6G10X6_UNORM_2PACK16:
case VK_FORMAT_R12X4G12X4_UNORM_2PACK16:
return PIPE_FORMAT_R16G16_UNORM;
default:
return vk_format_to_pipe_format(vkformat);
}
}
#endif
+6 -6
View File
@@ -34,7 +34,7 @@ nvk_get_image_plane_format_features(struct nvk_physical_device *pdev,
!fourcc_mod_is_vendor(drm_format_mod, NVIDIA))
return 0;
enum pipe_format p_format = vk_format_to_pipe_format(vk_format);
enum pipe_format p_format = nvk_format_to_pipe_format(vk_format);
if (p_format == PIPE_FORMAT_NONE)
return 0;
@@ -195,7 +195,7 @@ nvk_get_drm_format_modifier_properties_list(struct nvk_physical_device *pdev,
uint64_t mods[NIL_MAX_DRM_FORMAT_MODS];
size_t mod_count = NIL_MAX_DRM_FORMAT_MODS;
enum pipe_format p_format = vk_format_to_pipe_format(vk_format);
enum pipe_format p_format = nvk_format_to_pipe_format(vk_format);
nil_drm_format_mods_for_format(&pdev->info, nil_format(p_format),
&mod_count, &mods);
if (mod_count == 0) {
@@ -695,7 +695,7 @@ nvk_GetPhysicalDeviceSparseImageFormatProperties2(
VkImageAspectFlags aspects = vk_format_aspects(pFormatInfo->format);
const enum pipe_format pipe_format =
vk_format_to_pipe_format(pFormatInfo->format);
nvk_format_to_pipe_format(pFormatInfo->format);
const enum nil_image_dim dim = vk_image_type_to_nil_dim(pFormatInfo->type);
const enum nil_sample_layout sample_layout =
nil_choose_sample_layout(pFormatInfo->samples);
@@ -775,7 +775,7 @@ nvk_image_init(struct nvk_device *dev,
IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT);
enum pipe_format p_format =
vk_format_to_pipe_format(pCreateInfo->format);
nvk_format_to_pipe_format(pCreateInfo->format);
image->vk.drm_format_mod =
nil_select_best_drm_format_mod(&pdev->info, nil_format(p_format),
mod_list_info->drmFormatModifierCount,
@@ -789,7 +789,7 @@ nvk_image_init(struct nvk_device *dev,
struct nil_image_init_info tiled_shadow_nil_info = {
.dim = vk_image_type_to_nil_dim(pCreateInfo->imageType),
.format = nil_format(vk_format_to_pipe_format(image->vk.format)),
.format = nil_format(nvk_format_to_pipe_format(image->vk.format)),
.modifier = DRM_FORMAT_MOD_INVALID,
.extent_px = {
.width = pCreateInfo->extent.width,
@@ -818,7 +818,7 @@ nvk_image_init(struct nvk_device *dev,
ycbcr_info->planes[plane].denominator_scales[1] : 1;
struct nil_image_init_info nil_info = {
.dim = vk_image_type_to_nil_dim(pCreateInfo->imageType),
.format = nil_format(vk_format_to_pipe_format(format)),
.format = nil_format(nvk_format_to_pipe_format(format)),
.modifier = image->vk.drm_format_mod,
.extent_px = {
.width = pCreateInfo->extent.width / width_scale,
+1 -1
View File
@@ -152,7 +152,7 @@ nvk_image_view_init(struct nvk_device *dev,
assert(ycbcr_info || view_plane == 0);
VkFormat plane_format = ycbcr_info ?
ycbcr_info->planes[view_plane].format : view->vk.format;
enum pipe_format p_format = vk_format_to_pipe_format(plane_format);
enum pipe_format p_format = nvk_format_to_pipe_format(plane_format);
if (view->vk.aspects == VK_IMAGE_ASPECT_STENCIL_BIT)
p_format = get_stencil_format(p_format);