Port some other minor changes over from #9255

This commit is contained in:
Henrik Rydgård 2017-04-03 16:45:58 +02:00
parent 0903bfb5f5
commit 1faae8b6d6
8 changed files with 35 additions and 26 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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