From 7ba94036f363757b1e379ef3ad1cf2cc47735d6d Mon Sep 17 00:00:00 2001 From: Sil Vilerino Date: Thu, 20 Oct 2022 12:26:03 -0400 Subject: [PATCH] d3d12: Create d3d12_resource objects for video usage keeping their DXGI_..._UNORM formats Do not set D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS nor convert new d3d12_resource objects to their DXGI typeless formats for video usage flagged by the video driver with PIPE_BIND_CUSTOM Part-of: --- src/gallium/drivers/d3d12/d3d12_resource.cpp | 9 ++++++++- src/gallium/drivers/d3d12/d3d12_video_buffer.cpp | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/d3d12/d3d12_resource.cpp b/src/gallium/drivers/d3d12/d3d12_resource.cpp index bcf02c3..a1d9860 100644 --- a/src/gallium/drivers/d3d12/d3d12_resource.cpp +++ b/src/gallium/drivers/d3d12/d3d12_resource.cpp @@ -255,7 +255,14 @@ init_texture(struct d3d12_screen *screen, */ } - if (screen->support_shader_images && templ->nr_samples <= 1) { + /* The VA frontend VaFourccToPipeFormat chooses _UNORM types for RGBx formats as typeless formats + * such as DXGI_R8G8B8A8_TYPELESS are not supported as Video Processor input/output as specified in: + * https://learn.microsoft.com/en-us/windows/win32/direct3ddxgi/hardware-support-for-direct3d-12-1-formats + * PIPE_BIND_CUSTOM is used by the video frontend to hint this resource will be used in video and the + * original format must be not converted to _TYPELESS + */ + if ( ((templ->bind & PIPE_BIND_CUSTOM) == 0) && + (screen->support_shader_images && templ->nr_samples <= 1)) { /* Ideally, we'd key off of PIPE_BIND_SHADER_IMAGE for this, but it doesn't * seem to be set properly. So, all UAV-capable resources need the UAV flag. */ diff --git a/src/gallium/drivers/d3d12/d3d12_video_buffer.cpp b/src/gallium/drivers/d3d12/d3d12_video_buffer.cpp index 3b6d0cb..24872be 100644 --- a/src/gallium/drivers/d3d12/d3d12_video_buffer.cpp +++ b/src/gallium/drivers/d3d12/d3d12_video_buffer.cpp @@ -58,7 +58,7 @@ d3d12_video_buffer_create_impl(struct pipe_context *pipe, pD3D12VideoBuffer->base.height = tmpl->height; pD3D12VideoBuffer->base.interlaced = tmpl->interlaced; pD3D12VideoBuffer->base.associated_data = nullptr; - pD3D12VideoBuffer->base.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET; + pD3D12VideoBuffer->base.bind = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET | PIPE_BIND_DISPLAY_TARGET | PIPE_BIND_CUSTOM; // Fill vtable pD3D12VideoBuffer->base.destroy = d3d12_video_buffer_destroy; -- 2.7.4