mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Revert "Merge pull request #16628 from hrydgard/remove-fog-fshader-flag"
This reverts commit10dee90c83
, reversing changes made to34c11c8acf
.
This commit is contained in:
parent
ba4f2837e7
commit
f42c682d34
@ -97,6 +97,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
|
|||||||
p.ApplySamplerMetadata(arrayTexture ? samplersStereo : samplersMono);
|
p.ApplySamplerMetadata(arrayTexture ? samplersStereo : samplersMono);
|
||||||
|
|
||||||
bool doTexture = id.Bit(FS_BIT_DO_TEXTURE);
|
bool doTexture = id.Bit(FS_BIT_DO_TEXTURE);
|
||||||
|
bool enableFog = id.Bit(FS_BIT_ENABLE_FOG);
|
||||||
bool enableAlphaTest = id.Bit(FS_BIT_ALPHA_TEST);
|
bool enableAlphaTest = id.Bit(FS_BIT_ALPHA_TEST);
|
||||||
|
|
||||||
bool alphaTestAgainstZero = id.Bit(FS_BIT_ALPHA_AGAINST_ZERO);
|
bool alphaTestAgainstZero = id.Bit(FS_BIT_ALPHA_AGAINST_ZERO);
|
||||||
@ -259,7 +260,9 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
|
|||||||
WRITE(p, "float u_texNoAlpha : register(c%i);\n", CONST_PS_TEX_NO_ALPHA);
|
WRITE(p, "float u_texNoAlpha : register(c%i);\n", CONST_PS_TEX_NO_ALPHA);
|
||||||
WRITE(p, "float u_texMul : register(c%i);\n", CONST_PS_TEX_MUL);
|
WRITE(p, "float u_texMul : register(c%i);\n", CONST_PS_TEX_MUL);
|
||||||
}
|
}
|
||||||
WRITE(p, "float3 u_fogcolor : register(c%i);\n", CONST_PS_FOGCOLOR);
|
if (enableFog) {
|
||||||
|
WRITE(p, "float3 u_fogcolor : register(c%i);\n", CONST_PS_FOGCOLOR);
|
||||||
|
}
|
||||||
if (texture3D) {
|
if (texture3D) {
|
||||||
WRITE(p, "float u_mipBias : register(c%i);\n", CONST_PS_MIPBIAS);
|
WRITE(p, "float u_mipBias : register(c%i);\n", CONST_PS_MIPBIAS);
|
||||||
}
|
}
|
||||||
@ -423,8 +426,10 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
|
|||||||
|
|
||||||
WRITE(p, "%s %s lowp vec4 v_color0;\n", shading, compat.varying_fs);
|
WRITE(p, "%s %s lowp vec4 v_color0;\n", shading, compat.varying_fs);
|
||||||
WRITE(p, "%s %s lowp vec3 v_color1;\n", shading, compat.varying_fs);
|
WRITE(p, "%s %s lowp vec3 v_color1;\n", shading, compat.varying_fs);
|
||||||
*uniformMask |= DIRTY_FOGCOLOR;
|
if (enableFog) {
|
||||||
WRITE(p, "uniform vec3 u_fogcolor;\n");
|
*uniformMask |= DIRTY_FOGCOLOR;
|
||||||
|
WRITE(p, "uniform vec3 u_fogcolor;\n");
|
||||||
|
}
|
||||||
WRITE(p, "%s %s float v_fogdepth;\n", compat.varying_fs, highpFog ? "highp" : "mediump");
|
WRITE(p, "%s %s float v_fogdepth;\n", compat.varying_fs, highpFog ? "highp" : "mediump");
|
||||||
if (doTexture) {
|
if (doTexture) {
|
||||||
WRITE(p, "%s %s vec3 v_texcoord;\n", compat.varying_fs, highpTexcoord ? "highp" : "mediump");
|
WRITE(p, "%s %s vec3 v_texcoord;\n", compat.varying_fs, highpTexcoord ? "highp" : "mediump");
|
||||||
@ -531,7 +536,9 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
|
|||||||
if (compat.shaderLanguage == HLSL_D3D11 || compat.shaderLanguage == HLSL_D3D9) {
|
if (compat.shaderLanguage == HLSL_D3D11 || compat.shaderLanguage == HLSL_D3D9) {
|
||||||
WRITE(p, " vec4 v_color0 = In.v_color0;\n");
|
WRITE(p, " vec4 v_color0 = In.v_color0;\n");
|
||||||
WRITE(p, " vec3 v_color1 = In.v_color1;\n");
|
WRITE(p, " vec3 v_color1 = In.v_color1;\n");
|
||||||
WRITE(p, " float v_fogdepth = In.v_fogdepth;\n");
|
if (enableFog) {
|
||||||
|
WRITE(p, " float v_fogdepth = In.v_fogdepth;\n");
|
||||||
|
}
|
||||||
if (doTexture) {
|
if (doTexture) {
|
||||||
WRITE(p, " vec3 v_texcoord = In.v_texcoord;\n");
|
WRITE(p, " vec3 v_texcoord = In.v_texcoord;\n");
|
||||||
}
|
}
|
||||||
@ -857,8 +864,10 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
|
|||||||
WRITE(p, " vec4 v = v_color0 + s;\n");
|
WRITE(p, " vec4 v = v_color0 + s;\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
WRITE(p, " float fogCoef = clamp(v_fogdepth, 0.0, 1.0);\n");
|
if (enableFog) {
|
||||||
WRITE(p, " v = mix(vec4(u_fogcolor, v.a), v, fogCoef);\n");
|
WRITE(p, " float fogCoef = clamp(v_fogdepth, 0.0, 1.0);\n");
|
||||||
|
WRITE(p, " v = mix(vec4(u_fogcolor, v.a), v, fogCoef);\n");
|
||||||
|
}
|
||||||
|
|
||||||
// Texture access is at half texels [0.5/256, 255.5/256], but colors are normalized [0, 255].
|
// Texture access is at half texels [0.5/256, 255.5/256], but colors are normalized [0, 255].
|
||||||
// So we have to scale to account for the difference.
|
// So we have to scale to account for the difference.
|
||||||
|
@ -47,7 +47,7 @@ enum : uint64_t {
|
|||||||
DIRTY_PROJMATRIX = 1ULL << 0,
|
DIRTY_PROJMATRIX = 1ULL << 0,
|
||||||
DIRTY_PROJTHROUGHMATRIX = 1ULL << 1,
|
DIRTY_PROJTHROUGHMATRIX = 1ULL << 1,
|
||||||
DIRTY_FOGCOLOR = 1ULL << 2,
|
DIRTY_FOGCOLOR = 1ULL << 2,
|
||||||
DIRTY_FOGCOEFENABLE = 1ULL << 3,
|
DIRTY_FOGCOEF = 1ULL << 3,
|
||||||
DIRTY_TEXENV = 1ULL << 4,
|
DIRTY_TEXENV = 1ULL << 4,
|
||||||
DIRTY_ALPHACOLORREF = 1ULL << 5,
|
DIRTY_ALPHACOLORREF = 1ULL << 5,
|
||||||
|
|
||||||
|
@ -189,6 +189,7 @@ std::string FragmentShaderDesc(const FShaderID &id) {
|
|||||||
if (id.Bit(FS_BIT_CLEARMODE)) desc << "Clear ";
|
if (id.Bit(FS_BIT_CLEARMODE)) desc << "Clear ";
|
||||||
if (id.Bit(FS_BIT_DO_TEXTURE)) desc << (id.Bit(FS_BIT_3D_TEXTURE) ? "Tex3D " : "Tex ");
|
if (id.Bit(FS_BIT_DO_TEXTURE)) desc << (id.Bit(FS_BIT_3D_TEXTURE) ? "Tex3D " : "Tex ");
|
||||||
if (id.Bit(FS_BIT_DO_TEXTURE_PROJ)) desc << "TexProj ";
|
if (id.Bit(FS_BIT_DO_TEXTURE_PROJ)) desc << "TexProj ";
|
||||||
|
if (id.Bit(FS_BIT_ENABLE_FOG)) desc << "Fog ";
|
||||||
if (id.Bit(FS_BIT_FLATSHADE)) desc << "Flat ";
|
if (id.Bit(FS_BIT_FLATSHADE)) desc << "Flat ";
|
||||||
if (id.Bit(FS_BIT_BGRA_TEXTURE)) desc << "BGRA ";
|
if (id.Bit(FS_BIT_BGRA_TEXTURE)) desc << "BGRA ";
|
||||||
switch ((ShaderDepalMode)id.Bits(FS_BIT_SHADER_DEPAL_MODE, 2)) {
|
switch ((ShaderDepalMode)id.Bits(FS_BIT_SHADER_DEPAL_MODE, 2)) {
|
||||||
@ -325,6 +326,7 @@ void ComputeFragmentShaderID(FShaderID *id_out, const ComputedPipelineState &pip
|
|||||||
id.SetBit(FS_BIT_TEST_DISCARD_TO_ZERO, !NeedsTestDiscard());
|
id.SetBit(FS_BIT_TEST_DISCARD_TO_ZERO, !NeedsTestDiscard());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id.SetBit(FS_BIT_ENABLE_FOG, enableFog);
|
||||||
id.SetBit(FS_BIT_DO_TEXTURE_PROJ, doTextureProjection);
|
id.SetBit(FS_BIT_DO_TEXTURE_PROJ, doTextureProjection);
|
||||||
|
|
||||||
// 2 bits
|
// 2 bits
|
||||||
|
@ -80,7 +80,7 @@ enum FShaderBit : uint8_t {
|
|||||||
FS_BIT_COLOR_TEST = 17,
|
FS_BIT_COLOR_TEST = 17,
|
||||||
FS_BIT_COLOR_TEST_FUNC = 18, // 2 bits
|
FS_BIT_COLOR_TEST_FUNC = 18, // 2 bits
|
||||||
FS_BIT_COLOR_AGAINST_ZERO = 20,
|
FS_BIT_COLOR_AGAINST_ZERO = 20,
|
||||||
// 1 free bit
|
FS_BIT_ENABLE_FOG = 21,
|
||||||
FS_BIT_DO_TEXTURE_PROJ = 22,
|
FS_BIT_DO_TEXTURE_PROJ = 22,
|
||||||
// 1 free bit
|
// 1 free bit
|
||||||
FS_BIT_STENCIL_TO_ALPHA = 24, // 2 bits
|
FS_BIT_STENCIL_TO_ALPHA = 24, // 2 bits
|
||||||
|
@ -174,28 +174,21 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView
|
|||||||
ConvertMatrix4x3To3x4Transposed(ub->tex, gstate.tgenMatrix);
|
ConvertMatrix4x3To3x4Transposed(ub->tex, gstate.tgenMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dirtyUniforms & DIRTY_FOGCOEFENABLE) {
|
if (dirtyUniforms & DIRTY_FOGCOEF) {
|
||||||
if (gstate.isFogEnabled() && !gstate.isModeThrough()) {
|
float fogcoef[2] = {
|
||||||
float fogcoef[2] = {
|
getFloat24(gstate.fog1),
|
||||||
getFloat24(gstate.fog1),
|
getFloat24(gstate.fog2),
|
||||||
getFloat24(gstate.fog2),
|
};
|
||||||
};
|
// The PSP just ignores infnan here (ignoring IEEE), so take it down to a valid float.
|
||||||
// The PSP just ignores infnan here (ignoring IEEE), so take it down to a valid float.
|
// Workaround for https://github.com/hrydgard/ppsspp/issues/5384#issuecomment-38365988
|
||||||
// Workaround for https://github.com/hrydgard/ppsspp/issues/5384#issuecomment-38365988
|
if (my_isnanorinf(fogcoef[0])) {
|
||||||
if (my_isnanorinf(fogcoef[0])) {
|
// Not really sure what a sensible value might be, but let's try 64k.
|
||||||
// Not really sure what a sensible value might be, but let's try 64k.
|
fogcoef[0] = std::signbit(fogcoef[0]) ? -65535.0f : 65535.0f;
|
||||||
fogcoef[0] = std::signbit(fogcoef[0]) ? -65535.0f : 65535.0f;
|
|
||||||
}
|
|
||||||
if (my_isnanorinf(fogcoef[1])) {
|
|
||||||
fogcoef[1] = std::signbit(fogcoef[1]) ? -65535.0f : 65535.0f;
|
|
||||||
}
|
|
||||||
CopyFloat2(ub->fogCoef, fogcoef);
|
|
||||||
} else {
|
|
||||||
// not very useful values, use as marker for disabled fog.
|
|
||||||
// could also burn one extra uniform.
|
|
||||||
ub->fogCoef[0] = -65536.0f;
|
|
||||||
ub->fogCoef[1] = -65536.0f;
|
|
||||||
}
|
}
|
||||||
|
if (my_isnanorinf(fogcoef[1])) {
|
||||||
|
fogcoef[1] = std::signbit(fogcoef[1]) ? -65535.0f : 65535.0f;
|
||||||
|
}
|
||||||
|
CopyFloat2(ub->fogCoef, fogcoef);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dirtyUniforms & DIRTY_TEX_ALPHA_MUL) {
|
if (dirtyUniforms & DIRTY_TEX_ALPHA_MUL) {
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
enum : uint64_t {
|
enum : uint64_t {
|
||||||
DIRTY_BASE_UNIFORMS =
|
DIRTY_BASE_UNIFORMS =
|
||||||
DIRTY_WORLDMATRIX | DIRTY_PROJTHROUGHMATRIX | DIRTY_VIEWMATRIX | DIRTY_TEXMATRIX | DIRTY_ALPHACOLORREF |
|
DIRTY_WORLDMATRIX | DIRTY_PROJTHROUGHMATRIX | DIRTY_VIEWMATRIX | DIRTY_TEXMATRIX | DIRTY_ALPHACOLORREF |
|
||||||
DIRTY_PROJMATRIX | DIRTY_FOGCOLOR | DIRTY_FOGCOEFENABLE | DIRTY_TEXENV | DIRTY_TEX_ALPHA_MUL | DIRTY_STENCILREPLACEVALUE |
|
DIRTY_PROJMATRIX | DIRTY_FOGCOLOR | DIRTY_FOGCOEF | DIRTY_TEXENV | DIRTY_TEX_ALPHA_MUL | DIRTY_STENCILREPLACEVALUE |
|
||||||
DIRTY_ALPHACOLORMASK | DIRTY_SHADERBLEND | DIRTY_COLORWRITEMASK | DIRTY_UVSCALEOFFSET | DIRTY_TEXCLAMP | DIRTY_DEPTHRANGE | DIRTY_MATAMBIENTALPHA |
|
DIRTY_ALPHACOLORMASK | DIRTY_SHADERBLEND | DIRTY_COLORWRITEMASK | DIRTY_UVSCALEOFFSET | DIRTY_TEXCLAMP | DIRTY_DEPTHRANGE | DIRTY_MATAMBIENTALPHA |
|
||||||
DIRTY_BEZIERSPLINE | DIRTY_DEPAL,
|
DIRTY_BEZIERSPLINE | DIRTY_DEPAL,
|
||||||
DIRTY_LIGHT_UNIFORMS =
|
DIRTY_LIGHT_UNIFORMS =
|
||||||
|
@ -241,11 +241,9 @@ void SoftwareTransform::Decode(int prim, u32 vertType, const DecVtxFormat &decVt
|
|||||||
|
|
||||||
// Ignore color1 and fog, never used in throughmode anyway.
|
// Ignore color1 and fog, never used in throughmode anyway.
|
||||||
// The w of uv is also never used (hardcoded to 1.0.)
|
// The w of uv is also never used (hardcoded to 1.0.)
|
||||||
vert.fog = 1.0;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const Vec4f materialAmbientRGBA = Vec4f::FromRGBA(gstate.getMaterialAmbientRGBA());
|
const Vec4f materialAmbientRGBA = Vec4f::FromRGBA(gstate.getMaterialAmbientRGBA());
|
||||||
bool fogEnabled = gstate.isFogEnabled();
|
|
||||||
// Okay, need to actually perform the full transform.
|
// Okay, need to actually perform the full transform.
|
||||||
for (int index = 0; index < maxIndex; index++) {
|
for (int index = 0; index < maxIndex; index++) {
|
||||||
reader.Goto(index);
|
reader.Goto(index);
|
||||||
@ -254,6 +252,7 @@ void SoftwareTransform::Decode(int prim, u32 vertType, const DecVtxFormat &decVt
|
|||||||
Vec4f c0 = Vec4f(1, 1, 1, 1);
|
Vec4f c0 = Vec4f(1, 1, 1, 1);
|
||||||
Vec4f c1 = Vec4f(0, 0, 0, 0);
|
Vec4f c1 = Vec4f(0, 0, 0, 0);
|
||||||
float uv[3] = {0, 0, 1};
|
float uv[3] = {0, 0, 1};
|
||||||
|
float fogCoef = 1.0f;
|
||||||
|
|
||||||
float out[3];
|
float out[3];
|
||||||
float pos[3];
|
float pos[3];
|
||||||
@ -415,10 +414,11 @@ void SoftwareTransform::Decode(int prim, u32 vertType, const DecVtxFormat &decVt
|
|||||||
|
|
||||||
// Transform the coord by the view matrix.
|
// Transform the coord by the view matrix.
|
||||||
Vec3ByMatrix43(v, out, gstate.viewMatrix);
|
Vec3ByMatrix43(v, out, gstate.viewMatrix);
|
||||||
|
fogCoef = (v[2] + fog_end) * fog_slope;
|
||||||
|
|
||||||
// TODO: Write to a flexible buffer, we don't always need all four components.
|
// TODO: Write to a flexible buffer, we don't always need all four components.
|
||||||
Vec3ByMatrix44(transformed[index].pos, v, projMatrix_.m);
|
Vec3ByMatrix44(transformed[index].pos, v, projMatrix_.m);
|
||||||
transformed[index].fog = fogEnabled ? (v[2] + fog_end) * fog_slope : 1.0f;
|
transformed[index].fog = fogCoef;
|
||||||
memcpy(&transformed[index].uv, uv, 3 * sizeof(float));
|
memcpy(&transformed[index].uv, uv, 3 * sizeof(float));
|
||||||
transformed[index].color0_32 = c0.ToRGBA();
|
transformed[index].color0_32 = c0.ToRGBA();
|
||||||
transformed[index].color1_32 = c1.ToRGBA();
|
transformed[index].color1_32 = c1.ToRGBA();
|
||||||
|
@ -576,10 +576,8 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag
|
|||||||
WRITE(p, "uniform lowp vec4 u_matambientalpha;\n"); // matambient + matalpha
|
WRITE(p, "uniform lowp vec4 u_matambientalpha;\n"); // matambient + matalpha
|
||||||
*uniformMask |= DIRTY_MATAMBIENTALPHA;
|
*uniformMask |= DIRTY_MATAMBIENTALPHA;
|
||||||
}
|
}
|
||||||
if (useHWTransform) {
|
WRITE(p, "uniform highp vec2 u_fogcoef;\n");
|
||||||
WRITE(p, "uniform highp vec2 u_fogcoef;\n");
|
*uniformMask |= DIRTY_FOGCOEF;
|
||||||
*uniformMask |= DIRTY_FOGCOEFENABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isModeThrough) {
|
if (!isModeThrough) {
|
||||||
WRITE(p, "uniform highp vec4 u_depthRange;\n");
|
WRITE(p, "uniform highp vec4 u_depthRange;\n");
|
||||||
@ -1292,14 +1290,8 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute fogdepth. [branch] works around an apparent d3d9 shader compiler bug.
|
// Compute fogdepth
|
||||||
if (compat.shaderLanguage == HLSL_D3D9)
|
WRITE(p, " %sv_fogdepth = (viewPos.z + u_fogcoef.x) * u_fogcoef.y;\n", compat.vsOutPrefix);
|
||||||
WRITE(p, " [branch]\n");
|
|
||||||
WRITE(p, " if (u_fogcoef.x <= -65535.0 && u_fogcoef.y <= -65535.0) {\n");
|
|
||||||
WRITE(p, " %sv_fogdepth = 1.0;\n", compat.vsOutPrefix);
|
|
||||||
WRITE(p, " } else {\n");
|
|
||||||
WRITE(p, " %sv_fogdepth = (viewPos.z + u_fogcoef.x) * u_fogcoef.y;\n", compat.vsOutPrefix);
|
|
||||||
WRITE(p, " }\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (clipClampedDepth) {
|
if (clipClampedDepth) {
|
||||||
|
@ -338,7 +338,7 @@ void ShaderManagerDX9::PSUpdateUniforms(u64 dirtyUniforms) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const uint64_t vsUniforms = DIRTY_PROJMATRIX | DIRTY_PROJTHROUGHMATRIX | DIRTY_WORLDMATRIX | DIRTY_VIEWMATRIX | DIRTY_TEXMATRIX |
|
const uint64_t vsUniforms = DIRTY_PROJMATRIX | DIRTY_PROJTHROUGHMATRIX | DIRTY_WORLDMATRIX | DIRTY_VIEWMATRIX | DIRTY_TEXMATRIX |
|
||||||
DIRTY_FOGCOEFENABLE | DIRTY_BONE_UNIFORMS | DIRTY_UVSCALEOFFSET | DIRTY_DEPTHRANGE | DIRTY_CULLRANGE |
|
DIRTY_FOGCOEF | DIRTY_BONE_UNIFORMS | DIRTY_UVSCALEOFFSET | DIRTY_DEPTHRANGE | DIRTY_CULLRANGE |
|
||||||
DIRTY_AMBIENT | DIRTY_MATAMBIENTALPHA | DIRTY_MATSPECULAR | DIRTY_MATDIFFUSE | DIRTY_MATEMISSIVE | DIRTY_LIGHT0 | DIRTY_LIGHT1 | DIRTY_LIGHT2 | DIRTY_LIGHT3;
|
DIRTY_AMBIENT | DIRTY_MATAMBIENTALPHA | DIRTY_MATSPECULAR | DIRTY_MATDIFFUSE | DIRTY_MATEMISSIVE | DIRTY_LIGHT0 | DIRTY_LIGHT1 | DIRTY_LIGHT2 | DIRTY_LIGHT3;
|
||||||
|
|
||||||
void ShaderManagerDX9::VSUpdateUniforms(u64 dirtyUniforms) {
|
void ShaderManagerDX9::VSUpdateUniforms(u64 dirtyUniforms) {
|
||||||
@ -385,27 +385,21 @@ void ShaderManagerDX9::VSUpdateUniforms(u64 dirtyUniforms) {
|
|||||||
if (dirtyUniforms & DIRTY_TEXMATRIX) {
|
if (dirtyUniforms & DIRTY_TEXMATRIX) {
|
||||||
VSSetMatrix4x3_3(CONST_VS_TEXMTX, gstate.tgenMatrix);
|
VSSetMatrix4x3_3(CONST_VS_TEXMTX, gstate.tgenMatrix);
|
||||||
}
|
}
|
||||||
if (dirtyUniforms & DIRTY_FOGCOEFENABLE) {
|
if (dirtyUniforms & DIRTY_FOGCOEF) {
|
||||||
if (gstate.isFogEnabled() && !gstate.isModeThrough()) {
|
float fogcoef[2] = {
|
||||||
float fogcoef[2] = {
|
getFloat24(gstate.fog1),
|
||||||
getFloat24(gstate.fog1),
|
getFloat24(gstate.fog2),
|
||||||
getFloat24(gstate.fog2),
|
};
|
||||||
};
|
// The PSP just ignores infnan here (ignoring IEEE), so take it down to a valid float.
|
||||||
// The PSP just ignores infnan here (ignoring IEEE), so take it down to a valid float.
|
// Workaround for https://github.com/hrydgard/ppsspp/issues/5384#issuecomment-38365988
|
||||||
// Workaround for https://github.com/hrydgard/ppsspp/issues/5384#issuecomment-38365988
|
if (my_isnanorinf(fogcoef[0])) {
|
||||||
if (my_isnanorinf(fogcoef[0])) {
|
// Not really sure what a sensible value might be, but let's try 64k.
|
||||||
// Not really sure what a sensible value might be, but let's try 64k.
|
fogcoef[0] = std::signbit(fogcoef[0]) ? -65535.0f : 65535.0f;
|
||||||
fogcoef[0] = std::signbit(fogcoef[0]) ? -65535.0f : 65535.0f;
|
|
||||||
}
|
|
||||||
if (my_isnanorinf(fogcoef[1])) {
|
|
||||||
fogcoef[1] = std::signbit(fogcoef[1]) ? -65535.0f : 65535.0f;
|
|
||||||
}
|
|
||||||
VSSetFloatArray(CONST_VS_FOGCOEF, fogcoef, 2);
|
|
||||||
} else {
|
|
||||||
// not very useful values, use as marker for disabled fog.
|
|
||||||
float fogcoef[2] = { -65536.0f, -65536.0f };
|
|
||||||
VSSetFloatArray(CONST_VS_FOGCOEF, fogcoef, 2);
|
|
||||||
}
|
}
|
||||||
|
if (my_isnanorinf(fogcoef[1])) {
|
||||||
|
fogcoef[1] = std::signbit(fogcoef[1]) ? -65535.0f : 65535.0f;
|
||||||
|
}
|
||||||
|
VSSetFloatArray(CONST_VS_FOGCOEF, fogcoef, 2);
|
||||||
}
|
}
|
||||||
// TODO: Could even set all bones in one go if they're all dirty.
|
// TODO: Could even set all bones in one go if they're all dirty.
|
||||||
#ifdef USE_BONE_ARRAY
|
#ifdef USE_BONE_ARRAY
|
||||||
|
@ -488,26 +488,21 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, bool useBufferedRenderin
|
|||||||
SetVRCompat(VR_COMPAT_FOG_COLOR, gstate.fogcolor);
|
SetVRCompat(VR_COMPAT_FOG_COLOR, gstate.fogcolor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dirty & DIRTY_FOGCOEFENABLE) {
|
if (dirty & DIRTY_FOGCOEF) {
|
||||||
if (gstate.isFogEnabled() && !gstate.isModeThrough()) {
|
float fogcoef[2] = {
|
||||||
float fogcoef[2] = {
|
getFloat24(gstate.fog1),
|
||||||
getFloat24(gstate.fog1),
|
getFloat24(gstate.fog2),
|
||||||
getFloat24(gstate.fog2),
|
};
|
||||||
};
|
// The PSP just ignores infnan here (ignoring IEEE), so take it down to a valid float.
|
||||||
// The PSP just ignores infnan here (ignoring IEEE), so take it down to a valid float.
|
// Workaround for https://github.com/hrydgard/ppsspp/issues/5384#issuecomment-38365988
|
||||||
// Workaround for https://github.com/hrydgard/ppsspp/issues/5384#issuecomment-38365988
|
if (my_isnanorinf(fogcoef[0])) {
|
||||||
if (my_isnanorinf(fogcoef[0])) {
|
// Not really sure what a sensible value might be, but let's try 64k.
|
||||||
// Not really sure what a sensible value might be, but let's try 64k.
|
fogcoef[0] = std::signbit(fogcoef[0]) ? -65535.0f : 65535.0f;
|
||||||
fogcoef[0] = std::signbit(fogcoef[0]) ? -65535.0f : 65535.0f;
|
|
||||||
}
|
|
||||||
if (my_isnanorinf(fogcoef[1])) {
|
|
||||||
fogcoef[1] = std::signbit(fogcoef[1]) ? -65535.0f : 65535.0f;
|
|
||||||
}
|
|
||||||
render_->SetUniformF(&u_fogcoef, 2, fogcoef);
|
|
||||||
} else {
|
|
||||||
float fogcoef[2] = { -65536.0f, -65536.0f };
|
|
||||||
render_->SetUniformF(&u_fogcoef, 2, fogcoef);
|
|
||||||
}
|
}
|
||||||
|
if (my_isnanorinf(fogcoef[1])) {
|
||||||
|
fogcoef[1] = std::signbit(fogcoef[1]) ? -65535.0f : 65535.0f;
|
||||||
|
}
|
||||||
|
render_->SetUniformF(&u_fogcoef, 2, fogcoef);
|
||||||
}
|
}
|
||||||
if (dirty & DIRTY_UVSCALEOFFSET) {
|
if (dirty & DIRTY_UVSCALEOFFSET) {
|
||||||
const float invW = 1.0f / (float)gstate_c.curTextureWidth;
|
const float invW = 1.0f / (float)gstate_c.curTextureWidth;
|
||||||
@ -970,7 +965,7 @@ enum class CacheDetectFlags {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define CACHE_HEADER_MAGIC 0x83277592
|
#define CACHE_HEADER_MAGIC 0x83277592
|
||||||
#define CACHE_VERSION 28
|
#define CACHE_VERSION 29
|
||||||
|
|
||||||
struct CacheHeader {
|
struct CacheHeader {
|
||||||
uint32_t magic;
|
uint32_t magic;
|
||||||
|
@ -70,13 +70,13 @@ const CommonCommandTableEntry commonCommandTable[] = {
|
|||||||
{ GE_CMD_ZBUFWIDTH, FLAG_FLUSHBEFOREONCHANGE },
|
{ GE_CMD_ZBUFWIDTH, FLAG_FLUSHBEFOREONCHANGE },
|
||||||
|
|
||||||
{ GE_CMD_FOGCOLOR, FLAG_FLUSHBEFOREONCHANGE, DIRTY_FOGCOLOR },
|
{ GE_CMD_FOGCOLOR, FLAG_FLUSHBEFOREONCHANGE, DIRTY_FOGCOLOR },
|
||||||
{ GE_CMD_FOG1, FLAG_FLUSHBEFOREONCHANGE, DIRTY_FOGCOEFENABLE },
|
{ GE_CMD_FOG1, FLAG_FLUSHBEFOREONCHANGE, DIRTY_FOGCOEF },
|
||||||
{ GE_CMD_FOG2, FLAG_FLUSHBEFOREONCHANGE, DIRTY_FOGCOEFENABLE },
|
{ GE_CMD_FOG2, FLAG_FLUSHBEFOREONCHANGE, DIRTY_FOGCOEF },
|
||||||
|
|
||||||
// These affect the fragment shader so need flushing.
|
// These affect the fragment shader so need flushing.
|
||||||
{ GE_CMD_CLEARMODE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_CULLRANGE | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE },
|
{ GE_CMD_CLEARMODE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_CULLRANGE | DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE },
|
||||||
{ GE_CMD_TEXTUREMAPENABLE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE },
|
{ GE_CMD_TEXTUREMAPENABLE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE },
|
||||||
{ GE_CMD_FOGENABLE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_FOGCOEFENABLE },
|
{ GE_CMD_FOGENABLE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_FRAGMENTSHADER_STATE },
|
||||||
{ GE_CMD_TEXMODE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_TEXTURE_PARAMS | DIRTY_FRAGMENTSHADER_STATE },
|
{ GE_CMD_TEXMODE, FLAG_FLUSHBEFOREONCHANGE, DIRTY_TEXTURE_PARAMS | DIRTY_FRAGMENTSHADER_STATE },
|
||||||
{ GE_CMD_TEXSHADELS, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE },
|
{ GE_CMD_TEXSHADELS, FLAG_FLUSHBEFOREONCHANGE, DIRTY_VERTEXSHADER_STATE },
|
||||||
// Raster state for Direct3D 9, uncommon.
|
// Raster state for Direct3D 9, uncommon.
|
||||||
@ -828,7 +828,7 @@ void GPUCommonHW::Execute_VertexType(u32 op, u32 diff) {
|
|||||||
gstate_c.Dirty(DIRTY_UVSCALEOFFSET);
|
gstate_c.Dirty(DIRTY_UVSCALEOFFSET);
|
||||||
// Switching between through and non-through, we need to invalidate a bunch of stuff.
|
// Switching between through and non-through, we need to invalidate a bunch of stuff.
|
||||||
if (diff & GE_VTYPE_THROUGH_MASK)
|
if (diff & GE_VTYPE_THROUGH_MASK)
|
||||||
gstate_c.Dirty(DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE | DIRTY_CULLRANGE | DIRTY_FOGCOEFENABLE);
|
gstate_c.Dirty(DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE | DIRTY_CULLRANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -850,7 +850,7 @@ void GPUCommonHW::Execute_VertexTypeSkinning(u32 op, u32 diff) {
|
|||||||
gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE);
|
gstate_c.Dirty(DIRTY_VERTEXSHADER_STATE);
|
||||||
}
|
}
|
||||||
if (diff & GE_VTYPE_THROUGH_MASK)
|
if (diff & GE_VTYPE_THROUGH_MASK)
|
||||||
gstate_c.Dirty(DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE | DIRTY_CULLRANGE | DIRTY_FOGCOEFENABLE);
|
gstate_c.Dirty(DIRTY_RASTER_STATE | DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_FRAGMENTSHADER_STATE | DIRTY_GEOMETRYSHADER_STATE | DIRTY_CULLRANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPUCommonHW::Execute_Prim(u32 op, u32 diff) {
|
void GPUCommonHW::Execute_Prim(u32 op, u32 diff) {
|
||||||
|
@ -516,7 +516,7 @@ enum class VulkanCacheDetectFlags {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#define CACHE_HEADER_MAGIC 0xff51f420
|
#define CACHE_HEADER_MAGIC 0xff51f420
|
||||||
#define CACHE_VERSION 42
|
#define CACHE_VERSION 43
|
||||||
|
|
||||||
struct VulkanCacheHeader {
|
struct VulkanCacheHeader {
|
||||||
uint32_t magic;
|
uint32_t magic;
|
||||||
|
Loading…
Reference in New Issue
Block a user