Skip to content

Commit

Permalink
[dxso] Bias FETCH4 half-texel offset to avoid grid effect
Browse files Browse the repository at this point in the history
  • Loading branch information
misyltoad committed Jun 1, 2020
1 parent 2cac70f commit 12356d7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/dxso/dxso_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3110,7 +3110,12 @@ void DxsoCompiler::emitControlFlowGenericLoop(

textureSize.type = { DxsoScalarType::Float32, samplerInfo.dimensions };
textureSize.id = m_module.opConvertStoF(getVectorTypeId(textureSize.type), textureSize.id);
textureSize.id = m_module.opFDiv(getVectorTypeId(textureSize.type), m_module.constfReplicant(1.0f, samplerInfo.dimensions), textureSize.id);
// HACK: Bias fetch4 half-texel offset to avoid a "grid" effect.
// Technically we should only do that for non-powers of two
// as only then does the imprecision need to be biased
// towards infinity -- but that's not really worth doing...
float numerator = 1.0f - 1.0f / 256.0f;
textureSize.id = m_module.opFDiv(getVectorTypeId(textureSize.type), m_module.constfReplicant(numerator, samplerInfo.dimensions), textureSize.id);

// coord => same dimensions as texture size (no cube here !)
const std::array<uint32_t, 4> naturalIndices = { 0, 1, 2, 3 };
Expand Down

0 comments on commit 12356d7

Please sign in to comment.