Conor McCarthy : vkd3d: Add DXGI_FORMAT_UNKNOWN to the array of vkd3d_format objects.
Alexandre Julliard
julliard at winehq.org
Wed Jan 19 15:52:11 CST 2022
Module: vkd3d
Branch: master
Commit: ecb854c6c1cd749929856a0daaef1ffb4ecfa713
URL: https://source.winehq.org/git/vkd3d.git/?a=commit;h=ecb854c6c1cd749929856a0daaef1ffb4ecfa713
Author: Conor McCarthy <cmccarthy at codeweavers.com>
Date: Tue Jan 18 15:07:55 2022 +1000
vkd3d: Add DXGI_FORMAT_UNKNOWN to the array of vkd3d_format objects.
This results in a valid format instead of NULL being returned for
buffers and any other case where DXGI_FORMAT_UNKNOWN is specified.
In some cases invalid use of a buffer or DXGI_FORMAT_UNKNOWN will
not result in E_INVALIDARG, and would need to be tested explicitly
if proven to be an issue.
Signed-off-by: Conor McCarthy <cmccarthy at codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
libs/vkd3d/device.c | 8 +-------
libs/vkd3d/resource.c | 8 ++++++++
libs/vkd3d/state.c | 4 ++++
libs/vkd3d/utils.c | 1 +
tests/d3d12.c | 2 +-
5 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/libs/vkd3d/device.c b/libs/vkd3d/device.c
index 4af2607..4bcb5ef 100644
--- a/libs/vkd3d/device.c
+++ b/libs/vkd3d/device.c
@@ -3726,8 +3726,6 @@ static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints(ID3D12Device *i
UINT *row_counts, UINT64 *row_sizes, UINT64 *total_bytes)
{
struct d3d12_device *device = impl_from_ID3D12Device(iface);
- static const struct vkd3d_format vkd3d_format_unknown
- = {DXGI_FORMAT_UNKNOWN, VK_FORMAT_UNDEFINED, 1, 1, 1, 1, 0};
unsigned int i, sub_resource_idx, miplevel_idx, row_count, row_size, row_pitch;
unsigned int width, height, depth, plane_count, sub_resources_per_plane;
@@ -3748,11 +3746,7 @@ static void STDMETHODCALLTYPE d3d12_device_GetCopyableFootprints(ID3D12Device *i
if (total_bytes)
*total_bytes = ~(uint64_t)0;
- if (desc->Dimension == D3D12_RESOURCE_DIMENSION_BUFFER)
- {
- format = &vkd3d_format_unknown;
- }
- else if (!(format = vkd3d_format_from_d3d12_resource_desc(device, desc, 0)))
+ if (!(format = vkd3d_format_from_d3d12_resource_desc(device, desc, 0)))
{
WARN("Invalid format %#x.\n", desc->Format);
return;
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index a4d16ee..14e08b0 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -1589,6 +1589,12 @@ static void d3d12_validate_resource_flags(D3D12_RESOURCE_FLAGS flags)
static bool d3d12_resource_validate_texture_format(const D3D12_RESOURCE_DESC *desc,
const struct vkd3d_format *format)
{
+ if (desc->Format == DXGI_FORMAT_UNKNOWN)
+ {
+ WARN("DXGI_FORMAT_UNKNOWN is invalid for textures.\n");
+ return false;
+ }
+
if (!vkd3d_format_is_compressed(format))
return true;
@@ -2273,6 +2279,8 @@ static bool vkd3d_create_buffer_view_for_resource(struct d3d12_device *device,
}
else if ((format = vkd3d_format_from_d3d12_resource_desc(device, &resource->desc, view_format)))
{
+ /* TODO: if view_format is DXGI_FORMAT_UNKNOWN, this is always 1, which
+ * may not match driver behaviour (return false?). */
element_size = format->byte_count;
}
else
diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c
index 10503a6..b54a652 100644
--- a/libs/vkd3d/state.c
+++ b/libs/vkd3d/state.c
@@ -2328,6 +2328,8 @@ static HRESULT compute_input_layout_offsets(const struct d3d12_device *device,
return E_INVALIDARG;
}
+ /* TODO: DXGI_FORMAT_UNKNOWN will return a format with byte_count == 1,
+ * which may not match driver behaviour (return E_INVALIDARG?). */
if (!(format = vkd3d_get_format(device, e->Format, false)))
{
WARN("Invalid input element format %#x.\n", e->Format);
@@ -2816,6 +2818,8 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s
const D3D12_INPUT_ELEMENT_DESC *e = &desc->InputLayout.pInputElementDescs[i];
const struct vkd3d_shader_signature_element *signature_element;
+ /* TODO: DXGI_FORMAT_UNKNOWN will succeed here, which may not match
+ * driver behaviour (return E_INVALIDARG?). */
if (!(format = vkd3d_get_format(device, e->Format, false)))
{
WARN("Invalid input element format %#x.\n", e->Format);
diff --git a/libs/vkd3d/utils.c b/libs/vkd3d/utils.c
index ec2b4b3..cdb81f6 100644
--- a/libs/vkd3d/utils.c
+++ b/libs/vkd3d/utils.c
@@ -29,6 +29,7 @@
#define UINT VKD3D_FORMAT_TYPE_UINT
static const struct vkd3d_format vkd3d_formats[] =
{
+ {DXGI_FORMAT_UNKNOWN, VK_FORMAT_UNDEFINED, 1, 1, 1, 1},
{DXGI_FORMAT_R32G32B32A32_TYPELESS, VK_FORMAT_R32G32B32A32_SFLOAT, 16, 1, 1, 1, COLOR, 1, TYPELESS},
{DXGI_FORMAT_R32G32B32A32_FLOAT, VK_FORMAT_R32G32B32A32_SFLOAT, 16, 1, 1, 1, COLOR, 1},
{DXGI_FORMAT_R32G32B32A32_UINT, VK_FORMAT_R32G32B32A32_UINT, 16, 1, 1, 1, COLOR, 1, UINT},
diff --git a/tests/d3d12.c b/tests/d3d12.c
index 3540c9a..b12d6a9 100644
--- a/tests/d3d12.c
+++ b/tests/d3d12.c
@@ -1167,7 +1167,7 @@ static void test_format_support(void)
memset(&format_support, 0, sizeof(format_support));
hr = ID3D12Device_CheckFeatureSupport(device, D3D12_FEATURE_FORMAT_SUPPORT,
&format_support, sizeof(format_support));
- todo ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
+ ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
todo ok(format_support.Support1 == D3D12_FORMAT_SUPPORT1_BUFFER,
"Got unexpected support1 %#x.\n", format_support.Support1);
ok(!format_support.Support2 || format_support.Support2 == D3D12_FORMAT_SUPPORT2_TILED,
More information about the wine-cvs
mailing list