mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-11 13:36:24 +02:00
D3D: No need to convert blendcolor to float and back
Fix bug with constantAlpha Remove misleading comment, thanks unknown
This commit is contained in:
1 parent
bcd452179f
commit
df94914a63
4 files changed
+20
-23
No files matched your search
@@ -459,7 +459,6 @@ void ConvertViewportAndScissor(bool useBufferedRendering, float renderWidth, flo
|
||||
float offsetY = gstate.getOffsetY();
|
||||
|
||||
if (throughmode) {
|
||||
// No viewport transform here. Let's experiment with using region.
|
||||
out.viewportX = renderX + displayOffsetX;
|
||||
out.viewportY = renderY + displayOffsetY;
|
||||
out.viewportW = curRTWidth * renderWidthFactor;
|
||||
@@ -800,7 +799,7 @@ void ConvertBlendState(GenericBlendState &blendState) {
|
||||
blendState.applyShaderBlending = true;
|
||||
blendState.resetShaderBlending = false;
|
||||
blendState.replaceAlphaWithStencil = replaceAlphaWithStencil;
|
||||
break; // Surely this should be return??
|
||||
break;
|
||||
|
||||
case REPLACE_BLEND_PRE_SRC:
|
||||
case REPLACE_BLEND_PRE_SRC_2X_ALPHA:
|
||||
@@ -827,22 +826,22 @@ void ConvertBlendState(GenericBlendState &blendState) {
|
||||
if (blendFuncB > GE_DSTBLEND_FIXB)
|
||||
blendFuncB = GE_DSTBLEND_FIXB;
|
||||
|
||||
float constantAlpha = 1.0f;
|
||||
int constantAlpha = 255;
|
||||
BlendFactor constantAlphaGL = BlendFactor::ONE;
|
||||
if (gstate.isStencilTestEnabled() && replaceAlphaWithStencil == REPLACE_ALPHA_NO) {
|
||||
switch (ReplaceAlphaWithStencilType()) {
|
||||
case STENCIL_VALUE_UNIFORM:
|
||||
constantAlpha = (float)gstate.getStencilTestRef() * (1.0f / 255.0f);
|
||||
constantAlpha = gstate.getStencilTestRef();
|
||||
break;
|
||||
|
||||
case STENCIL_VALUE_INCR_4:
|
||||
case STENCIL_VALUE_DECR_4:
|
||||
constantAlpha = 1.0f / 15.0f;
|
||||
constantAlpha = 16;
|
||||
break;
|
||||
|
||||
case STENCIL_VALUE_INCR_8:
|
||||
case STENCIL_VALUE_DECR_8:
|
||||
constantAlpha = 1.0f / 255.0f;
|
||||
constantAlpha = 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -850,9 +849,9 @@ void ConvertBlendState(GenericBlendState &blendState) {
|
||||
}
|
||||
|
||||
// Otherwise it will stay GL_ONE.
|
||||
if (constantAlpha <= 0.0f) {
|
||||
if (constantAlpha <= 0) {
|
||||
constantAlphaGL = BlendFactor::ZERO;
|
||||
} else if (constantAlpha < 1.0f) {
|
||||
} else if (constantAlpha < 255) {
|
||||
constantAlphaGL = BlendFactor::CONSTANT_ALPHA;
|
||||
}
|
||||
}
|
||||
@@ -945,7 +944,7 @@ void ConvertBlendState(GenericBlendState &blendState) {
|
||||
}
|
||||
}
|
||||
|
||||
// Some Android devices (especially Mali, it seems) composite badly if there's alpha in the backbuffer.
|
||||
// Some Android devices (especially old Mali, it seems) composite badly if there's alpha in the backbuffer.
|
||||
// So in non-buffered rendering, we will simply consider the dest alpha to be zero in blending equations.
|
||||
#ifdef ANDROID
|
||||
if (g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) {
|
||||
|
||||
@@ -126,11 +126,11 @@ struct GenericBlendState {
|
||||
eqAlpha = eqA;
|
||||
}
|
||||
void setBlendColor(uint32_t color, uint8_t alpha) {
|
||||
blendColor = color | (alpha << 24);
|
||||
blendColor = color | ((uint32_t)alpha << 24);
|
||||
useBlendColor = true;
|
||||
}
|
||||
void defaultBlendColor(uint8_t alpha) {
|
||||
blendColor = 0xFFFFFF | (alpha << 24);
|
||||
blendColor = 0xFFFFFF | ((uint32_t)alpha << 24);
|
||||
useBlendColor = true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -166,30 +166,21 @@ void TransformDrawEngineDX9::ApplyDrawState(int prim) {
|
||||
shaderManager_->DirtyUniform(DIRTY_SHADERBLEND);
|
||||
}
|
||||
if (blendState.useBlendColor) {
|
||||
uint32_t color = blendState.blendColor;
|
||||
const float col[4] = {
|
||||
(float)((color & 0xFF) >> 0) * (1.0f / 255.0f),
|
||||
(float)((color & 0xFF00) >> 8) * (1.0f / 255.0f),
|
||||
(float)((color & 0xFF0000) >> 16) * (1.0f / 255.0f),
|
||||
(float)((color & 0xFF000000) >> 24) * (1.0f / 255.0f),
|
||||
};
|
||||
dxstate.blendColor.set(col);
|
||||
dxstate.blendColor.setDWORD(blendState.blendColor);
|
||||
}
|
||||
} else {
|
||||
dxstate.blend.disable();
|
||||
dxstate.blendSeparate.disable();
|
||||
}
|
||||
|
||||
// Set Dither
|
||||
if (gstate.isDitherEnabled()) {
|
||||
dxstate.dither.enable();
|
||||
dxstate.dither.set(true);
|
||||
} else
|
||||
} else {
|
||||
dxstate.dither.disable();
|
||||
}
|
||||
|
||||
// Set ColorMask/Stencil/Depth
|
||||
if (gstate.isModeClear()) {
|
||||
|
||||
// Set Cull
|
||||
dxstate.cullMode.set(false, false);
|
||||
|
||||
|
||||
@@ -269,6 +269,13 @@ private:
|
||||
restore();
|
||||
}
|
||||
}
|
||||
void setDWORD(DWORD newc) {
|
||||
newc = ((newc >> 8) & 0xff) | (newc & 0xff00ff00) | ((newc << 16) & 0xff0000); // ARGB -> ABGR fix
|
||||
if (c != newc) {
|
||||
c = newc;
|
||||
restore();
|
||||
}
|
||||
}
|
||||
void force(const float v[4]) {
|
||||
DWORD old = c;
|
||||
set(v);
|
||||
|
||||
Reference in new issue
Block a user