dzn: Add physical device arg to format lookup
A followup change will switch format mappings based on this Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22606>
This commit is contained in:
parent
1e11645a30
commit
c6bc4459e5
5 changed files with 50 additions and 27 deletions
|
|
@ -2543,6 +2543,7 @@ dzn_cmd_buffer_copy_img_chunk(struct dzn_cmd_buffer *cmdbuf,
|
|||
uint32_t l)
|
||||
{
|
||||
struct dzn_device *device = container_of(cmdbuf->vk.base.device, struct dzn_device, vk);
|
||||
struct dzn_physical_device *pdev = container_of(device->vk.physical, struct dzn_physical_device, vk);
|
||||
VK_FROM_HANDLE(dzn_image, src, info->srcImage);
|
||||
VK_FROM_HANDLE(dzn_image, dst, info->dstImage);
|
||||
|
||||
|
|
@ -2611,7 +2612,7 @@ dzn_cmd_buffer_copy_img_chunk(struct dzn_cmd_buffer *cmdbuf,
|
|||
}
|
||||
|
||||
tmp_desc->Format =
|
||||
dzn_image_get_placed_footprint_format(src->vk.format, aspect);
|
||||
dzn_image_get_placed_footprint_format(pdev, src->vk.format, aspect);
|
||||
tmp_desc->Width = region.extent.width;
|
||||
tmp_desc->Height = region.extent.height;
|
||||
|
||||
|
|
@ -2651,7 +2652,7 @@ dzn_cmd_buffer_copy_img_chunk(struct dzn_cmd_buffer *cmdbuf,
|
|||
}
|
||||
|
||||
tmp_desc->Format =
|
||||
dzn_image_get_placed_footprint_format(dst->vk.format, aspect);
|
||||
dzn_image_get_placed_footprint_format(pdev, dst->vk.format, aspect);
|
||||
if (src_blkw != dst_blkw)
|
||||
tmp_desc->Width = DIV_ROUND_UP(region.extent.width, src_blkw) * dst_blkw;
|
||||
if (src_blkh != dst_blkh)
|
||||
|
|
@ -2768,13 +2769,14 @@ dzn_cmd_buffer_blit_set_pipeline(struct dzn_cmd_buffer *cmdbuf,
|
|||
VkFilter filter, bool resolve)
|
||||
{
|
||||
struct dzn_device *device = container_of(cmdbuf->vk.base.device, struct dzn_device, vk);
|
||||
struct dzn_physical_device *pdev = container_of(device->vk.physical, struct dzn_physical_device, vk);
|
||||
enum pipe_format pfmt = vk_format_to_pipe_format(dst->vk.format);
|
||||
VkImageUsageFlags usage =
|
||||
vk_format_is_depth_or_stencil(dst->vk.format) ?
|
||||
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT :
|
||||
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
|
||||
struct dzn_meta_blit_key ctx_key = {
|
||||
.out_format = dzn_image_get_dxgi_format(dst->vk.format, usage, aspect),
|
||||
.out_format = dzn_image_get_dxgi_format(pdev, dst->vk.format, usage, aspect),
|
||||
.samples = (uint32_t)src->vk.samples,
|
||||
.loc = (uint32_t)(aspect == VK_IMAGE_ASPECT_DEPTH_BIT ?
|
||||
FRAG_RESULT_DEPTH :
|
||||
|
|
@ -4016,6 +4018,7 @@ dzn_CmdCopyImage2(VkCommandBuffer commandBuffer,
|
|||
{
|
||||
VK_FROM_HANDLE(dzn_cmd_buffer, cmdbuf, commandBuffer);
|
||||
struct dzn_device *device = container_of(cmdbuf->vk.base.device, struct dzn_device, vk);
|
||||
struct dzn_physical_device *pdev = container_of(device->vk.physical, struct dzn_physical_device, vk);
|
||||
VK_FROM_HANDLE(dzn_image, src, info->srcImage);
|
||||
VK_FROM_HANDLE(dzn_image, dst, info->dstImage);
|
||||
|
||||
|
|
@ -4131,7 +4134,7 @@ dzn_CmdCopyImage2(VkCommandBuffer commandBuffer,
|
|||
uint64_t region_size = 0;
|
||||
|
||||
tmp_desc.Format =
|
||||
dzn_image_get_dxgi_format(src->vk.format,
|
||||
dzn_image_get_dxgi_format(pdev, src->vk.format,
|
||||
VK_IMAGE_USAGE_TRANSFER_DST_BIT,
|
||||
aspect);
|
||||
tmp_desc.Width = region->extent.width;
|
||||
|
|
|
|||
|
|
@ -672,7 +672,7 @@ dzn_get_most_capable_format_for_casting(VkFormat format, VkImageCreateFlags crea
|
|||
bool block_compressed = util_format_is_compressed(pfmt);
|
||||
if (block_compressed &&
|
||||
!(create_flags & VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT))
|
||||
return dzn_image_get_dxgi_format(format, 0, 0);
|
||||
return dzn_image_get_dxgi_format(NULL, format, 0, 0);
|
||||
unsigned blksz = util_format_get_blocksize(pfmt);
|
||||
switch (blksz) {
|
||||
case 1: return DXGI_FORMAT_R8_UNORM;
|
||||
|
|
@ -701,7 +701,7 @@ dzn_physical_device_get_format_support(struct dzn_physical_device *pdev,
|
|||
aspects = VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
|
||||
D3D12_FEATURE_DATA_FORMAT_SUPPORT dfmt_info = {
|
||||
.Format = dzn_image_get_dxgi_format(format, usage, aspects),
|
||||
.Format = dzn_image_get_dxgi_format(pdev, format, usage, aspects),
|
||||
};
|
||||
|
||||
/* KHR_maintenance2: If an image is created with the extended usage flag
|
||||
|
|
@ -729,7 +729,7 @@ dzn_physical_device_get_format_support(struct dzn_physical_device *pdev,
|
|||
*/
|
||||
dzn_foreach_aspect(aspect, aspects) {
|
||||
D3D12_FEATURE_DATA_FORMAT_SUPPORT dfmt_info2 = {
|
||||
.Format = dzn_image_get_dxgi_format(format, 0, aspect),
|
||||
.Format = dzn_image_get_dxgi_format(pdev, format, 0, aspect),
|
||||
};
|
||||
|
||||
hres = ID3D12Device1_CheckFeatureSupport(dev, D3D12_FEATURE_FORMAT_SUPPORT,
|
||||
|
|
@ -2869,6 +2869,8 @@ dzn_buffer_get_copy_loc(const struct dzn_buffer *buf,
|
|||
VkImageAspectFlagBits aspect,
|
||||
uint32_t layer)
|
||||
{
|
||||
struct dzn_physical_device *pdev =
|
||||
container_of(buf->base.device->physical, struct dzn_physical_device, vk);
|
||||
const uint32_t buffer_row_length =
|
||||
region->bufferRowLength ? region->bufferRowLength : region->imageExtent.width;
|
||||
|
||||
|
|
@ -2885,7 +2887,7 @@ dzn_buffer_get_copy_loc(const struct dzn_buffer *buf,
|
|||
.PlacedFootprint = {
|
||||
.Footprint = {
|
||||
.Format =
|
||||
dzn_image_get_placed_footprint_format(format, aspect),
|
||||
dzn_image_get_placed_footprint_format(pdev, format, aspect),
|
||||
.Width = region->imageExtent.width,
|
||||
.Height = region->imageExtent.height,
|
||||
.Depth = region->imageExtent.depth,
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ dzn_image_create(struct dzn_device *device,
|
|||
image->castable_format_count = 0;
|
||||
for (uint32_t i = 0; i < compat_format_count; i++) {
|
||||
castable_formats[image->castable_format_count] =
|
||||
dzn_image_get_dxgi_format(compat_formats[i], usage, 0);
|
||||
dzn_image_get_dxgi_format(pdev, compat_formats[i], usage, 0);
|
||||
|
||||
if (castable_formats[image->castable_format_count] != DXGI_FORMAT_UNKNOWN)
|
||||
image->castable_format_count++;
|
||||
|
|
@ -162,7 +162,7 @@ dzn_image_create(struct dzn_device *device,
|
|||
.DepthOrArraySize = 1,
|
||||
.MipLevels = 1,
|
||||
.Format =
|
||||
dzn_image_get_dxgi_format(pCreateInfo->format, usage, 0),
|
||||
dzn_image_get_dxgi_format(pdev, pCreateInfo->format, usage, 0),
|
||||
.SampleDesc = { .Count = 1, .Quality = 0 },
|
||||
.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN,
|
||||
.Flags = D3D12_RESOURCE_FLAG_NONE
|
||||
|
|
@ -186,7 +186,7 @@ dzn_image_create(struct dzn_device *device,
|
|||
image->castable_format_count = 0;
|
||||
} else {
|
||||
image->desc.Format =
|
||||
dzn_image_get_dxgi_format(pCreateInfo->format,
|
||||
dzn_image_get_dxgi_format(pdev, pCreateInfo->format,
|
||||
usage & ~VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
|
||||
0),
|
||||
image->desc.Dimension = (D3D12_RESOURCE_DIMENSION)(D3D12_RESOURCE_DIMENSION_TEXTURE1D + pCreateInfo->imageType);
|
||||
|
|
@ -269,7 +269,8 @@ dzn_image_create(struct dzn_device *device,
|
|||
}
|
||||
|
||||
DXGI_FORMAT
|
||||
dzn_image_get_dxgi_format(VkFormat format,
|
||||
dzn_image_get_dxgi_format(const struct dzn_physical_device *pdev,
|
||||
VkFormat format,
|
||||
VkImageUsageFlags usage,
|
||||
VkImageAspectFlags aspects)
|
||||
{
|
||||
|
|
@ -329,11 +330,12 @@ dzn_image_get_dxgi_format(VkFormat format,
|
|||
}
|
||||
|
||||
DXGI_FORMAT
|
||||
dzn_image_get_placed_footprint_format(VkFormat format,
|
||||
dzn_image_get_placed_footprint_format(const struct dzn_physical_device *pdev,
|
||||
VkFormat format,
|
||||
VkImageAspectFlags aspect)
|
||||
{
|
||||
DXGI_FORMAT out =
|
||||
dzn_image_get_dxgi_format(format,
|
||||
dzn_image_get_dxgi_format(pdev, format,
|
||||
VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
|
||||
VK_IMAGE_USAGE_TRANSFER_DST_BIT,
|
||||
aspect);
|
||||
|
|
@ -409,6 +411,8 @@ dzn_image_get_copy_loc(const struct dzn_image *image,
|
|||
VkImageAspectFlagBits aspect,
|
||||
uint32_t layer)
|
||||
{
|
||||
struct dzn_physical_device *pdev =
|
||||
container_of(image->vk.base.device->physical, struct dzn_physical_device, vk);
|
||||
D3D12_TEXTURE_COPY_LOCATION loc = {
|
||||
.pResource = image->res,
|
||||
};
|
||||
|
|
@ -421,7 +425,7 @@ dzn_image_get_copy_loc(const struct dzn_image *image,
|
|||
loc.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT;
|
||||
loc.PlacedFootprint.Offset = 0;
|
||||
loc.PlacedFootprint.Footprint.Format =
|
||||
dzn_image_get_placed_footprint_format(image->vk.format, aspect);
|
||||
dzn_image_get_placed_footprint_format(pdev, image->vk.format, aspect);
|
||||
loc.PlacedFootprint.Footprint.Width = image->vk.extent.width;
|
||||
loc.PlacedFootprint.Footprint.Height = image->vk.extent.height;
|
||||
loc.PlacedFootprint.Footprint.Depth = image->vk.extent.depth;
|
||||
|
|
@ -439,10 +443,12 @@ dzn_image_get_dsv_desc(const struct dzn_image *image,
|
|||
const VkImageSubresourceRange *range,
|
||||
uint32_t level)
|
||||
{
|
||||
struct dzn_physical_device *pdev =
|
||||
container_of(image->vk.base.device->physical, struct dzn_physical_device, vk);
|
||||
uint32_t layer_count = dzn_get_layer_count(image, range);
|
||||
D3D12_DEPTH_STENCIL_VIEW_DESC dsv_desc = {
|
||||
.Format =
|
||||
dzn_image_get_dxgi_format(image->vk.format,
|
||||
dzn_image_get_dxgi_format(pdev, image->vk.format,
|
||||
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
|
||||
range->aspectMask),
|
||||
};
|
||||
|
|
@ -506,10 +512,12 @@ dzn_image_get_rtv_desc(const struct dzn_image *image,
|
|||
const VkImageSubresourceRange *range,
|
||||
uint32_t level)
|
||||
{
|
||||
struct dzn_physical_device *pdev =
|
||||
container_of(image->vk.base.device->physical, struct dzn_physical_device, vk);
|
||||
uint32_t layer_count = dzn_get_layer_count(image, range);
|
||||
D3D12_RENDER_TARGET_VIEW_DESC rtv_desc = {
|
||||
.Format =
|
||||
dzn_image_get_dxgi_format(image->vk.format,
|
||||
dzn_image_get_dxgi_format(pdev, image->vk.format,
|
||||
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT),
|
||||
};
|
||||
|
|
@ -715,8 +723,8 @@ dzn_image_formats_are_compatible(const struct dzn_device *device,
|
|||
{
|
||||
const struct dzn_physical_device *pdev =
|
||||
container_of(device->vk.physical, struct dzn_physical_device, vk);
|
||||
DXGI_FORMAT orig_dxgi = dzn_image_get_dxgi_format(orig_fmt, usage, aspect);
|
||||
DXGI_FORMAT new_dxgi = dzn_image_get_dxgi_format(new_fmt, usage, aspect);
|
||||
DXGI_FORMAT orig_dxgi = dzn_image_get_dxgi_format(pdev, orig_fmt, usage, aspect);
|
||||
DXGI_FORMAT new_dxgi = dzn_image_get_dxgi_format(pdev, new_fmt, usage, aspect);
|
||||
|
||||
if (orig_dxgi == new_dxgi)
|
||||
return true;
|
||||
|
|
@ -1005,6 +1013,8 @@ translate_swizzle(VkComponentSwizzle in, uint32_t comp)
|
|||
static void
|
||||
dzn_image_view_prepare_srv_desc(struct dzn_image_view *iview)
|
||||
{
|
||||
struct dzn_physical_device *pdev =
|
||||
container_of(iview->vk.base.device->physical, struct dzn_physical_device, vk);
|
||||
uint32_t plane_slice = (iview->vk.aspects & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)) ==
|
||||
VK_IMAGE_ASPECT_STENCIL_BIT ? 1 : 0;
|
||||
bool ms = iview->vk.image->samples > 1;
|
||||
|
|
@ -1018,7 +1028,7 @@ dzn_image_view_prepare_srv_desc(struct dzn_image_view *iview)
|
|||
|
||||
iview->srv_desc = (D3D12_SHADER_RESOURCE_VIEW_DESC) {
|
||||
.Format =
|
||||
dzn_image_get_dxgi_format(iview->vk.format,
|
||||
dzn_image_get_dxgi_format(pdev, iview->vk.format,
|
||||
iview->vk.usage & ~VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
|
||||
iview->vk.aspects),
|
||||
};
|
||||
|
|
@ -1135,13 +1145,15 @@ dzn_image_view_prepare_srv_desc(struct dzn_image_view *iview)
|
|||
static void
|
||||
dzn_image_view_prepare_uav_desc(struct dzn_image_view *iview)
|
||||
{
|
||||
struct dzn_physical_device *pdev =
|
||||
container_of(iview->vk.base.device->physical, struct dzn_physical_device, vk);
|
||||
bool use_array = iview->vk.base_array_layer > 0 || iview->vk.layer_count > 1;
|
||||
|
||||
assert(iview->vk.image->samples == 1);
|
||||
|
||||
iview->uav_desc = (D3D12_UNORDERED_ACCESS_VIEW_DESC) {
|
||||
.Format =
|
||||
dzn_image_get_dxgi_format(iview->vk.format,
|
||||
dzn_image_get_dxgi_format(pdev, iview->vk.format,
|
||||
VK_IMAGE_USAGE_STORAGE_BIT,
|
||||
iview->vk.aspects),
|
||||
};
|
||||
|
|
@ -1189,6 +1201,8 @@ dzn_image_view_prepare_uav_desc(struct dzn_image_view *iview)
|
|||
static void
|
||||
dzn_image_view_prepare_rtv_desc(struct dzn_image_view *iview)
|
||||
{
|
||||
struct dzn_physical_device *pdev =
|
||||
container_of(iview->vk.base.device->physical, struct dzn_physical_device, vk);
|
||||
bool use_array = iview->vk.base_array_layer > 0 || iview->vk.layer_count > 1;
|
||||
bool from_3d_image = iview->vk.image->image_type == VK_IMAGE_TYPE_3D;
|
||||
bool ms = iview->vk.image->samples > 1;
|
||||
|
|
@ -1198,7 +1212,7 @@ dzn_image_view_prepare_rtv_desc(struct dzn_image_view *iview)
|
|||
|
||||
iview->rtv_desc = (D3D12_RENDER_TARGET_VIEW_DESC) {
|
||||
.Format =
|
||||
dzn_image_get_dxgi_format(iview->vk.format,
|
||||
dzn_image_get_dxgi_format(pdev, iview->vk.format,
|
||||
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
|
||||
iview->vk.aspects),
|
||||
};
|
||||
|
|
@ -1259,12 +1273,14 @@ dzn_image_view_prepare_rtv_desc(struct dzn_image_view *iview)
|
|||
static void
|
||||
dzn_image_view_prepare_dsv_desc(struct dzn_image_view *iview)
|
||||
{
|
||||
struct dzn_physical_device *pdev =
|
||||
container_of(iview->vk.base.device->physical, struct dzn_physical_device, vk);
|
||||
bool use_array = iview->vk.base_array_layer > 0 || iview->vk.layer_count > 1;
|
||||
bool ms = iview->vk.image->samples > 1;
|
||||
|
||||
iview->dsv_desc = (D3D12_DEPTH_STENCIL_VIEW_DESC) {
|
||||
.Format =
|
||||
dzn_image_get_dxgi_format(iview->vk.format,
|
||||
dzn_image_get_dxgi_format(pdev, iview->vk.format,
|
||||
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
|
||||
iview->vk.aspects),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1911,7 +1911,7 @@ dzn_graphics_pipeline_create(struct dzn_device *device,
|
|||
rts->NumRenderTargets = color_count;
|
||||
for (uint32_t i = 0; i < color_count; i++) {
|
||||
rts->RTFormats[i] =
|
||||
dzn_image_get_dxgi_format(color_fmts[i],
|
||||
dzn_image_get_dxgi_format(pdev, color_fmts[i],
|
||||
VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
|
||||
VK_IMAGE_ASPECT_COLOR_BIT);
|
||||
}
|
||||
|
|
@ -1920,7 +1920,7 @@ dzn_graphics_pipeline_create(struct dzn_device *device,
|
|||
if (zs_fmt != VK_FORMAT_UNDEFINED) {
|
||||
d3d12_gfx_pipeline_state_stream_new_desc(stream_desc, DEPTH_STENCIL_FORMAT, DXGI_FORMAT, ds_fmt);
|
||||
*ds_fmt =
|
||||
dzn_image_get_dxgi_format(zs_fmt,
|
||||
dzn_image_get_dxgi_format(pdev, zs_fmt,
|
||||
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
|
||||
VK_IMAGE_ASPECT_DEPTH_BIT |
|
||||
VK_IMAGE_ASPECT_STENCIL_BIT);
|
||||
|
|
|
|||
|
|
@ -1055,7 +1055,8 @@ dzn_image_align_extent(const struct dzn_image *image,
|
|||
VkExtent3D *extent);
|
||||
|
||||
DXGI_FORMAT
|
||||
dzn_image_get_dxgi_format(VkFormat format,
|
||||
dzn_image_get_dxgi_format(const struct dzn_physical_device *pdev,
|
||||
VkFormat format,
|
||||
VkImageUsageFlags usage,
|
||||
VkImageAspectFlags aspects);
|
||||
|
||||
|
|
@ -1063,7 +1064,8 @@ VkFormat
|
|||
dzn_image_get_plane_format(VkFormat fmt, VkImageAspectFlags aspect);
|
||||
|
||||
DXGI_FORMAT
|
||||
dzn_image_get_placed_footprint_format(VkFormat fmt, VkImageAspectFlags aspect);
|
||||
dzn_image_get_placed_footprint_format(const struct dzn_physical_device *pdev,
|
||||
VkFormat fmt, VkImageAspectFlags aspect);
|
||||
|
||||
D3D12_DEPTH_STENCIL_VIEW_DESC
|
||||
dzn_image_get_dsv_desc(const struct dzn_image *image,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue