1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 02:52:10 +01:00

[d3d11] Implemented D3D11_APPEND_ALIGNED_ELEMENT

This commit is contained in:
Philip Rebohle 2017-12-18 23:24:10 +01:00
parent 13d4a3d87d
commit 2b6cb25675
2 changed files with 17 additions and 5 deletions

View File

@ -561,10 +561,22 @@ namespace dxvk {
pInputElementDescs[i].Format).actual;
attrib.offset = pInputElementDescs[i].AlignedByteOffset;
// TODO implement D3D11_APPEND_ALIGNED_ELEMENT
// The application may choose to let the implementation
// 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.
if (attrib.offset == D3D11_APPEND_ALIGNED_ELEMENT) {
Logger::err("D3D11Device::CreateInputLayout: D3D11_APPEND_ALIGNED_ELEMENT not supported yet");
return E_INVALIDARG;
attrib.offset = 0;
for (uint32_t j = 1; j <= i; j++) {
const DxvkVertexAttribute& prev = attributes.at(i - j);
if (prev.binding == attrib.binding) {
const DxvkFormatInfo* formatInfo = imageFormatInfo(prev.format);
attrib.offset = align(prev.offset + formatInfo->elementSize, 4);
break;
}
}
}
attributes.push_back(attrib);

View File

@ -9,8 +9,8 @@ namespace dxvk {
return n;
}
template<typename T>
T align(T what, T to) {
template<typename T, typename U = T>
T align(T what, U to) {
return (what + to - 1) & ~(to - 1);
}