mirror of
https://github.com/EduApps-CDG/OpenDX
synced 2024-12-30 09:45:37 +01:00
[dxbc] Use OpDemoteToHelperInvocationEXT for discards if supported
This commit is contained in:
parent
e901e1269d
commit
8644d75722
@ -4047,9 +4047,15 @@ namespace dxvk {
|
|||||||
m_module.opSelectionMerge(cond.labelEnd, spv::SelectionControlMaskNone);
|
m_module.opSelectionMerge(cond.labelEnd, spv::SelectionControlMaskNone);
|
||||||
m_module.opBranchConditional(zeroTest.id, cond.labelIf, cond.labelEnd);
|
m_module.opBranchConditional(zeroTest.id, cond.labelIf, cond.labelEnd);
|
||||||
|
|
||||||
// OpKill terminates the block
|
|
||||||
m_module.opLabel(cond.labelIf);
|
m_module.opLabel(cond.labelIf);
|
||||||
m_module.opKill();
|
|
||||||
|
if (m_moduleInfo.options.useDemoteToHelperInvocation) {
|
||||||
|
m_module.opDemoteToHelperInvocation();
|
||||||
|
m_module.opBranch(cond.labelEnd);
|
||||||
|
} else {
|
||||||
|
// OpKill terminates the block
|
||||||
|
m_module.opKill();
|
||||||
|
}
|
||||||
|
|
||||||
m_module.opLabel(cond.labelEnd);
|
m_module.opLabel(cond.labelEnd);
|
||||||
} else {
|
} else {
|
||||||
@ -6621,9 +6627,13 @@ namespace dxvk {
|
|||||||
m_module.defVoidType(), 0, nullptr));
|
m_module.defVoidType(), 0, nullptr));
|
||||||
this->emitFunctionLabel();
|
this->emitFunctionLabel();
|
||||||
|
|
||||||
// We may have to defer kill operations to the end of
|
if (m_analysis->usesKill && m_moduleInfo.options.useDemoteToHelperInvocation) {
|
||||||
// the shader in order to keep derivatives correct.
|
// This extension basically implements D3D-style discard
|
||||||
if (m_analysis->usesKill && m_analysis->usesDerivatives) {
|
m_module.enableExtension("SPV_EXT_demote_to_helper_invocation");
|
||||||
|
m_module.enableCapability(spv::CapabilityDemoteToHelperInvocationEXT);
|
||||||
|
} else if (m_analysis->usesKill && m_analysis->usesDerivatives) {
|
||||||
|
// We may have to defer kill operations to the end of
|
||||||
|
// the shader in order to keep derivatives correct.
|
||||||
m_ps.killState = m_module.newVarInit(
|
m_ps.killState = m_module.newVarInit(
|
||||||
m_module.defPointerType(m_module.defBoolType(), spv::StorageClassPrivate),
|
m_module.defPointerType(m_module.defBoolType(), spv::StorageClassPrivate),
|
||||||
spv::StorageClassPrivate, m_module.constBool(false));
|
spv::StorageClassPrivate, m_module.constBool(false));
|
||||||
|
@ -24,6 +24,8 @@ namespace dxvk {
|
|||||||
useSubgroupOpsForAtomicCounters
|
useSubgroupOpsForAtomicCounters
|
||||||
= (devInfo.coreSubgroup.supportedStages & allShaderStages) == allShaderStages
|
= (devInfo.coreSubgroup.supportedStages & allShaderStages) == allShaderStages
|
||||||
&& (devInfo.coreSubgroup.supportedOperations & VK_SUBGROUP_FEATURE_BALLOT_BIT);
|
&& (devInfo.coreSubgroup.supportedOperations & VK_SUBGROUP_FEATURE_BALLOT_BIT);
|
||||||
|
useDemoteToHelperInvocation
|
||||||
|
= (devFeatures.extShaderDemoteToHelperInvocation.shaderDemoteToHelperInvocation);
|
||||||
useSubgroupOpsForEarlyDiscard
|
useSubgroupOpsForEarlyDiscard
|
||||||
= (devInfo.coreSubgroup.subgroupSize >= 4)
|
= (devInfo.coreSubgroup.subgroupSize >= 4)
|
||||||
&& (devInfo.coreSubgroup.supportedStages & VK_SHADER_STAGE_FRAGMENT_BIT)
|
&& (devInfo.coreSubgroup.supportedStages & VK_SHADER_STAGE_FRAGMENT_BIT)
|
||||||
|
@ -21,6 +21,9 @@ namespace dxvk {
|
|||||||
/// atomic operations for append/consume buffers.
|
/// atomic operations for append/consume buffers.
|
||||||
bool useSubgroupOpsForAtomicCounters = false;
|
bool useSubgroupOpsForAtomicCounters = false;
|
||||||
|
|
||||||
|
/// Use a SPIR-V extension to implement D3D-style discards
|
||||||
|
bool useDemoteToHelperInvocation = false;
|
||||||
|
|
||||||
/// Use subgroup operations to discard fragment
|
/// Use subgroup operations to discard fragment
|
||||||
/// shader invocations if derivatives remain valid.
|
/// shader invocations if derivatives remain valid.
|
||||||
bool useSubgroupOpsForEarlyDiscard = false;
|
bool useSubgroupOpsForEarlyDiscard = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user