Skip to content
Permalink
Browse files

D3D9: Implement flat shading via state.

  • Loading branch information...
unknownbrackets committed Apr 28, 2018
1 parent b845278 commit 5b62c8afb80a3aedb05dcbe2c50e48bedbbd87c0
Showing with 7 additions and 1 deletion.
  1. +3 −0 GPU/Directx9/StateMappingDX9.cpp
  2. +2 −1 GPU/GPUCommon.cpp
  3. +1 −0 ext/native/gfx/d3d9_state.cpp
  4. +1 −0 ext/native/gfx/d3d9_state.h
@@ -204,10 +204,13 @@ void DrawEngineDX9::ApplyDrawState(int prim) {
if (gstate.isModeClear()) {
// Set Cull
dxstate.cullMode.set(false, false);
// Well, probably doesn't matter...
dxstate.shadeMode.set(D3DSHADE_GOURAUD);
} else {
// Set cull
bool wantCull = !gstate.isModeThrough() && prim != GE_PRIM_RECTANGLES && gstate.isCullEnabled();
dxstate.cullMode.set(wantCull, gstate.getCullMode());
dxstate.shadeMode.set(gstate.getShadeMode() == GE_SHADE_GOURAUD ? D3DSHADE_GOURAUD : D3DSHADE_FLAT);
}
}

@@ -72,7 +72,8 @@ const CommonCommandTableEntry commonCommandTable[] = {
{ GE_CMD_FOGENABLE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE},
{ GE_CMD_TEXMODE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_TEXTURE_PARAMS | DIRTY_FRAGMENTSHADER_STATE },
{ GE_CMD_TEXSHADELS, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE },
{ GE_CMD_SHADEMODE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE },
// Raster state for Direct3D 9, uncommon.
{ GE_CMD_SHADEMODE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_RASTER_STATE },
{ GE_CMD_TEXFUNC, FLAG_FLUSHBEFOREONCHANGE, DIRTY_FRAGMENTSHADER_STATE },
{ GE_CMD_COLORTEST, FLAG_FLUSHBEFOREONCHANGE, DIRTY_FRAGMENTSHADER_STATE },
{ GE_CMD_ALPHATESTENABLE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_FRAGMENTSHADER_STATE },
@@ -35,6 +35,7 @@ void DirectXState::Restore() {
scissorRect.restore(); count++;

cullMode.restore(); count++;
shadeMode.restore(); count++;

depthTest.restore(); count++;
depthFunc.restore(); count++;
@@ -455,6 +455,7 @@ class DirectXState {
BoolUnused dither;

CullMode cullMode;
DxState1<D3DRS_SHADEMODE, D3DSHADE_GOURAUD> shadeMode;

BoolState<D3DRS_ZENABLE, false> depthTest;

0 comments on commit 5b62c8a

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.