Skip to content

Commit 1fbb3c0

Browse files
committed
perf(d3d): enable PUREDEVICE and hardware vertex processing
1 parent 926ffff commit 1fbb3c0

8 files changed

Lines changed: 74 additions & 74 deletions

File tree

Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp

Lines changed: 46 additions & 48 deletions
Large diffs are not rendered by default.

Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,11 +2890,8 @@ void WaterRenderObjClass::drawRiverWater(PolygonTrigger *pTrig)
28902890
DX8Wrapper::Set_DX8_Render_State(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
28912891

28922892
if (m_riverWaterPixelShader) DX8Wrapper::_Get_D3D_Device8()->SetPixelShader(m_riverWaterPixelShader);
2893-
DWORD cull;
2894-
DX8Wrapper::_Get_D3D_Device8()->GetRenderState(D3DRS_CULLMODE, &cull);
2895-
DX8Wrapper::_Get_D3D_Device8()->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
2896-
2897-
2893+
DWORD cull = DX8Wrapper::Get_DX8_Render_State(D3DRS_CULLMODE);
2894+
DX8Wrapper::Set_DX8_Render_State(D3DRS_CULLMODE, D3DCULL_NONE);
28982895

28992896
if (wireframeForDebug) {
29002897
DX8Wrapper::_Get_D3D_Device8()->SetRenderState(D3DRS_FILLMODE,D3DFILL_WIREFRAME);
@@ -2923,7 +2920,7 @@ void WaterRenderObjClass::drawRiverWater(PolygonTrigger *pTrig)
29232920
DX8Wrapper::_Get_D3D_Device8()->SetRenderState(D3DRS_ZFUNC, D3DCMP_EQUAL);
29242921
W3DShaderManager::resetShader(W3DShaderManager::ST_SHROUD_TEXTURE);
29252922
}
2926-
DX8Wrapper::_Get_D3D_Device8()->SetRenderState(D3DRS_CULLMODE, cull);
2923+
DX8Wrapper::Set_DX8_Render_State(D3DRS_CULLMODE, cull);
29272924

29282925

29292926
}
@@ -3265,12 +3262,8 @@ void WaterRenderObjClass::drawTrapezoidWater(Vector3 points[4])
32653262
DX8Wrapper::Set_DX8_Render_State(D3DRS_DESTBLEND, D3DBLEND_INVDESTALPHA );
32663263
}
32673264

3268-
3269-
DWORD cull;
3270-
DX8Wrapper::_Get_D3D_Device8()->GetRenderState(D3DRS_CULLMODE, &cull);
3271-
DX8Wrapper::_Get_D3D_Device8()->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
3272-
3273-
3265+
DWORD cull = DX8Wrapper::Get_DX8_Render_State(D3DRS_CULLMODE);
3266+
DX8Wrapper::Set_DX8_Render_State(D3DRS_CULLMODE, D3DCULL_NONE);
32743267

32753268
//#ifdef FEATHER_WATER // the NEW WATER a'la LORENZEN
32763269

@@ -3337,7 +3330,7 @@ void WaterRenderObjClass::drawTrapezoidWater(Vector3 points[4])
33373330
W3DShaderManager::resetShader(W3DShaderManager::ST_SHROUD_TEXTURE);
33383331
}
33393332
}
3340-
DX8Wrapper::_Get_D3D_Device8()->SetRenderState(D3DRS_CULLMODE, cull);
3333+
DX8Wrapper::Set_DX8_Render_State(D3DRS_CULLMODE, cull);
33413334
}
33423335

33433336

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3330,7 +3330,7 @@ void W3DVolumetricShadowManager::renderShadows( Bool forceStencilFill )
33303330
#else
33313331
//disable writes to color buffer
33323332
if (DX8Wrapper::Get_Current_Caps()->Get_DX8_Caps().PrimitiveMiscCaps & D3DPMISCCAPS_COLORWRITEENABLE)
3333-
{ DX8Wrapper::_Get_D3D_Device8()->GetRenderState(D3DRS_COLORWRITEENABLE, &oldColorWriteEnable);
3333+
{ oldColorWriteEnable = DX8Wrapper::Get_DX8_Render_State(D3DRS_COLORWRITEENABLE);
33343334
DX8Wrapper::Set_DX8_Render_State(D3DRS_COLORWRITEENABLE,0);
33353335
}
33363336
else

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ void renderStenciledPlayerColor( UnsignedInt color, UnsignedInt stencilRef, Bool
12501250
//disable writes to color buffer
12511251
if (DX8Wrapper::Get_Current_Caps()->Get_DX8_Caps().PrimitiveMiscCaps & D3DPMISCCAPS_COLORWRITEENABLE)
12521252
{
1253-
DX8Wrapper::_Get_D3D_Device8()->GetRenderState(D3DRS_COLORWRITEENABLE, &oldColorWriteEnable);
1253+
oldColorWriteEnable = DX8Wrapper::Get_DX8_Render_State(D3DRS_COLORWRITEENABLE);
12541254
DX8Wrapper::Set_DX8_Render_State(D3DRS_COLORWRITEENABLE,0);
12551255
}
12561256
else

Generals/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,9 @@ void DX8Wrapper::Invalidate_Cached_Render_States()
455455
for (a=0;a<sizeof(RenderStates)/sizeof(unsigned);++a) {
456456
RenderStates[a]=0x12345678;
457457
}
458+
// TheSuperHackers @performance Seed cache with D3D defaults for PUREDEVICE
459+
RenderStates[D3DRS_COLORWRITEENABLE] = D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA;
460+
RenderStates[D3DRS_CULLMODE] = D3DCULL_CCW;
458461
for (a=0;a<MAX_TEXTURE_STAGES;++a)
459462
{
460463
for (int b=0; b<32;b++)
@@ -550,10 +553,13 @@ bool DX8Wrapper::Create_Device()
550553
return false;
551554
}
552555

553-
Vertex_Processing_Behavior=D3DCREATE_SOFTWARE_VERTEXPROCESSING;
554-
if (caps.DevCaps&D3DDEVCAPS_HWTRANSFORMANDLIGHT)
556+
Vertex_Processing_Behavior = (caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) ?
557+
D3DCREATE_HARDWARE_VERTEXPROCESSING : D3DCREATE_SOFTWARE_VERTEXPROCESSING;
558+
559+
// TheSuperHackers @performance Enable pure device to skip per-draw-call state validation
560+
if (caps.DevCaps & D3DDEVCAPS_PUREDEVICE)
555561
{
556-
Vertex_Processing_Behavior=D3DCREATE_MIXED_VERTEXPROCESSING;
562+
Vertex_Processing_Behavior |= D3DCREATE_PUREDEVICE;
557563
}
558564

559565
#ifdef CREATE_DX8_MULTI_THREADED

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3474,7 +3474,7 @@ void W3DVolumetricShadowManager::renderShadows( Bool forceStencilFill )
34743474
#else
34753475
//disable writes to color buffer
34763476
if (DX8Wrapper::Get_Current_Caps()->Get_DX8_Caps().PrimitiveMiscCaps & D3DPMISCCAPS_COLORWRITEENABLE)
3477-
{ DX8Wrapper::_Get_D3D_Device8()->GetRenderState(D3DRS_COLORWRITEENABLE, &oldColorWriteEnable);
3477+
{ oldColorWriteEnable = DX8Wrapper::Get_DX8_Render_State(D3DRS_COLORWRITEENABLE);
34783478
DX8Wrapper::Set_DX8_Render_State(D3DRS_COLORWRITEENABLE,0);
34793479
}
34803480
else

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,7 @@ void renderStenciledPlayerColor( UnsignedInt color, UnsignedInt stencilRef, Bool
12981298
//disable writes to color buffer
12991299
if (DX8Wrapper::Get_Current_Caps()->Get_DX8_Caps().PrimitiveMiscCaps & D3DPMISCCAPS_COLORWRITEENABLE)
13001300
{
1301-
DX8Wrapper::_Get_D3D_Device8()->GetRenderState(D3DRS_COLORWRITEENABLE, &oldColorWriteEnable);
1301+
oldColorWriteEnable = DX8Wrapper::Get_DX8_Render_State(D3DRS_COLORWRITEENABLE);
13021302
DX8Wrapper::Set_DX8_Render_State(D3DRS_COLORWRITEENABLE,0);
13031303
}
13041304
else

GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,9 @@ void DX8Wrapper::Invalidate_Cached_Render_States()
462462
for (a=0;a<sizeof(RenderStates)/sizeof(unsigned);++a) {
463463
RenderStates[a]=0x12345678;
464464
}
465+
// TheSuperHackers @performance Seed cache with D3D defaults for PUREDEVICE
466+
RenderStates[D3DRS_COLORWRITEENABLE] = D3DCOLORWRITEENABLE_RED | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_ALPHA;
467+
RenderStates[D3DRS_CULLMODE] = D3DCULL_CCW;
465468
for (a=0;a<MAX_TEXTURE_STAGES;++a)
466469
{
467470
for (int b=0; b<32;b++)
@@ -562,14 +565,14 @@ bool DX8Wrapper::Create_Device()
562565

563566
#ifndef _XBOX
564567

565-
Vertex_Processing_Behavior=(caps.DevCaps&D3DDEVCAPS_HWTRANSFORMANDLIGHT) ?
566-
D3DCREATE_MIXED_VERTEXPROCESSING : D3DCREATE_SOFTWARE_VERTEXPROCESSING;
568+
Vertex_Processing_Behavior = (caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) ?
569+
D3DCREATE_HARDWARE_VERTEXPROCESSING : D3DCREATE_SOFTWARE_VERTEXPROCESSING;
567570

568-
// enable this when all 'get' dx calls are removed KJM
569-
/*if (caps.DevCaps&D3DDEVCAPS_PUREDEVICE)
571+
// TheSuperHackers @performance Enable pure device to skip per-draw-call state validation
572+
if (caps.DevCaps & D3DDEVCAPS_PUREDEVICE)
570573
{
571-
Vertex_Processing_Behavior|=D3DCREATE_PUREDEVICE;
572-
}*/
574+
Vertex_Processing_Behavior |= D3DCREATE_PUREDEVICE;
575+
}
573576

574577
#else // XBOX
575578
Vertex_Processing_Behavior=D3DCREATE_PUREDEVICE;

0 commit comments

Comments
 (0)