mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-01 22:31:58 +00:00
Fix a vshader id bit collision, avoid color test when set to 'ALWAYS', zeroinitialize dls.
This commit is contained in:
parent
cbbc4e2c9e
commit
ea11c36091
@ -62,20 +62,30 @@ static bool IsAlphaTestTriviallyTrue() {
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsColorTestTriviallyTrue() {
|
||||
int colorTestFunc = gstate.colortest & 3;
|
||||
switch (colorTestFunc) {
|
||||
case GE_COMP_ALWAYS:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Here we must take all the bits of the gstate that determine what the fragment shader will
|
||||
// look like, and concatenate them together into an ID.
|
||||
void ComputeFragmentShaderID(FragmentShaderID *id) {
|
||||
memset(&id->d[0], 0, sizeof(id->d));
|
||||
bool enableFog = gstate.isFogEnabled() && !gstate.isModeThrough() && !gstate.isModeClear();
|
||||
bool enableAlphaTest = gstate.isAlphaTestEnabled() && !IsAlphaTestTriviallyTrue();
|
||||
bool enableColorTest = gstate.isColorTestEnabled();
|
||||
int lmode = (gstate.lmode & 1) && gstate.isLightingEnabled();
|
||||
|
||||
if (gstate.clearmode & 1) {
|
||||
// We only need one clear shader, so let's ignore the rest of the bits.
|
||||
id->d[0] = 1;
|
||||
} else {
|
||||
bool enableFog = gstate.isFogEnabled() && !gstate.isModeThrough();
|
||||
bool enableAlphaTest = gstate.isAlphaTestEnabled() && !IsAlphaTestTriviallyTrue();
|
||||
bool enableColorTest = gstate.isColorTestEnabled() && !IsColorTestTriviallyTrue();
|
||||
int lmode = (gstate.lmode & 1) && gstate.isLightingEnabled();
|
||||
|
||||
// id->d[0] |= (gstate.clearmode & 1);
|
||||
if (gstate.isTextureMapEnabled()) {
|
||||
id->d[0] |= 1 << 1;
|
||||
@ -94,14 +104,11 @@ void ComputeFragmentShaderID(FragmentShaderID *id) {
|
||||
}
|
||||
}
|
||||
|
||||
// Missing: Alpha test, color test, Z depth range, fog
|
||||
// Missing: Z depth range
|
||||
// Also, logic ops etc, of course. Urgh.
|
||||
// We could do all this with booleans, but I don't trust the shader compilers on
|
||||
// Android devices to be anything but stupid.
|
||||
void GenerateFragmentShader(char *buffer) {
|
||||
char *p = buffer;
|
||||
|
||||
|
||||
#if defined(GLSL_ES_1_0)
|
||||
WRITE(p, "precision lowp float;\n");
|
||||
#elif !defined(FORCE_OPENGL_2_0)
|
||||
@ -112,11 +119,10 @@ void GenerateFragmentShader(char *buffer) {
|
||||
int doTexture = gstate.isTextureMapEnabled() && !gstate.isModeClear();
|
||||
|
||||
bool enableFog = gstate.isFogEnabled() && !gstate.isModeThrough() && !gstate.isModeClear();
|
||||
bool enableAlphaTest = gstate.isAlphaTestEnabled() && !gstate.isModeClear() && !IsAlphaTestTriviallyTrue();
|
||||
bool enableColorTest = gstate.isColorTestEnabled() && !gstate.isModeClear();
|
||||
bool enableAlphaTest = gstate.isAlphaTestEnabled() && !IsAlphaTestTriviallyTrue() && !gstate.isModeClear();
|
||||
bool enableColorTest = gstate.isColorTestEnabled() && !IsColorTestTriviallyTrue() && !gstate.isModeClear();
|
||||
bool enableColorDoubling = (gstate.texfunc & 0x10000) != 0;
|
||||
|
||||
|
||||
if (doTexture)
|
||||
WRITE(p, "uniform sampler2D tex;\n");
|
||||
|
||||
@ -143,7 +149,7 @@ void GenerateFragmentShader(char *buffer) {
|
||||
|
||||
WRITE(p, "void main() {\n");
|
||||
|
||||
if (gstate.clearmode & 1) {
|
||||
if (gstate.isModeClear()) {
|
||||
// Clear mode does not allow any fancy shading.
|
||||
WRITE(p, " gl_FragColor = v_color0;\n");
|
||||
} else {
|
||||
|
@ -36,16 +36,14 @@
|
||||
|
||||
#define WRITE p+=sprintf
|
||||
|
||||
bool CanUseHardwareTransform(int prim)
|
||||
{
|
||||
bool CanUseHardwareTransform(int prim) {
|
||||
if (!g_Config.bHardwareTransform)
|
||||
return false;
|
||||
return !gstate.isModeThrough() && prim != GE_PRIM_RECTANGLES;
|
||||
}
|
||||
|
||||
// prim so we can special case for RECTANGLES :(
|
||||
void ComputeVertexShaderID(VertexShaderID *id, int prim)
|
||||
{
|
||||
void ComputeVertexShaderID(VertexShaderID *id, int prim) {
|
||||
int doTexture = gstate.isTextureMapEnabled() && !gstate.isModeClear();
|
||||
|
||||
bool hasColor = (gstate.vertType & GE_VTYPE_COL_MASK) != 0;
|
||||
@ -84,8 +82,8 @@ void ComputeVertexShaderID(VertexShaderID *id, int prim)
|
||||
|
||||
// Okay, d[1] coming up. ==============
|
||||
|
||||
id->d[1] |= gstate.isLightingEnabled() << 19;
|
||||
if ((gstate.lightingEnable & 1) || gstate.getUVGenMode() == 2) {
|
||||
id->d[1] |= gstate.isLightingEnabled() << 24;
|
||||
if (gstate.isLightingEnabled() || gstate.getUVGenMode() == 2) {
|
||||
// Light bits
|
||||
for (int i = 0; i < 4; i++) {
|
||||
id->d[1] |= (gstate.ltype[i] & 3) << (i * 4);
|
||||
@ -99,7 +97,7 @@ void ComputeVertexShaderID(VertexShaderID *id, int prim)
|
||||
}
|
||||
}
|
||||
|
||||
const char *boneWeightAttrDecl[8] = {
|
||||
static const char * const boneWeightAttrDecl[8] = {
|
||||
"attribute float a_weight0123;\n",
|
||||
"attribute vec2 a_weight0123;\n",
|
||||
"attribute vec3 a_weight0123;\n",
|
||||
@ -110,7 +108,7 @@ const char *boneWeightAttrDecl[8] = {
|
||||
"attribute vec4 a_weight0123;\nattribute vec4 a_weight4567;\n",
|
||||
};
|
||||
|
||||
const char *boneWeightAttr[8] = {
|
||||
static const char * const boneWeightAttr[8] = {
|
||||
"a_weight0123.x",
|
||||
"a_weight0123.y",
|
||||
"a_weight0123.z",
|
||||
|
@ -22,6 +22,7 @@ GPUCommon::GPUCommon() :
|
||||
dumpThisFrame_(false),
|
||||
interruptsEnabled_(true)
|
||||
{
|
||||
memset(dls, 0, sizeof(dls));
|
||||
for (int i = 0; i < DisplayListMaxCount; ++i) {
|
||||
dls[i].state = PSP_GE_DL_STATE_NONE;
|
||||
dls[i].waitTicks = 0;
|
||||
|
@ -354,6 +354,6 @@ extern GPUInterface *gpu;
|
||||
extern GPUStatistics gpuStats;
|
||||
|
||||
inline u32 GPUStateCache::getRelativeAddress(u32 data) const {
|
||||
u32 baseExtended = ((gstate.base & 0x0F0000) << 8) | (data & 0xFFFFFF);
|
||||
u32 baseExtended = ((gstate.base & 0x0F0000) << 8) | data;
|
||||
return (gstate_c.offsetAddr + baseExtended) & 0x0FFFFFFF;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user