diff --git a/GPU/Common/ShaderId.h b/GPU/Common/ShaderId.h index 324c8b73eb..54d1c7f8a0 100644 --- a/GPU/Common/ShaderId.h +++ b/GPU/Common/ShaderId.h @@ -113,7 +113,9 @@ struct ShaderID { } return true; } - + bool operator != (const ShaderID &other) const { + return !(*this == other); + } bool Bit(int bit) const { return (d[bit >> 5] >> (bit & 31)) & 1; } diff --git a/GPU/D3D11/GPU_D3D11.cpp b/GPU/D3D11/GPU_D3D11.cpp index ddd7016279..d84fc5245f 100644 --- a/GPU/D3D11/GPU_D3D11.cpp +++ b/GPU/D3D11/GPU_D3D11.cpp @@ -482,8 +482,6 @@ void GPU_D3D11::Execute_VertexTypeSkinning(u32 op, u32 diff) { } void GPU_D3D11::Execute_Prim(u32 op, u32 diff) { - SetDrawType(DRAW_PRIM); - // This drives all drawing. All other state we just buffer up, then we apply it only // when it's time to draw. As most PSP games set state redundantly ALL THE TIME, this is a huge optimization. @@ -495,6 +493,8 @@ void GPU_D3D11::Execute_Prim(u32 op, u32 diff) { if (count == 0) return; + SetDrawType(DRAW_PRIM, prim); + // Discard AA lines as we can't do anything that makes sense with these anyway. The SW plugin might, though. if (gstate.isAntiAliasEnabled()) { @@ -553,8 +553,6 @@ void GPU_D3D11::Execute_Prim(u32 op, u32 diff) { } void GPU_D3D11::Execute_Bezier(u32 op, u32 diff) { - SetDrawType(DRAW_BEZIER); - // We don't dirty on normal changes anymore as we prescale, but it's needed for splines/bezier. gstate_c.Dirty(DIRTY_UVSCALEOFFSET); @@ -588,6 +586,8 @@ void GPU_D3D11::Execute_Bezier(u32 op, u32 diff) { } GEPatchPrimType patchPrim = gstate.getPatchPrimitiveType(); + SetDrawType(DRAW_BEZIER, PatchPrimToPrim(patchPrim)); + int bz_ucount = op & 0xFF; int bz_vcount = (op >> 8) & 0xFF; bool computeNormals = gstate.isLightingEnabled(); @@ -612,8 +612,6 @@ void GPU_D3D11::Execute_Bezier(u32 op, u32 diff) { } void GPU_D3D11::Execute_Spline(u32 op, u32 diff) { - SetDrawType(DRAW_SPLINE); - // We don't dirty on normal changes anymore as we prescale, but it's needed for splines/bezier. gstate_c.Dirty(DIRTY_UVSCALEOFFSET); @@ -651,6 +649,7 @@ void GPU_D3D11::Execute_Spline(u32 op, u32 diff) { int sp_utype = (op >> 16) & 0x3; int sp_vtype = (op >> 18) & 0x3; GEPatchPrimType patchPrim = gstate.getPatchPrimitiveType(); + SetDrawType(DRAW_SPLINE, PatchPrimToPrim(patchPrim)); bool computeNormals = gstate.isLightingEnabled(); bool patchFacing = gstate.patchfacing & 1; u32 vertType = gstate.vertType; diff --git a/GPU/D3D11/StateMappingD3D11.cpp b/GPU/D3D11/StateMappingD3D11.cpp index 6db61e5be3..f525151951 100644 --- a/GPU/D3D11/StateMappingD3D11.cpp +++ b/GPU/D3D11/StateMappingD3D11.cpp @@ -279,6 +279,7 @@ void DrawEngineD3D11::ApplyDrawState(int prim) { dynState_.useStencil = false; { + keys_.raster.value = 0; if (gstate.isModeClear()) { keys_.raster.cullMode = D3D11_CULL_NONE; } else { @@ -306,6 +307,7 @@ void DrawEngineD3D11::ApplyDrawState(int prim) { { // Set ColorMask/Stencil/Depth if (gstate.isModeClear()) { + keys_.depthStencil.value = 0; keys_.depthStencil.depthTestEnable = true; keys_.depthStencil.depthCompareOp = D3D11_COMPARISON_ALWAYS; keys_.depthStencil.depthWriteEnable = gstate.isClearModeDepthMask(); @@ -333,6 +335,7 @@ void DrawEngineD3D11::ApplyDrawState(int prim) { } } else { + keys_.depthStencil.value = 0; // Depth Test if (gstate.isDepthTestEnabled()) { keys_.depthStencil.depthTestEnable = true; diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index 03a4b256a8..fcb189f439 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -449,8 +449,6 @@ void GPU_DX9::Execute_VertexTypeSkinning(u32 op, u32 diff) { } void GPU_DX9::Execute_Prim(u32 op, u32 diff) { - SetDrawType(DRAW_PRIM); - // This drives all drawing. All other state we just buffer up, then we apply it only // when it's time to draw. As most PSP games set state redundantly ALL THE TIME, this is a huge optimization. @@ -462,6 +460,8 @@ void GPU_DX9::Execute_Prim(u32 op, u32 diff) { if (count == 0) return; + SetDrawType(DRAW_PRIM, prim); + // Discard AA lines as we can't do anything that makes sense with these anyway. The SW plugin might, though. if (gstate.isAntiAliasEnabled()) { @@ -520,8 +520,6 @@ void GPU_DX9::Execute_Prim(u32 op, u32 diff) { } void GPU_DX9::Execute_Bezier(u32 op, u32 diff) { - SetDrawType(DRAW_BEZIER); - // We don't dirty on normal changes anymore as we prescale, but it's needed for splines/bezier. gstate_c.Dirty(DIRTY_UVSCALEOFFSET); @@ -555,6 +553,7 @@ void GPU_DX9::Execute_Bezier(u32 op, u32 diff) { } GEPatchPrimType patchPrim = gstate.getPatchPrimitiveType(); + SetDrawType(DRAW_BEZIER, PatchPrimToPrim(patchPrim)); int bz_ucount = op & 0xFF; int bz_vcount = (op >> 8) & 0xFF; bool computeNormals = gstate.isLightingEnabled(); @@ -568,8 +567,6 @@ void GPU_DX9::Execute_Bezier(u32 op, u32 diff) { } void GPU_DX9::Execute_Spline(u32 op, u32 diff) { - SetDrawType(DRAW_SPLINE); - // We don't dirty on normal changes anymore as we prescale, but it's needed for splines/bezier. gstate_c.Dirty(DIRTY_UVSCALEOFFSET); @@ -607,6 +604,7 @@ void GPU_DX9::Execute_Spline(u32 op, u32 diff) { int sp_utype = (op >> 16) & 0x3; int sp_vtype = (op >> 18) & 0x3; GEPatchPrimType patchPrim = gstate.getPatchPrimitiveType(); + SetDrawType(DRAW_SPLINE, PatchPrimToPrim(patchPrim)); bool computeNormals = gstate.isLightingEnabled(); bool patchFacing = gstate.patchfacing & 1; u32 vertType = gstate.vertType; diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index 49380d589f..7452a8c963 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -636,8 +636,6 @@ void GPU_GLES::ExecuteOp(u32 op, u32 diff) { } void GPU_GLES::Execute_Prim(u32 op, u32 diff) { - SetDrawType(DRAW_PRIM); - // This drives all drawing. All other state we just buffer up, then we apply it only // when it's time to draw. As most PSP games set state redundantly ALL THE TIME, this is a huge optimization. @@ -649,6 +647,8 @@ void GPU_GLES::Execute_Prim(u32 op, u32 diff) { if (count == 0) return; + SetDrawType(DRAW_PRIM, prim); + // Discard AA lines as we can't do anything that makes sense with these anyway. The SW plugin might, though. if (gstate.isAntiAliasEnabled()) { @@ -728,8 +728,6 @@ void GPU_GLES::Execute_VertexTypeSkinning(u32 op, u32 diff) { } void GPU_GLES::Execute_Bezier(u32 op, u32 diff) { - SetDrawType(DRAW_BEZIER); - // We don't dirty on normal changes anymore as we prescale, but it's needed for splines/bezier. gstate_c.Dirty(DIRTY_UVSCALEOFFSET); @@ -763,6 +761,8 @@ void GPU_GLES::Execute_Bezier(u32 op, u32 diff) { } GEPatchPrimType patchPrim = gstate.getPatchPrimitiveType(); + SetDrawType(DRAW_BEZIER, PatchPrimToPrim(patchPrim)); + int bz_ucount = op & 0xFF; int bz_vcount = (op >> 8) & 0xFF; bool computeNormals = gstate.isLightingEnabled(); @@ -787,8 +787,6 @@ void GPU_GLES::Execute_Bezier(u32 op, u32 diff) { } void GPU_GLES::Execute_Spline(u32 op, u32 diff) { - SetDrawType(DRAW_SPLINE); - // We don't dirty on normal changes anymore as we prescale, but it's needed for splines/bezier. gstate_c.Dirty(DIRTY_UVSCALEOFFSET); @@ -826,6 +824,7 @@ void GPU_GLES::Execute_Spline(u32 op, u32 diff) { int sp_utype = (op >> 16) & 0x3; int sp_vtype = (op >> 18) & 0x3; GEPatchPrimType patchPrim = gstate.getPatchPrimitiveType(); + SetDrawType(DRAW_SPLINE, PatchPrimToPrim(patchPrim)); bool computeNormals = gstate.isLightingEnabled(); bool patchFacing = gstate.patchfacing & 1; u32 vertType = gstate.vertType; diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 6f41169786..528e89129c 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -219,7 +219,7 @@ public: typedef void (GPUCommon::*CmdFunc)(u32 op, u32 diff); protected: - void SetDrawType(DrawType type) { + void SetDrawType(DrawType type, GEPrimitiveType prim) { if (type != lastDraw_) { gstate_c.Dirty(DIRTY_UVSCALEOFFSET); lastDraw_ = type; diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 7232ca0864..f1cb86f562 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -465,8 +465,6 @@ void GPU_Vulkan::ExecuteOp(u32 op, u32 diff) { } void GPU_Vulkan::Execute_Prim(u32 op, u32 diff) { - SetDrawType(DRAW_PRIM); - // This drives all drawing. All other state we just buffer up, then we apply it only // when it's time to draw. As most PSP games set state redundantly ALL THE TIME, this is a huge optimization. @@ -478,6 +476,8 @@ void GPU_Vulkan::Execute_Prim(u32 op, u32 diff) { if (count == 0) return; + SetDrawType(DRAW_PRIM, prim); + // Discard AA lines as we can't do anything that makes sense with these anyway. The SW plugin might, though. if (gstate.isAntiAliasEnabled()) { @@ -540,8 +540,6 @@ void GPU_Vulkan::Execute_VertexType(u32 op, u32 diff) { } void GPU_Vulkan::Execute_Bezier(u32 op, u32 diff) { - SetDrawType(DRAW_BEZIER); - // We don't dirty on normal changes anymore as we prescale, but it's needed for splines/bezier. gstate_c.Dirty(DIRTY_UVSCALEOFFSET); @@ -575,6 +573,8 @@ void GPU_Vulkan::Execute_Bezier(u32 op, u32 diff) { } GEPatchPrimType patchPrim = gstate.getPatchPrimitiveType(); + SetDrawType(DRAW_BEZIER, PatchPrimToPrim(patchPrim)); + int bz_ucount = op & 0xFF; int bz_vcount = (op >> 8) & 0xFF; bool computeNormals = gstate.isLightingEnabled(); @@ -599,8 +599,6 @@ void GPU_Vulkan::Execute_Bezier(u32 op, u32 diff) { } void GPU_Vulkan::Execute_Spline(u32 op, u32 diff) { - SetDrawType(DRAW_SPLINE); - // We don't dirty on normal changes anymore as we prescale, but it's needed for splines/bezier. gstate_c.Dirty(DIRTY_UVSCALEOFFSET); @@ -638,6 +636,7 @@ void GPU_Vulkan::Execute_Spline(u32 op, u32 diff) { int sp_utype = (op >> 16) & 0x3; int sp_vtype = (op >> 18) & 0x3; GEPatchPrimType patchPrim = gstate.getPatchPrimitiveType(); + SetDrawType(DRAW_SPLINE, PatchPrimToPrim(patchPrim)); bool computeNormals = gstate.isLightingEnabled(); bool patchFacing = gstate.patchfacing & 1; u32 vertType = gstate.vertType; diff --git a/GPU/ge_constants.h b/GPU/ge_constants.h index 1ea7ab0549..377f5c913f 100644 --- a/GPU/ge_constants.h +++ b/GPU/ge_constants.h @@ -557,6 +557,15 @@ enum GEPatchPrimType GE_PATCHPRIM_UNKNOWN = 3, }; +inline GEPrimitiveType PatchPrimToPrim(GEPatchPrimType type) { + switch (type) { + case GE_PATCHPRIM_TRIANGLES: return GE_PRIM_TRIANGLES; + case GE_PATCHPRIM_LINES: return GE_PRIM_LINES; + case GE_PATCHPRIM_POINTS: return GE_PRIM_POINTS; + case GE_PATCHPRIM_UNKNOWN: default: return GE_PRIM_KEEP_PREVIOUS; // just something + } +} + enum GEPaletteFormat { GE_CMODE_16BIT_BGR5650,