1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-11 10:24:10 +01:00

[dxvk] Validate vertex attribute alignment

This commit is contained in:
Philip Rebohle 2021-02-08 14:55:18 +01:00
parent a045cac281
commit bcadc04932
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99

View File

@ -611,6 +611,9 @@ namespace dxvk {
// generate the exact vertex layout. In that case we'll
// pack attributes on the same binding in the order they
// are declared, aligning each attribute to four bytes.
const DxvkFormatInfo* formatInfo = imageFormatInfo(attrib.format);
VkDeviceSize alignment = std::min<VkDeviceSize>(formatInfo->elementSize, 4);
if (attrib.offset == D3D11_APPEND_ALIGNED_ELEMENT) {
attrib.offset = 0;
@ -618,13 +621,12 @@ namespace dxvk {
const DxvkVertexAttribute& prev = attrList.at(i - j);
if (prev.binding == attrib.binding) {
const DxvkFormatInfo* formatInfo = imageFormatInfo(prev.format);
VkDeviceSize alignment = std::min<VkDeviceSize>(formatInfo->elementSize, 4);
attrib.offset = align(prev.offset + formatInfo->elementSize, alignment);
attrib.offset = align(prev.offset + imageFormatInfo(prev.format)->elementSize, alignment);
break;
}
}
}
} else if (attrib.offset & (alignment - 1))
return E_INVALIDARG;
attrList.at(i) = attrib;