[d3d11] Ensure that all required inputs are defined by input layout

This commit is contained in:
Philip Rebohle 2022-08-10 14:12:39 +02:00
parent 5540df955c
commit 3edb0ef114
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
1 changed files with 15 additions and 1 deletions

View File

@ -591,7 +591,10 @@ namespace dxvk {
ID3D11InputLayout** ppInputLayout) {
InitReturnPtr(ppInputLayout);
if (pInputElementDescs == nullptr)
// This check is somehow even correct, passing null with zero
// size will always fail but passing non-null with zero size
// works, provided the shader does not have any actual inputs
if (!pInputElementDescs)
return E_INVALIDARG;
try {
@ -603,6 +606,7 @@ namespace dxvk {
uint32_t attrMask = 0;
uint32_t bindMask = 0;
uint32_t locationMask = 0;
uint32_t bindingsDefined = 0;
std::array<DxvkVertexAttribute, D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT> attrList = { };
@ -669,9 +673,19 @@ namespace dxvk {
if (entry) {
attrMask |= 1u << i;
bindMask |= 1u << binding.binding;
locationMask |= 1u << attrib.location;
}
}
// Ensure that all inputs used by the shader are defined
for (auto i = inputSignature->begin(); i != inputSignature->end(); i++) {
bool isBuiltIn = DxbcIsgn::compareSemanticNames(i->semanticName, "sv_instanceid")
|| DxbcIsgn::compareSemanticNames(i->semanticName, "sv_vertexid");
if (!isBuiltIn && !(locationMask & (1u << i->registerId)))
return E_INVALIDARG;
}
// Compact the attribute and binding lists to filter
// out attributes and bindings not used by the shader
uint32_t attrCount = CompactSparseList(attrList.data(), attrMask);