mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Get rid of the bool, not worth it.
This commit is contained in:
parent
7df9545195
commit
00c44ea799
@ -1327,7 +1327,7 @@ bool PPGeImage::Load() {
|
||||
unsigned char *textureData;
|
||||
int success;
|
||||
if (filename_.empty()) {
|
||||
success = pngLoadPtr(Memory::GetPointerRange(png_, size_), size_, &width_, &height_, &textureData);
|
||||
success = pngLoadPtr(Memory::GetPointerRange(png_, (u32)size_), size_, &width_, &height_, &textureData);
|
||||
} else {
|
||||
std::vector<u8> pngData;
|
||||
if (pspFileSystem.ReadEntireFile(filename_, pngData) < 0) {
|
||||
|
@ -260,7 +260,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
|
||||
if (texFunc == GE_TEXFUNC_BLEND) {
|
||||
WRITE(p, "float3 u_texenv : register(c%i);\n", CONST_PS_TEXENV);
|
||||
}
|
||||
WRITE(p, "bool u_texAlpha : register(b%i);\n", CONST_PS_TEXALPHA); // NOTE! "b" register, not "c"!
|
||||
WRITE(p, "float u_texNoAlpha : register(c%i);\n", CONST_PS_TEX_NO_ALPHA);
|
||||
}
|
||||
WRITE(p, "float3 u_fogcolor : register(c%i);\n", CONST_PS_FOGCOLOR);
|
||||
if (texture3D) {
|
||||
@ -354,7 +354,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
|
||||
WRITE(p, "uniform sampler2D tex;\n");
|
||||
}
|
||||
*uniformMask |= DIRTY_TEXALPHA;
|
||||
WRITE(p, "uniform bool u_texAlpha;\n");
|
||||
WRITE(p, "uniform float u_texNoAlpha;\n");
|
||||
}
|
||||
|
||||
if (readFramebufferTex) {
|
||||
@ -824,7 +824,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
|
||||
WRITE(p, " vec4 p = v_color0;\n");
|
||||
|
||||
if (texFunc != GE_TEXFUNC_REPLACE) {
|
||||
WRITE(p, " if (!u_texAlpha) { t.a = 1.0; }\n");
|
||||
WRITE(p, " t.a = max(t.a, u_texNoAlpha);\n");
|
||||
}
|
||||
|
||||
switch (texFunc) {
|
||||
@ -838,7 +838,9 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
|
||||
WRITE(p, " vec4 v = vec4(mix(p.rgb, u_texenv.rgb, t.rgb), p.a * t.a) + s;\n");
|
||||
break;
|
||||
case GE_TEXFUNC_REPLACE:
|
||||
WRITE(p, " vec4 v = (u_texAlpha ? t : vec4(t.rgb, p.a)) + s;\n");
|
||||
WRITE(p, " vec4 r = t;\n");
|
||||
WRITE(p, " r.a = mix(r.a, p.a, u_texNoAlpha);\n");
|
||||
WRITE(p, " vec4 v = r + s;\n");
|
||||
break;
|
||||
case GE_TEXFUNC_ADD:
|
||||
case GE_TEXFUNC_UNKNOWN1:
|
||||
|
@ -36,12 +36,12 @@ struct FShaderID;
|
||||
#define CONST_PS_TEXCLAMP 8
|
||||
#define CONST_PS_TEXCLAMPOFF 9
|
||||
#define CONST_PS_MIPBIAS 10
|
||||
#define CONST_PS_TEX_NO_ALPHA 11
|
||||
|
||||
// For stencil upload
|
||||
#define BCONST_PS_STENCILVALUE 11
|
||||
#define BCONST_PS_STENCILVALUE 12
|
||||
|
||||
// D3D9 bool constants, they have their own register space.
|
||||
#define CONST_PS_TEXALPHA 0
|
||||
|
||||
|
||||
// Can technically be deduced from the fragment shader ID, but this is safer.
|
||||
|
@ -199,7 +199,7 @@ void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms, bool flipView
|
||||
}
|
||||
|
||||
if (dirtyUniforms & DIRTY_TEXALPHA) {
|
||||
ub->texAlpha = gstate.isTextureAlphaUsed() ? 1 : 0;
|
||||
ub->texNoAlpha = gstate.isTextureAlphaUsed() ? 0.0f : 1.0f;
|
||||
}
|
||||
|
||||
if (dirtyUniforms & DIRTY_STENCILREPLACEVALUE) {
|
||||
|
@ -17,7 +17,7 @@ enum : uint64_t {
|
||||
DIRTY_MATDIFFUSE | DIRTY_MATSPECULAR | DIRTY_MATEMISSIVE | DIRTY_AMBIENT,
|
||||
};
|
||||
|
||||
// Currently 448 bytes.
|
||||
// Currently 496 bytes.
|
||||
// Every line here is a 4-float.
|
||||
struct alignas(16) UB_VS_FS_Base {
|
||||
float proj[16];
|
||||
@ -39,7 +39,7 @@ struct alignas(16) UB_VS_FS_Base {
|
||||
float blendFixB[3]; float rotation;
|
||||
float texClamp[4];
|
||||
float texClampOffset[2]; float fogCoef[2];
|
||||
uint32_t texAlpha; float pad[3];
|
||||
float texNoAlpha; float pad[3];
|
||||
// VR stuff is to go here, later. For normal drawing, we can then get away
|
||||
// with just uploading the first 448 bytes of the struct (up to and including fogCoef).
|
||||
};
|
||||
@ -66,7 +66,7 @@ R"( mat4 u_proj;
|
||||
vec4 u_texclamp;
|
||||
vec2 u_texclampoff;
|
||||
vec2 u_fogcoef;
|
||||
bool u_texAlpha; float pad0; float pad1; float pad2;
|
||||
float u_texNoAlpha; float pad0; float pad1; float pad2;
|
||||
)";
|
||||
|
||||
// 512 bytes. Would like to shrink more. Some colors only have 8-bit precision and we expand
|
||||
|
@ -285,7 +285,8 @@ void ShaderManagerDX9::PSUpdateUniforms(u64 dirtyUniforms) {
|
||||
PSSetFloat(CONST_PS_STENCILREPLACE, (float)gstate.getStencilTestRef() * (1.0f / 255.0f));
|
||||
}
|
||||
if (dirtyUniforms & DIRTY_TEXALPHA) {
|
||||
PSSetBool(CONST_PS_TEXALPHA, gstate.isTextureAlphaUsed());
|
||||
// NOTE: Reversed value, more efficient in shader.
|
||||
PSSetFloat(CONST_PS_TEX_NO_ALPHA, gstate.isTextureAlphaUsed() ? 0.0f : 1.0f);
|
||||
}
|
||||
if (dirtyUniforms & DIRTY_SHADERBLEND) {
|
||||
PSSetColorUniform3(CONST_PS_BLENDFIXA, gstate.getFixA());
|
||||
|
@ -152,7 +152,7 @@ LinkedShader::LinkedShader(GLRenderManager *render, VShaderID VSID, Shader *vs,
|
||||
queries.push_back({ &u_uvscaleoffset, "u_uvscaleoffset" });
|
||||
queries.push_back({ &u_texclamp, "u_texclamp" });
|
||||
queries.push_back({ &u_texclampoff, "u_texclampoff" });
|
||||
queries.push_back({ &u_texAlpha, "u_texAlpha" });
|
||||
queries.push_back({ &u_texNoAlpha, "u_texNoAlpha" });
|
||||
queries.push_back({ &u_lightControl, "u_lightControl" });
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
@ -446,7 +446,7 @@ void LinkedShader::UpdateUniforms(const ShaderID &vsid, bool useBufferedRenderin
|
||||
SetColorUniform3(render_, &u_texenv, gstate.texenvcolor);
|
||||
}
|
||||
if (dirty & DIRTY_TEXALPHA) {
|
||||
SetBoolUniform(render_, &u_texAlpha, gstate.isTextureAlphaUsed());
|
||||
render_->SetUniformF1(&u_texNoAlpha, gstate.isTextureAlphaUsed() ? 0.0f : 1.0f);
|
||||
}
|
||||
if (dirty & DIRTY_ALPHACOLORREF) {
|
||||
if (shaderLanguage.bitwiseOps) {
|
||||
|
@ -101,7 +101,7 @@ public:
|
||||
int u_uvscaleoffset;
|
||||
int u_texclamp;
|
||||
int u_texclampoff;
|
||||
int u_texAlpha;
|
||||
int u_texNoAlpha;
|
||||
|
||||
// Lighting
|
||||
int u_lightControl;
|
||||
|
Loading…
Reference in New Issue
Block a user