DxilConv: Pad copied IO signature parts (#4330)
DXBC containers from some sources may have signature parts with unaligned sizes, such as from 9on12. This change pads these signature parts when this is the case to avoid any problems down the line.
This commit is contained in:
Родитель
14bc8dab53
Коммит
e51701e707
|
@ -289,8 +289,13 @@ void DxbcConverter::ConvertImpl(_In_reads_bytes_(DxbcSize) LPCVOID pDxbc,
|
|||
IFT(dxbcReader.FindFirstPartKind(IOSigFourCCArray[i], &uBlob));
|
||||
if(uBlob != DXIL_CONTAINER_BLOB_NOT_FOUND) {
|
||||
IFT(dxbcReader.GetPartContent(uBlob, &pBlobData, &uElemSize));
|
||||
pContainerWriter->AddPart(IOSigFourCCArray[i], uElemSize, [=](AbstractMemoryStream *pStream) {
|
||||
pContainerWriter->AddPart(IOSigFourCCArray[i], PSVALIGN4(uElemSize), [=](AbstractMemoryStream *pStream) {
|
||||
WritePart(pStream, pBlobData, uElemSize);
|
||||
unsigned padding = PSVALIGN4(uElemSize) - uElemSize;
|
||||
if (padding) {
|
||||
const char padZeros[4] = {0,0,0,0};
|
||||
WritePart(pStream, padZeros, padding);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Двоичный файл не отображается.
|
@ -0,0 +1,15 @@
|
|||
// RUN: %dxbc2dxil %t.bin /o %t.dxo.converted
|
||||
// RUN: %dxa --listparts %t.dxo.converted | %FileCheck %s
|
||||
|
||||
// This file has no HLSL source, it is a binary shader result from 9on12.
|
||||
// There should be a corresponding .bin file checked in next to this one.
|
||||
|
||||
// Original DXBC has unaligned sizes for ISG1 and OSG1:
|
||||
// Part count: 3
|
||||
// #0 - ISG1 (49 bytes)
|
||||
// #1 - OSG1 (93 bytes)
|
||||
// #2 - SHDR (444 bytes)
|
||||
|
||||
// Make sure converted DXIL pads the parts for alignment:
|
||||
// CHECK: ISG1 (52 bytes)
|
||||
// CHECK: OSG1 (96 bytes)
|
|
@ -235,6 +235,9 @@ bool DxilConvTest::InitSupport() {
|
|||
if (!FindToolInBinDir("%opt-exe", "opt.exe")) {
|
||||
return false;
|
||||
}
|
||||
if (!FindToolInBinDir("%dxa", "dxa.exe")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче