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

[dxbc] Generate smallest possible vectors for local arrays

FXC is buggy and always emits vec4 in the array declaration,
so we'll have to analyze the used components ourselves.
This commit is contained in:
Philip Rebohle 2022-03-24 12:43:39 +01:00
parent b2f22d5719
commit c590736fec
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 15 additions and 6 deletions

View File

@ -78,7 +78,14 @@ namespace dxvk {
} break;
default:
return;
break;
}
for (uint32_t i = 0; i < ins.dstCount; i++) {
if (ins.dst[0].type == DxbcOperandType::IndexableTemp) {
uint32_t index = ins.dst[0].idx[0].offset;
m_analysis->xRegMasks[index] |= ins.dst[0].mask;
}
}
}

View File

@ -35,6 +35,7 @@ namespace dxvk {
*/
struct DxbcAnalysisInfo {
std::array<DxbcUavInfo, 64> uavInfos;
std::array<DxbcRegMask, 4096> xRegMasks;
DxbcClipCullInfo clipCullIn;
DxbcClipCullInfo clipCullOut;

View File

@ -381,15 +381,16 @@ namespace dxvk {
// dcl_indexable_temps has three operands:
// (imm0) Array register index (x#)
// (imm1) Number of vectors stored in the array
// (imm2) Component count of each individual vector
// (imm2) Component count of each individual vector. This is
// always 4 in fxc-generated binaries and therefore useless.
const uint32_t regId = ins.imm[0].u32;
DxbcRegisterInfo info;
info.type.ctype = DxbcScalarType::Float32;
info.type.ccount = ins.imm[2].u32;
info.type.ccount = m_analysis->xRegMasks.at(regId).minComponents();
info.type.alength = ins.imm[1].u32;
info.sclass = spv::StorageClassPrivate;
const uint32_t regId = ins.imm[0].u32;
if (regId >= m_xRegs.size())
m_xRegs.resize(regId + 1);