D3D9: Implement flat shading via state.

This commit is contained in:
Unknown W. Brackets 2018-04-28 16:31:39 -07:00
parent b845278d7d
commit 5b62c8afb8
4 changed files with 7 additions and 1 deletions

View File

@ -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);
}
}

View File

@ -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 },

View File

@ -35,6 +35,7 @@ void DirectXState::Restore() {
scissorRect.restore(); count++;
cullMode.restore(); count++;
shadeMode.restore(); count++;
depthTest.restore(); count++;
depthFunc.restore(); count++;

View File

@ -455,6 +455,7 @@ public:
BoolUnused dither;
CullMode cullMode;
DxState1<D3DRS_SHADEMODE, D3DSHADE_GOURAUD> shadeMode;
BoolState<D3DRS_ZENABLE, false> depthTest;