Commit e27868a9 authored by Joshua Ashton's avatar Joshua Ashton 🐸

[d3d9] Respect fog off meaning fog off, pass through FOG as fog depth override instead

Closes #346
parent b8f7ea1e
......@@ -5988,6 +5988,7 @@ namespace dxvk {
key.data.HasColor0 = m_state.vertexDecl != nullptr ? m_state.vertexDecl->TestFlag(D3D9VertexDeclFlag::HasColor0) : false;
key.data.HasColor1 = m_state.vertexDecl != nullptr ? m_state.vertexDecl->TestFlag(D3D9VertexDeclFlag::HasColor1) : false;
key.data.HasPointSize = m_state.vertexDecl != nullptr ? m_state.vertexDecl->TestFlag(D3D9VertexDeclFlag::HasPointSize) : false;
key.data.HasFog = m_state.vertexDecl != nullptr ? m_state.vertexDecl->TestFlag(D3D9VertexDeclFlag::HasFog) : false;
bool lighting = m_state.renderStates[D3DRS_LIGHTING] != 0 && !key.data.HasPositionT;
bool colorVertex = m_state.renderStates[D3DRS_COLORVERTEX] != 0;
......
......@@ -86,7 +86,9 @@ namespace dxvk {
depth = spvModule.opLength(floatType, pos3);
}
else
depth = spvModule.opFAbs(floatType, z);
depth = fogCtx.HasFogInput
? fogCtx.vFog
: spvModule.opFAbs(floatType, z);
}
uint32_t applyFogFactor = spvModule.allocateId();
......@@ -117,7 +119,9 @@ namespace dxvk {
default:
// vFog
case D3DFOG_NONE: {
return fogCtx.vFog;
return fogCtx.IsPixel
? fogCtx.vFog
: spvModule.constf32(1.0f);
}
// (end - d) / (end - start)
......@@ -1007,6 +1011,7 @@ namespace dxvk {
fogCtx.RangeFog = m_vsKey.data.RangeFog;
fogCtx.RenderState = m_rsBlock;
fogCtx.vPos = vtx;
fogCtx.HasFogInput = m_vsKey.data.HasFog;
fogCtx.vFog = m_vs.in.FOG;
fogCtx.oColor = 0;
m_module.opStore(m_vs.out.FOG, DoFixedFunctionFog(m_module, fogCtx));
......
......@@ -27,6 +27,8 @@ namespace dxvk {
uint32_t vFog;
uint32_t oColor;
bool HasFogInput;
};
struct D3D9FixedFunctionOptions {
......@@ -97,6 +99,7 @@ namespace dxvk {
uint32_t LightCount : 4;
uint32_t TexcoordDeclMask : 24;
uint32_t HasFog : 1;
} data;
struct {
......
......@@ -215,6 +215,8 @@ namespace dxvk {
m_flags.set(D3D9VertexDeclFlag::HasPositionT);
else if (element.Usage == D3DDECLUSAGE_PSIZE)
m_flags.set(D3D9VertexDeclFlag::HasPointSize);
else if (element.Usage == D3DDECLUSAGE_FOG)
m_flags.set(D3D9VertexDeclFlag::HasFog);
if (element.Usage == D3DDECLUSAGE_TEXCOORD)
m_texcoordMask |= GetDecltypeCount(D3DDECLTYPE(element.Type)) << (element.UsageIndex * 3);
......
......@@ -10,7 +10,8 @@ namespace dxvk {
HasColor0,
HasColor1,
HasPositionT,
HasPointSize
HasPointSize,
HasFog
};
using D3D9VertexDeclFlags = Flags<D3D9VertexDeclFlag>;
......
......@@ -1094,7 +1094,7 @@ namespace dxvk {
m_fog = this->emitRegisterPtr(
input ? "vFog" : "oFog",
DxsoScalarType::Float32, 1,
input ? 0 : m_module.constf32(0.0f),
input ? 0 : m_module.constf32(1.0f),
input ? spv::StorageClassInput : spv::StorageClassOutput);
m_entryPointInterfaces.push_back(m_fog.id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment