Read Fog color through GetXboxRenderState (not via host GetRenderState), just like all other states.
Also updated a few random comments and stuff mentioning the now-obsolete EmuMappedD3DRenderState. Removed unused code and replaced manual conversion of DWORD to 4 ARGB floats by using D3DXCOLOR.
This commit is contained in:
parent
8bf71bd7df
commit
b3671fe0e4
|
@ -4368,7 +4368,7 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexData2s)
|
|||
float fa, fb;
|
||||
|
||||
// Test case: Halo
|
||||
// Note : XQEMU recently verified that the int16_t arguments
|
||||
// Note : XQEMU verified that the int16_t arguments
|
||||
// must be mapped to floats in the range [-32768.0, 32767.0]
|
||||
// (See https://github.com/xqemu/xqemu/pull/176)
|
||||
fa = (float)a;
|
||||
|
@ -4377,16 +4377,6 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexData2s)
|
|||
EMUPATCH(D3DDevice_SetVertexData4f)(Register, fa, fb, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
DWORD FloatsToDWORD(FLOAT d, FLOAT a, FLOAT b, FLOAT c)
|
||||
{
|
||||
DWORD ca = (FtoDW(d) << 24);
|
||||
DWORD cr = (FtoDW(a) << 16) & 0x00FF0000;
|
||||
DWORD cg = (FtoDW(b) << 8) & 0x0000FF00;
|
||||
DWORD cb = (FtoDW(c) << 0) & 0x000000FF;
|
||||
|
||||
return ca | cr | cg | cb;
|
||||
}
|
||||
|
||||
extern uint32_t HLE_read_NV2A_pgraph_register(const int reg); // Declared in PushBuffer.cpp
|
||||
extern void HLE_write_NV2A_vertex_attribute_slot(unsigned slot, uint32_t parameter); // Declared in PushBuffer.cpp
|
||||
extern uint32_t HLE_read_NV2A_vertex_attribute_slot(unsigned VertexSlot); // Declared in PushBuffer.cpp
|
||||
|
@ -4410,6 +4400,8 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexData4f_16)
|
|||
mov Register, edi
|
||||
}
|
||||
|
||||
LOG_FORWARD("D3DDevice_SetVertexData4f");
|
||||
|
||||
EMUPATCH(D3DDevice_SetVertexData4f)(Register, a, b, c, d);
|
||||
}
|
||||
|
||||
|
@ -4727,7 +4719,9 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexData4s)
|
|||
float fa, fb, fc, fd;
|
||||
|
||||
// Test case: Halo
|
||||
// See comment note in D3DDevice_SetVertexData2s
|
||||
// Note : XQEMU verified that the int16_t arguments
|
||||
// must be mapped to floats in the range [-32768.0, 32767.0]
|
||||
// (See https://github.com/xqemu/xqemu/pull/176)
|
||||
fa = (float)a;
|
||||
fb = (float)b;
|
||||
fc = (float)c;
|
||||
|
@ -4747,12 +4741,9 @@ VOID WINAPI XTL::EMUPATCH(D3DDevice_SetVertexDataColor)
|
|||
{
|
||||
LOG_FORWARD("D3DDevice_SetVertexData4f");
|
||||
|
||||
FLOAT a = ((Color & 0xFF000000) >> 24) / 255.0f;
|
||||
FLOAT r = ((Color & 0x00FF0000) >> 16) / 255.0f;
|
||||
FLOAT g = ((Color & 0x0000FF00) >> 8) / 255.0f;
|
||||
FLOAT b = ((Color & 0x000000FF) >> 0) / 255.0f;
|
||||
D3DXCOLOR XColor = Color;
|
||||
|
||||
EMUPATCH(D3DDevice_SetVertexData4f)(Register, r, g, b, a);
|
||||
EMUPATCH(D3DDevice_SetVertexData4f)(Register, XColor.r, XColor.g, XColor.b, XColor.a);
|
||||
}
|
||||
|
||||
// ******************************************************************
|
||||
|
|
|
@ -650,11 +650,11 @@ typedef enum _X_D3DRENDERSTATETYPE {
|
|||
// Dxbx note : These declarations are from XDK version 5933, the most recent and complete version.
|
||||
// Older versions are slightly different (some members are missing), so we use a mapping table to
|
||||
// cater for the differences (see DxbxBuildRenderStateMappingTable). This enables to ignore these
|
||||
// version-differences in the rest of our code (unless it matters somehow); We write via indirection :
|
||||
// *EmuMappedD3DRenderState[X_D3DRENDERSTATETYPE] = Value;
|
||||
// version-differences in the rest of our code (unless it matters somehow); We write like this :
|
||||
// XboxRenderStates.SetXboxRenderState(X_D3DRENDERSTATETYPE, Value);
|
||||
//
|
||||
// And we read via the same mapping (do note, that missing elements all point to the same dummy) :
|
||||
// Result = *EmuMappedD3DRenderState[X_D3DRENDERSTATETYPE];
|
||||
// And we read like this (do note, that missing elements all point to the same dummy) :
|
||||
// Result = XboxRenderStates.GetXboxRenderState(X_D3DRENDERSTATETYPE);
|
||||
|
||||
// Dxbx note : The PS* render states map 1-on-1 to the X_D3DPIXELSHADERDEF record,
|
||||
// SetPixelShader actually pushes the definition into these render state slots.
|
||||
|
|
|
@ -1650,7 +1650,7 @@ bool PSH_IMD_ARGUMENT::Decode(const DWORD Value, DWORD aMask, TArgumentType Argu
|
|||
Modifiers = (1 << ARGMOD_BIAS);
|
||||
break;
|
||||
// case PS_INPUTMAPPING_HALFBIAS_NEGATE:
|
||||
// Modifiers = ARGMOD_IDENTITY; ???
|
||||
// Modifiers = (1 << ARGMOD_IDENTITY); ???
|
||||
// break;
|
||||
case PS_INPUTMAPPING_SIGNED_IDENTITY:
|
||||
Modifiers = (1 << ARGMOD_IDENTITY);
|
||||
|
@ -5982,11 +5982,9 @@ VOID DxbxUpdateActivePixelShader() // NOPATCH
|
|||
|
||||
HRESULT Result = D3D_OK;
|
||||
|
||||
// TODO: Is this even right? The first RenderState is PSAlpha,
|
||||
// The first RenderState is PSAlpha,
|
||||
// The pixel shader is stored in pDevice->m_pPixelShader
|
||||
// For now, we still patch SetPixelShader and read from there...
|
||||
//DWORD *XTL_D3D__RenderState = EmuMappedD3DRenderState[0];
|
||||
//pPSDef = (XTL::X_D3DPIXELSHADERDEF*)(XTL_D3D__RenderState);
|
||||
|
||||
// Use the pixel shader stored in D3D__RenderState rather than the set handle
|
||||
// This allows changes made via SetRenderState to actually take effect!
|
||||
|
@ -5994,6 +5992,7 @@ VOID DxbxUpdateActivePixelShader() // NOPATCH
|
|||
// All other fields are the same.
|
||||
// We cast D3D__RenderState to a pPSDef for these fields, but
|
||||
// manually read from D3D__RenderState[X_D3DRS_PSTEXTUREMODES) for that one field.
|
||||
// See D3DDevice_SetPixelShaderCommon which implements this
|
||||
|
||||
pPSDef = g_pXbox_PixelShader != nullptr ? (XTL::X_D3DPIXELSHADERDEF*)(XboxRenderStates.GetPixelShaderRenderStatePointer()) : nullptr;
|
||||
|
||||
|
@ -6066,25 +6065,16 @@ VOID DxbxUpdateActivePixelShader() // NOPATCH
|
|||
if (RecompiledPixelShader->ConstInUse[i])
|
||||
{
|
||||
// Read the color from the corresponding render state slot :
|
||||
// TODO: These should read from EmuMappedD3DRenderState, but it doesn't exist yet
|
||||
// The required code needs o be ported from Wip_LessVertexPatching or Dxbx
|
||||
switch (i) {
|
||||
case PSH_XBOX_CONSTANT_FOG:
|
||||
//dwColor = *EmuMappedD3DRenderState[XTL::X_D3DRS_FOGCOLOR] | 0xFF000000;
|
||||
// Note : FOG.RGB is correct like this, but FOG.a should be coming
|
||||
// from the vertex shader (oFog) - however, D3D8 does not forward this...
|
||||
g_pD3DDevice->GetRenderState(D3DRS_FOGCOLOR, &dwColor);
|
||||
fColor.a = ((dwColor >> 24) & 0xFF) / 255.0f;
|
||||
fColor.r = ((dwColor >> 16) & 0xFF) / 255.0f;
|
||||
fColor.g = ((dwColor >> 8) & 0xFF) / 255.0f;
|
||||
fColor.b = (dwColor & 0xFF) / 255.0f;
|
||||
fColor = dwColor = XboxRenderStates.GetXboxRenderState(XTL::X_D3DRS_FOGCOLOR);
|
||||
break;
|
||||
case PSH_XBOX_CONSTANT_FC0:
|
||||
//dwColor = *EmuMappedD3DRenderState[XTL::X_D3DRS_PSFINALCOMBINERCONSTANT0];
|
||||
fColor = dwColor = XboxRenderStates.GetXboxRenderState(XTL::X_D3DRS_PSFINALCOMBINERCONSTANT0);
|
||||
break;
|
||||
case PSH_XBOX_CONSTANT_FC1:
|
||||
//dwColor = *EmuMappedD3DRenderState[XTL::X_D3DRS_PSFINALCOMBINERCONSTANT1];
|
||||
fColor = dwColor = XboxRenderStates.GetXboxRenderState(XTL::X_D3DRS_PSFINALCOMBINERCONSTANT1);
|
||||
break;
|
||||
case PSH_XBOX_CONSTANT_MUL0:
|
||||
|
@ -6119,7 +6109,6 @@ VOID DxbxUpdateActivePixelShader() // NOPATCH
|
|||
break;
|
||||
}
|
||||
default:
|
||||
//dwColor = *EmuMappedD3DRenderState[XTL::X_D3DRS_PSCONSTANT0_0 + i];
|
||||
fColor = dwColor = XboxRenderStates.GetXboxRenderState(XTL::X_D3DRS_PSCONSTANT0_0 + i);
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue