1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-19 05:52:11 +01:00

[dxso] Support clamping Dref.

This commit is contained in:
Georg Lehmann 2022-09-26 11:19:52 +02:00 committed by Joshie
parent 5684e29718
commit 6fe96d7d82
2 changed files with 11 additions and 4 deletions

View File

@ -27,6 +27,7 @@ namespace dxvk {
SpecVertexShaderBools, // 16 bools | Bits: 16
SpecPixelShaderBools, // 16 bools | Bits: 16
SpecDrefClamp, // 1 bit for 16 PS samplers | Bits: 16
SpecFetch4, // 1 bit for 16 PS samplers | Bits: 16
SpecConstantCount,
@ -62,7 +63,8 @@ namespace dxvk {
{ 3, 0, 16 }, // VertexShaderBools
{ 3, 16, 16 }, // PixelShaderBools
{ 4, 0, 16 }, // Fetch4
{ 4, 0, 16 }, // DrefClamp
{ 4, 16, 16 }, // Fetch4
}};
template <D3D9SpecConstantId Id, typename T>

View File

@ -2862,19 +2862,24 @@ void DxsoCompiler::emitControlFlowGenericLoop(
texcoordVar.id = DoProjection(texcoordVar, true);
}
uint32_t reference = 0;
uint32_t bool_t = m_module.defBoolType();
uint32_t reference = 0;
if (depth) {
uint32_t fType = m_module.defFloatType(32);
uint32_t component = sampler.dimensions;
reference = m_module.opCompositeExtract(
m_module.defFloatType(32), texcoordVar.id, 1, &component);
fType, texcoordVar.id, 1, &component);
uint32_t clampDref = m_spec.get(m_module, m_specUbo, SpecDrefClamp, samplerIdx, 1);
clampDref = m_module.opINotEqual(bool_t, clampDref, m_module.constu32(0));
uint32_t clampedDref = m_module.opFClamp(fType, reference, m_module.constf32(0.0f), m_module.constf32(1.0f));
reference = m_module.opSelect(fType, clampDref, clampedDref, reference);
}
uint32_t fetch4 = 0;
if (m_programInfo.type() == DxsoProgramType::PixelShader && samplerType != SamplerTypeTexture3D) {
fetch4 = m_spec.get(m_module, m_specUbo, SpecFetch4, samplerIdx, 1);
uint32_t bool_t = m_module.defBoolType();
fetch4 = m_module.opINotEqual(bool_t, fetch4, m_module.constu32(0));
uint32_t bvec4_t = m_module.defVectorType(bool_t, 4);