From 55ebe380441bfd456256e38e405671e24a73653b Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 5 Feb 2018 11:46:03 +0000 Subject: [PATCH] Fix replay of ID3D11Device::CreateInputLayout with no input elements * ID3D11Device::CreateInputLayout will fail if we pass a NULL descriptor array pointer, even though 0xdeadbeef will work so it doesn't actually use the pointer at all. --- renderdoc/driver/d3d11/d3d11_device_wrap.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/renderdoc/driver/d3d11/d3d11_device_wrap.cpp b/renderdoc/driver/d3d11/d3d11_device_wrap.cpp index 409a40b67..97f513433 100644 --- a/renderdoc/driver/d3d11/d3d11_device_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_device_wrap.cpp @@ -1242,9 +1242,14 @@ bool WrappedID3D11Device::Serialise_CreateInputLayout( if(IsReplayingAndReading()) { + // for no explicable reason, CreateInputLayout requires a descriptor pointer even if + // NumElements==0. + D3D11_INPUT_ELEMENT_DESC dummy = {}; + const D3D11_INPUT_ELEMENT_DESC *inputDescs = pInputElementDescs ? pInputElementDescs : &dummy; + ID3D11InputLayout *ret = NULL; HRESULT hr = m_pDevice->CreateInputLayout( - pInputElementDescs, NumElements, pShaderBytecodeWithInputSignature, BytecodeLength, &ret); + inputDescs, NumElements, pShaderBytecodeWithInputSignature, BytecodeLength, &ret); if(FAILED(hr)) { @@ -1260,8 +1265,9 @@ bool WrappedID3D11Device::Serialise_CreateInputLayout( AddResource(pInputLayout, ResourceType::StateObject, "Input Layout"); - m_LayoutDescs[ret] = - std::vector(pInputElementDescs, pInputElementDescs + NumElements); + if(NumElements > 0) + m_LayoutDescs[ret] = std::vector(pInputElementDescs, + pInputElementDescs + NumElements); if(BytecodeLength > 0 && pShaderBytecodeWithInputSignature) m_LayoutShaders[ret] =