mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-02 01:24:11 +01:00
[dxbc] Declare temp registers on demand
And ignore dcl_temps. Needed to successfully compile some broken ENB shaders (this does work on Windows too). See #865.
This commit is contained in:
parent
ee77afb6af
commit
3e12a116bb
@ -364,24 +364,8 @@ namespace dxvk {
|
|||||||
void DxbcCompiler::emitDclTemps(const DxbcShaderInstruction& ins) {
|
void DxbcCompiler::emitDclTemps(const DxbcShaderInstruction& ins) {
|
||||||
// dcl_temps has one operand:
|
// dcl_temps has one operand:
|
||||||
// (imm0) Number of temp registers
|
// (imm0) Number of temp registers
|
||||||
const uint32_t oldCount = m_rRegs.size();
|
|
||||||
const uint32_t newCount = ins.imm[0].u32;
|
|
||||||
|
|
||||||
if (newCount > oldCount) {
|
// Ignore this and declare temps on demand.
|
||||||
m_rRegs.resize(newCount);
|
|
||||||
|
|
||||||
DxbcRegisterInfo info;
|
|
||||||
info.type.ctype = DxbcScalarType::Float32;
|
|
||||||
info.type.ccount = 4;
|
|
||||||
info.type.alength = 0;
|
|
||||||
info.sclass = spv::StorageClassPrivate;
|
|
||||||
|
|
||||||
for (uint32_t i = oldCount; i < newCount; i++) {
|
|
||||||
const uint32_t varId = this->emitNewVariable(info);
|
|
||||||
m_module.setDebugName(varId, str::format("r", i).c_str());
|
|
||||||
m_rRegs.at(i) = varId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4684,10 +4668,29 @@ namespace dxvk {
|
|||||||
const DxbcRegister& operand) {
|
const DxbcRegister& operand) {
|
||||||
// r# regs are indexed as follows:
|
// r# regs are indexed as follows:
|
||||||
// (0) register index (immediate)
|
// (0) register index (immediate)
|
||||||
|
uint32_t regIdx = operand.idx[0].offset;
|
||||||
|
|
||||||
|
if (regIdx >= m_rRegs.size())
|
||||||
|
m_rRegs.resize(regIdx + 1, 0u);
|
||||||
|
|
||||||
|
if (!m_rRegs.at(regIdx)) {
|
||||||
|
DxbcRegisterInfo info;
|
||||||
|
info.type.ctype = DxbcScalarType::Float32;
|
||||||
|
info.type.ccount = 4;
|
||||||
|
info.type.alength = 0;
|
||||||
|
info.sclass = spv::StorageClassPrivate;
|
||||||
|
|
||||||
|
uint32_t varId = emitNewVariable(info);
|
||||||
|
m_rRegs.at(regIdx) = varId;
|
||||||
|
|
||||||
|
m_module.setDebugName(varId,
|
||||||
|
str::format("r", regIdx).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
DxbcRegisterPointer result;
|
DxbcRegisterPointer result;
|
||||||
result.type.ctype = DxbcScalarType::Float32;
|
result.type.ctype = DxbcScalarType::Float32;
|
||||||
result.type.ccount = 4;
|
result.type.ccount = 4;
|
||||||
result.id = m_rRegs.at(operand.idx[0].offset);
|
result.id = m_rRegs.at(regIdx);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user