diff --git a/dxvk.conf b/dxvk.conf index 473ca91bd..626c187a6 100644 --- a/dxvk.conf +++ b/dxvk.conf @@ -208,6 +208,7 @@ # Supported values: True, False # d3d11.forceSampleRateShading = False +# d3d9.forceSampleRateShading = False # Forces the sample count of all textures to 1, and performs diff --git a/src/d3d9/d3d9_fixed_function.cpp b/src/d3d9/d3d9_fixed_function.cpp index c24cf064e..f8225222e 100644 --- a/src/d3d9/d3d9_fixed_function.cpp +++ b/src/d3d9/d3d9_fixed_function.cpp @@ -14,6 +14,7 @@ namespace dxvk { D3D9FixedFunctionOptions::D3D9FixedFunctionOptions(const D3D9Options* options) { invariantPosition = options->invariantPosition; + forceSampleRateShading = options->forceSampleRateShading; } uint32_t DoFixedFunctionFog(D3D9ShaderSpecConstantManager& spec, SpirvModule& spvModule, const D3D9FogContext& fogCtx) { @@ -933,10 +934,16 @@ namespace dxvk { uint32_t ptr = m_module.newVar(ptrType, storageClass); - if (builtin == spv::BuiltInMax) + if (builtin == spv::BuiltInMax) { m_module.decorateLocation(ptr, slot); - else + + if (isPS() && input && m_options.forceSampleRateShading) { + m_module.enableCapability(spv::CapabilitySampleRateShading); + m_module.decorate(ptr, spv::DecorationSample); + } + } else { m_module.decorateBuiltIn(ptr, builtin); + } bool diffuseOrSpec = semantic == DxsoSemantic{ DxsoUsage::Color, 0 } || semantic == DxsoSemantic{ DxsoUsage::Color, 1 }; diff --git a/src/d3d9/d3d9_fixed_function.h b/src/d3d9/d3d9_fixed_function.h index a75458713..104f044cd 100644 --- a/src/d3d9/d3d9_fixed_function.h +++ b/src/d3d9/d3d9_fixed_function.h @@ -49,6 +49,7 @@ namespace dxvk { D3D9FixedFunctionOptions(const D3D9Options* options); bool invariantPosition; + bool forceSampleRateShading; }; // Returns new oFog if VS diff --git a/src/d3d9/d3d9_options.cpp b/src/d3d9/d3d9_options.cpp index 33938c4f7..0ecb38953 100644 --- a/src/d3d9/d3d9_options.cpp +++ b/src/d3d9/d3d9_options.cpp @@ -63,6 +63,7 @@ namespace dxvk { this->enableDialogMode = config.getOption ("d3d9.enableDialogMode", false); this->forceSamplerTypeSpecConstants = config.getOption ("d3d9.forceSamplerTypeSpecConstants", false); this->forceSwapchainMSAA = config.getOption ("d3d9.forceSwapchainMSAA", -1); + this->forceSampleRateShading = config.getOption ("d3d9.forceSampleRateShading", false); this->forceAspectRatio = config.getOption ("d3d9.forceAspectRatio", ""); this->allowDiscard = config.getOption ("d3d9.allowDiscard", true); this->enumerateByDisplays = config.getOption ("d3d9.enumerateByDisplays", true); diff --git a/src/d3d9/d3d9_options.h b/src/d3d9/d3d9_options.h index 43fcbb954..592c27d18 100644 --- a/src/d3d9/d3d9_options.h +++ b/src/d3d9/d3d9_options.h @@ -123,6 +123,9 @@ namespace dxvk { /// Forces an MSAA level on the swapchain int32_t forceSwapchainMSAA; + /// Forces sample rate shading + bool forceSampleRateShading; + /// Allow D3DLOCK_DISCARD bool allowDiscard; diff --git a/src/dxso/dxso_compiler.cpp b/src/dxso/dxso_compiler.cpp index 8b9b16dd3..f453f8172 100644 --- a/src/dxso/dxso_compiler.cpp +++ b/src/dxso/dxso_compiler.cpp @@ -3192,6 +3192,12 @@ void DxsoCompiler::emitControlFlowGenericLoop( m_module.decorateLocation(inputPtr.id, slot); + if (m_programInfo.type() == DxsoProgramType::PixelShader + && m_moduleInfo.options.forceSampleRateShading) { + m_module.enableCapability(spv::CapabilitySampleRateShading); + m_module.decorate(inputPtr.id, spv::DecorationSample); + } + std::string name = str::format("in_", elem.semantic.usage, elem.semantic.usageIndex); m_module.setDebugName(inputPtr.id, name.c_str()); diff --git a/src/dxso/dxso_options.cpp b/src/dxso/dxso_options.cpp index 163c39b96..d9f7834ed 100644 --- a/src/dxso/dxso_options.cpp +++ b/src/dxso/dxso_options.cpp @@ -25,6 +25,7 @@ namespace dxvk { invariantPosition = options.invariantPosition; forceSamplerTypeSpecConstants = options.forceSamplerTypeSpecConstants; + forceSampleRateShading = options.forceSampleRateShading; vertexFloatConstantBufferAsSSBO = pDevice->GetVertexConstantLayout().floatSize() > devInfo.core.properties.limits.maxUniformBufferRange; diff --git a/src/dxso/dxso_options.h b/src/dxso/dxso_options.h index 437f97532..cd0ab8e11 100644 --- a/src/dxso/dxso_options.h +++ b/src/dxso/dxso_options.h @@ -36,6 +36,9 @@ namespace dxvk { /// Works around a game bug in Halo CE where it gives cube textures to 2d/volume samplers bool forceSamplerTypeSpecConstants; + /// Interpolate pixel shader inputs at the sample location rather than pixel center + bool forceSampleRateShading; + /// Should the SWVP float constant buffer be a SSBO (because of the size on NV) bool vertexFloatConstantBufferAsSSBO;