1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-03-15 07:29:17 +01:00

[dxbc] Implement stencil ref export from fragment shaders

This is an optional feature in D3D11.3, but easy enough to support.
This commit is contained in:
Philip Rebohle 2019-09-15 14:56:23 +02:00
parent b7bc51c3bd
commit 17a6c4168e
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
4 changed files with 21 additions and 1 deletions

View File

@ -1367,10 +1367,11 @@ namespace dxvk {
if (FeatureSupportDataSize != sizeof(D3D11_FEATURE_DATA_D3D11_OPTIONS2)) if (FeatureSupportDataSize != sizeof(D3D11_FEATURE_DATA_D3D11_OPTIONS2))
return E_INVALIDARG; return E_INVALIDARG;
const auto& extensions = m_dxvkDevice->extensions();
const auto& features = m_dxvkDevice->features(); const auto& features = m_dxvkDevice->features();
auto info = static_cast<D3D11_FEATURE_DATA_D3D11_OPTIONS2*>(pFeatureSupportData); auto info = static_cast<D3D11_FEATURE_DATA_D3D11_OPTIONS2*>(pFeatureSupportData);
info->PSSpecifiedStencilRefSupported = FALSE; // TODO info->PSSpecifiedStencilRefSupported = extensions.extShaderStencilExport;
info->TypedUAVLoadAdditionalFormats = features.core.features.shaderStorageImageReadWithoutFormat; info->TypedUAVLoadAdditionalFormats = features.core.features.shaderStorageImageReadWithoutFormat;
info->ROVsSupported = FALSE; info->ROVsSupported = FALSE;
info->ConservativeRasterizationTier = D3D11_CONSERVATIVE_RASTERIZATION_NOT_SUPPORTED; info->ConservativeRasterizationTier = D3D11_CONSERVATIVE_RASTERIZATION_NOT_SUPPORTED;

View File

@ -554,6 +554,18 @@ namespace dxvk {
"oDepth"); "oDepth");
} break; } break;
case DxbcOperandType::OutputStencilRef: {
m_module.enableExtension("SPV_EXT_shader_stencil_export");
m_module.enableCapability(spv::CapabilityStencilExportEXT);
m_module.setExecutionMode(m_entryPointId,
spv::ExecutionModeStencilRefReplacingEXT);
m_ps.builtinStencilRef = emitNewBuiltinVariable({
{ DxbcScalarType::Sint32, 1, 0 },
spv::StorageClassOutput },
spv::BuiltInFragStencilRefEXT,
"oStencilRef");
} break;
case DxbcOperandType::OutputDepthGe: { case DxbcOperandType::OutputDepthGe: {
m_module.setExecutionMode(m_entryPointId, spv::ExecutionModeDepthReplacing); m_module.setExecutionMode(m_entryPointId, spv::ExecutionModeDepthReplacing);
m_module.setExecutionMode(m_entryPointId, spv::ExecutionModeDepthGreater); m_module.setExecutionMode(m_entryPointId, spv::ExecutionModeDepthGreater);
@ -4860,6 +4872,11 @@ namespace dxvk {
{ DxbcScalarType::Float32, 1 }, { DxbcScalarType::Float32, 1 },
m_ps.builtinDepth }; m_ps.builtinDepth };
case DxbcOperandType::OutputStencilRef:
return DxbcRegisterPointer {
{ DxbcScalarType::Sint32, 1 },
m_ps.builtinStencilRef };
case DxbcOperandType::InputPrimitiveId: case DxbcOperandType::InputPrimitiveId:
return DxbcRegisterPointer { return DxbcRegisterPointer {
{ DxbcScalarType::Uint32, 1 }, { DxbcScalarType::Uint32, 1 },

View File

@ -171,6 +171,7 @@ namespace dxvk {
uint32_t builtinFragCoord = 0; uint32_t builtinFragCoord = 0;
uint32_t builtinDepth = 0; uint32_t builtinDepth = 0;
uint32_t builtinStencilRef = 0;
uint32_t builtinIsFrontFace = 0; uint32_t builtinIsFrontFace = 0;
uint32_t builtinSampleId = 0; uint32_t builtinSampleId = 0;
uint32_t builtinSampleMaskIn = 0; uint32_t builtinSampleMaskIn = 0;

View File

@ -288,6 +288,7 @@ namespace dxvk {
OutputDepthGe = 38, OutputDepthGe = 38,
OutputDepthLe = 39, OutputDepthLe = 39,
CycleCounter = 40, CycleCounter = 40,
OutputStencilRef = 41,
}; };