Use a gstate enum, report unhandled blend mode.

This commit is contained in:
Unknown W. Brackets 2013-09-14 07:34:36 -07:00
parent 1a7e0e40cf
commit 40e3e8e930
3 changed files with 10 additions and 4 deletions

View file

@ -159,7 +159,7 @@ void TransformDrawEngine::ApplyDrawState(int prim) {
int blendFuncA = gstate.getBlendFuncA();
int blendFuncB = gstate.getBlendFuncB();
int blendFuncEq = gstate.getBlendEq();
GEBlendMode blendFuncEq = gstate.getBlendEq();
if (blendFuncA > GE_SRCBLEND_FIXA) blendFuncA = GE_SRCBLEND_FIXA;
if (blendFuncB > GE_DSTBLEND_FIXB) blendFuncB = GE_DSTBLEND_FIXB;
@ -225,6 +225,11 @@ void TransformDrawEngine::ApplyDrawState(int prim) {
} else {
glstate.blendFuncSeparate.set(glBlendFuncA, glBlendFuncB, glBlendFuncA, glBlendFuncB);
}
#if !defined(USING_GLES2)
if (blendFuncEq == GE_BLENDMODE_ABSDIFF) {
WARN_LOG_REPORT_ONCE(blendAbsdiff, G3D, "Unsupported absdiff blend mode");
}
#endif
glstate.blendEquation.set(eqLookup[blendFuncEq]);
}

View file

@ -233,7 +233,7 @@ struct GPUgstate
u32 getFixA() const { return blendfixa & 0xFFFFFF; }
u32 getFixB() const { return blendfixb & 0xFFFFFF; }
GEBlendDstFactor getBlendFuncB() const { return (GEBlendDstFactor)((blend >> 4) & 0xF); }
int getBlendEq() const { return (blend >> 8) & 0x7; }
GEBlendMode getBlendEq() const { return static_cast<GEBlendMode>((blend >> 8) & 0x7); }
bool isAlphaBlendEnabled() const { return alphaBlendEnable & 1; }
// AntiAlias
@ -309,6 +309,7 @@ struct GPUgstate
bool isDirectionalLight(int chan) const { return getLightType(chan) == GE_LIGHTTYPE_DIRECTIONAL; }
bool isPointLight(int chan) const { return getLightType(chan) == GE_LIGHTTYPE_POINT; }
bool isSpotLight(int chan) const { return getLightType(chan) == GE_LIGHTTYPE_SPOT; }
GEShadeMode getShadeMode() const { return static_cast<GEShadeMode>(shademodel & 1); }
unsigned int getAmbientR() const { return ambientcolor&0xFF; }
unsigned int getAmbientG() const { return (ambientcolor>>8)&0xFF; }
unsigned int getAmbientB() const { return (ambientcolor>>16)&0xFF; }
@ -352,7 +353,7 @@ struct GPUgstate
int getRegionX1() const { return region1 & 0x3FF; }
int getRegionY1() const { return (region1 >> 10) & 0x3FF; }
int getRegionX2() const { return (region2 & 0x3FF); }
int getRegionY2() const { return ((region2 >> 10) & 0x3FF); }
int getRegionY2() const { return (region2 >> 10) & 0x3FF; }
float getViewportX1() const { return fabsf(getFloat24(viewportx1) * 2.0f); }
float getViewportY1() const { return fabsf(getFloat24(viewporty1) * 2.0f); }

View file

@ -775,7 +775,7 @@ void DrawTriangle(const VertexData& v0, const VertexData& v1, const VertexData&
Vec3<int> prim_color_rgb(0, 0, 0);
int prim_color_a = 0;
Vec3<int> sec_color(0, 0, 0);
if ((gstate.shademodel&1) == GE_SHADE_GOURAUD) {
if (gstate.getShadeMode() == GE_SHADE_GOURAUD) {
// NOTE: When not casting color0 and color1 to float vectors, this code suffers from severe overflow issues.
// Not sure if that should be regarded as a bug or if casting to float is a valid fix.
// TODO: Is that the correct way to interpolate?