From: Józef Kucia Subject: [PATCH vkd3d 4/7] vkd3d: Validate RTV format for inactive render targets in pipeline state desc. Message-Id: <20181213092842.17876-4-joseph.kucia@gmail.com> Date: Thu, 13 Dec 2018 10:28:39 +0100 From: Józef Kucia Signed-off-by: Józef Kucia --- libs/vkd3d/state.c | 9 +++++++++ tests/d3d12.c | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/libs/vkd3d/state.c b/libs/vkd3d/state.c index 9c2d3ac114cd..b2f177c9798d 100644 --- a/libs/vkd3d/state.c +++ b/libs/vkd3d/state.c @@ -1945,6 +1945,15 @@ static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *s memset(&input_signature, 0, sizeof(input_signature)); + for (i = desc->NumRenderTargets; i < ARRAY_SIZE(desc->RTVFormats); ++i) + { + if (desc->RTVFormats[i] != DXGI_FORMAT_UNKNOWN) + { + WARN("Format must be set to DXGI_FORMAT_UNKNOWN for inactive render targets.\n"); + return E_INVALIDARG; + } + } + if (!(root_signature = unsafe_impl_from_ID3D12RootSignature(desc->pRootSignature))) { WARN("Root signature is NULL.\n"); diff --git a/tests/d3d12.c b/tests/d3d12.c index 420d7519de88..b96ca430361f 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -2491,6 +2491,13 @@ static void test_create_graphics_pipeline_state(void) ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); ID3D12PipelineState_Release(pipeline_state); + /* Inactive render targets formats must be set to DXGI_FORMAT_UNKNOWN. */ + init_pipeline_state_desc(&pso_desc, root_signature, DXGI_FORMAT_R8G8B8A8_UNORM, NULL, NULL, NULL); + pso_desc.RTVFormats[1] = DXGI_FORMAT_R8G8B8A8_UNORM; + hr = ID3D12Device_CreateGraphicsPipelineState(device, &pso_desc, + &IID_ID3D12PipelineState, (void **)&pipeline_state); + ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); + refcount = ID3D12RootSignature_Release(root_signature); ok(!refcount, "ID3D12RootSignature has %u references left.\n", (unsigned int)refcount); refcount = ID3D12Device_Release(device); -- 2.19.2