mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-02 01:24:11 +01:00
[dxbc] Implement geometry shader instancing
Required for Frostpunk (see #385).
This commit is contained in:
parent
7f619d9051
commit
fb11acbc91
@ -277,6 +277,9 @@ namespace dxvk {
|
||||
case DxbcOpcode::DclThreadGroup:
|
||||
return this->emitDclThreadGroup(ins);
|
||||
|
||||
case DxbcOpcode::DclGsInstanceCount:
|
||||
return this->emitDclGsInstanceCount(ins);
|
||||
|
||||
default:
|
||||
Logger::warn(
|
||||
str::format("DxbcCompiler: Unhandled opcode: ",
|
||||
@ -545,6 +548,14 @@ namespace dxvk {
|
||||
// output arrays, so there's nothing left to do.
|
||||
} break;
|
||||
|
||||
case DxbcOperandType::InputGsInstanceId: {
|
||||
m_gs.builtinInvocationId = emitNewBuiltinVariable({
|
||||
{ DxbcScalarType::Uint32, 1, 0 },
|
||||
spv::StorageClassInput },
|
||||
spv::BuiltInInvocationId,
|
||||
"vInstanceID");
|
||||
} break;
|
||||
|
||||
default:
|
||||
Logger::err(str::format(
|
||||
"DxbcCompiler: Unsupported operand type declaration: ",
|
||||
@ -1219,6 +1230,13 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
void DxbcCompiler::emitDclGsInstanceCount(const DxbcShaderInstruction& ins) {
|
||||
// dcl_gs_instance_count has one operand:
|
||||
// (imm0) Number of geometry shader invocations
|
||||
m_module.setInvocations(m_entryPointId, ins.imm[0].u32);
|
||||
}
|
||||
|
||||
|
||||
uint32_t DxbcCompiler::emitDclUavCounter(uint32_t regId) {
|
||||
// Declare a structure type which holds the UAV counter
|
||||
if (m_uavCtrStructType == 0) {
|
||||
@ -4282,6 +4300,11 @@ namespace dxvk {
|
||||
return DxbcRegisterPointer {
|
||||
{ DxbcScalarType::Uint32, 1 },
|
||||
getCurrentHsForkJoinPhase()->instanceIdPtr };
|
||||
|
||||
case DxbcOperandType::InputGsInstanceId:
|
||||
return DxbcRegisterPointer {
|
||||
{ DxbcScalarType::Uint32, 1 },
|
||||
m_gs.builtinInvocationId };
|
||||
|
||||
default:
|
||||
throw DxvkError(str::format(
|
||||
|
@ -120,6 +120,7 @@ namespace dxvk {
|
||||
|
||||
uint32_t builtinLayer = 0;
|
||||
uint32_t builtinViewportId = 0;
|
||||
uint32_t builtinInvocationId = 0;
|
||||
};
|
||||
|
||||
|
||||
@ -514,6 +515,9 @@ namespace dxvk {
|
||||
void emitDclThreadGroup(
|
||||
const DxbcShaderInstruction& ins);
|
||||
|
||||
void emitDclGsInstanceCount(
|
||||
const DxbcShaderInstruction& ins);
|
||||
|
||||
uint32_t emitDclUavCounter(
|
||||
uint32_t regId);
|
||||
|
||||
|
@ -999,7 +999,9 @@ namespace dxvk {
|
||||
{ DxbcOperandKind::SrcReg, DxbcScalarType::Float32 },
|
||||
} },
|
||||
/* DclGsInstanceCount */
|
||||
{ },
|
||||
{ 1, DxbcInstClass::Declaration, {
|
||||
{ DxbcOperandKind::Imm32, DxbcScalarType::Uint32 },
|
||||
} },
|
||||
}};
|
||||
|
||||
|
||||
|
@ -92,6 +92,16 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
void SpirvModule::setInvocations(
|
||||
uint32_t entryPointId,
|
||||
uint32_t invocations) {
|
||||
m_execModeInfo.putIns (spv::OpExecutionMode, 4);
|
||||
m_execModeInfo.putWord (entryPointId);
|
||||
m_execModeInfo.putWord (spv::ExecutionModeInvocations);
|
||||
m_execModeInfo.putInt32(invocations);
|
||||
}
|
||||
|
||||
|
||||
void SpirvModule::setLocalSize(
|
||||
uint32_t entryPointId,
|
||||
uint32_t x,
|
||||
|
@ -79,6 +79,10 @@ namespace dxvk {
|
||||
uint32_t entryPointId,
|
||||
spv::ExecutionMode executionMode);
|
||||
|
||||
void setInvocations(
|
||||
uint32_t entryPointId,
|
||||
uint32_t invocations);
|
||||
|
||||
void setLocalSize(
|
||||
uint32_t entryPointId,
|
||||
uint32_t x,
|
||||
|
Loading…
Reference in New Issue
Block a user