mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-19 21:52:45 +00:00
Remove SmoothedDepal compat setting, instead detect the ramp directly.
This commit is contained in:
parent
f5e6754ac0
commit
6558bde0f6
@ -98,7 +98,6 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) {
|
||||
CheckSetting(iniFile, gameID, "AllowLargeFBTextureOffsets", &flags_.AllowLargeFBTextureOffsets);
|
||||
CheckSetting(iniFile, gameID, "AtracLoopHack", &flags_.AtracLoopHack);
|
||||
CheckSetting(iniFile, gameID, "DeswizzleDepth", &flags_.DeswizzleDepth);
|
||||
CheckSetting(iniFile, gameID, "SmoothedDepal", &flags_.SmoothedDepal);
|
||||
}
|
||||
|
||||
void Compatibility::CheckSetting(IniFile &iniFile, const std::string &gameID, const char *option, bool *flag) {
|
||||
|
@ -88,7 +88,6 @@ struct CompatFlags {
|
||||
bool AllowLargeFBTextureOffsets;
|
||||
bool AtracLoopHack;
|
||||
bool DeswizzleDepth;
|
||||
bool SmoothedDepal;
|
||||
};
|
||||
|
||||
class IniFile;
|
||||
|
@ -90,7 +90,7 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu
|
||||
|
||||
bool doFlatShading = id.Bit(FS_BIT_FLATSHADE) && !flatBug;
|
||||
bool shaderDepal = id.Bit(FS_BIT_SHADER_DEPAL) && !texture3D; // combination with texture3D not supported. Enforced elsewhere too.
|
||||
bool smoothedDepal = PSP_CoreParameter().compat.flags().SmoothedDepal;
|
||||
bool smoothedDepal = id.Bit(FS_BIT_SHADER_SMOOTHED_DEPAL);
|
||||
bool bgraTexture = id.Bit(FS_BIT_BGRA_TEXTURE);
|
||||
bool colorWriteMask = id.Bit(FS_BIT_COLOR_WRITEMASK) && compat.bitwiseOps;
|
||||
|
||||
|
@ -261,6 +261,7 @@ void ComputeFragmentShaderID(FShaderID *id_out, const Draw::Bugs &bugs) {
|
||||
bool doTextureAlpha = gstate.isTextureAlphaUsed();
|
||||
bool doFlatShading = gstate.getShadeMode() == GE_SHADE_FLAT;
|
||||
bool useShaderDepal = gstate_c.useShaderDepal;
|
||||
bool useSmoothedDepal = gstate_c.useSmoothedShaderDepal;
|
||||
bool colorWriteMask = IsColorWriteMaskComplex(gstate_c.allowFramebufferRead);
|
||||
|
||||
// Note how we here recompute some of the work already done in state mapping.
|
||||
@ -290,6 +291,7 @@ void ComputeFragmentShaderID(FShaderID *id_out, const Draw::Bugs &bugs) {
|
||||
}
|
||||
id.SetBit(FS_BIT_BGRA_TEXTURE, gstate_c.bgraTexture);
|
||||
id.SetBit(FS_BIT_SHADER_DEPAL, useShaderDepal);
|
||||
id.SetBit(FS_BIT_SHADER_SMOOTHED_DEPAL, useSmoothedDepal);
|
||||
id.SetBit(FS_BIT_3D_TEXTURE, gstate_c.curTextureIs3D);
|
||||
}
|
||||
|
||||
|
@ -94,6 +94,7 @@ enum FShaderBit : uint8_t {
|
||||
FS_BIT_NO_DEPTH_CANNOT_DISCARD_STENCIL = 49,
|
||||
FS_BIT_COLOR_WRITEMASK = 50,
|
||||
FS_BIT_3D_TEXTURE = 51,
|
||||
FS_BIT_SHADER_SMOOTHED_DEPAL = 52,
|
||||
};
|
||||
|
||||
static inline FShaderBit operator +(FShaderBit bit, int i) {
|
||||
|
@ -1886,8 +1886,8 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer
|
||||
const GEPaletteFormat clutFormat = gstate.getClutPaletteFormat();
|
||||
|
||||
// Very icky conflation here of native and thin3d rendering. This will need careful work per backend in BindAsClutTexture.
|
||||
Draw::Texture *clutTexture = textureShaderCache_->GetClutTexture(clutFormat, clutHash_, clutBufRaw_);
|
||||
BindAsClutTexture(clutTexture);
|
||||
ClutTexture clutTexture = textureShaderCache_->GetClutTexture(clutFormat, clutHash_, clutBufRaw_);
|
||||
BindAsClutTexture(clutTexture.texture);
|
||||
|
||||
framebufferManager_->BindFramebufferAsColorTexture(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET);
|
||||
// Vulkan needs to do some extra work here to pick out the native handle from Draw.
|
||||
@ -1901,7 +1901,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer
|
||||
|
||||
// Since we started/ended render passes, might need these.
|
||||
gstate_c.Dirty(DIRTY_DEPAL);
|
||||
gstate_c.SetUseShaderDepal(true);
|
||||
gstate_c.SetUseShaderDepal(true, gstate.getClutIndexStartPos() == 0 && gstate.getClutIndexMask() <= clutTexture.rampLength);
|
||||
gstate_c.depalFramebufferFormat = framebuffer->drawnFormat;
|
||||
const u32 bytesPerColor = clutFormat == GE_CMODE_32BIT_ABGR8888 ? sizeof(u32) : sizeof(u16);
|
||||
const u32 clutTotalColors = clutMaxBytes_ / bytesPerColor;
|
||||
@ -1914,12 +1914,12 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer
|
||||
}
|
||||
|
||||
textureShader = textureShaderCache_->GetDepalettizeShader(clutMode, texFormat, depth ? GE_FORMAT_DEPTH16 : framebuffer->drawnFormat);
|
||||
gstate_c.SetUseShaderDepal(false);
|
||||
gstate_c.SetUseShaderDepal(false, false);
|
||||
}
|
||||
|
||||
if (textureShader) {
|
||||
const GEPaletteFormat clutFormat = gstate.getClutPaletteFormat();
|
||||
Draw::Texture *clutTexture = textureShaderCache_->GetClutTexture(clutFormat, clutHash_, clutBufRaw_);
|
||||
ClutTexture clutTexture = textureShaderCache_->GetClutTexture(clutFormat, clutHash_, clutBufRaw_);
|
||||
Draw::Framebuffer *depalFBO = framebufferManager_->GetTempFBO(TempFBO::DEPAL, framebuffer->renderWidth, framebuffer->renderHeight);
|
||||
draw_->BindTexture(0, nullptr);
|
||||
draw_->BindTexture(1, nullptr);
|
||||
@ -1930,7 +1930,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer
|
||||
draw_->SetViewports(1, &vp);
|
||||
|
||||
draw_->BindFramebufferAsTexture(framebuffer->fbo, 0, depth ? Draw::FB_DEPTH_BIT : Draw::FB_COLOR_BIT, 0);
|
||||
draw_->BindTexture(1, clutTexture);
|
||||
draw_->BindTexture(1, clutTexture.texture);
|
||||
Draw::SamplerState *nearest = textureShaderCache_->GetSampler();
|
||||
draw_->BindSamplerStates(0, 1, &nearest);
|
||||
draw_->BindSamplerStates(1, 1, &nearest);
|
||||
@ -1958,7 +1958,7 @@ void TextureCacheCommon::ApplyTextureFramebuffer(VirtualFramebuffer *framebuffer
|
||||
framebufferManager_->BindFramebufferAsColorTexture(0, framebuffer, BINDFBCOLOR_MAY_COPY_WITH_UV | BINDFBCOLOR_APPLY_TEX_OFFSET);
|
||||
BoundFramebufferTexture();
|
||||
|
||||
gstate_c.SetUseShaderDepal(false);
|
||||
gstate_c.SetUseShaderDepal(false, false);
|
||||
gstate_c.SetTextureFullAlpha(gstate.getTextureFormat() == GE_TFMT_5650);
|
||||
}
|
||||
|
||||
|
@ -51,22 +51,22 @@ void TextureShaderCache::DeviceLost() {
|
||||
Clear();
|
||||
}
|
||||
|
||||
Draw::Texture *TextureShaderCache::GetClutTexture(GEPaletteFormat clutFormat, const u32 clutHash, u32 *rawClut) {
|
||||
ClutTexture TextureShaderCache::GetClutTexture(GEPaletteFormat clutFormat, const u32 clutHash, u32 *rawClut) {
|
||||
// Simplistic, but works well enough.
|
||||
u32 clutId = clutHash ^ (uint32_t)clutFormat;
|
||||
|
||||
auto oldtex = texCache_.find(clutId);
|
||||
if (oldtex != texCache_.end()) {
|
||||
oldtex->second->lastFrame = gpuStats.numFlips;
|
||||
return oldtex->second->texture;
|
||||
return *oldtex->second;
|
||||
}
|
||||
|
||||
int texturePixels = clutFormat == GE_CMODE_32BIT_ABGR8888 ? 256 : 512;
|
||||
int maxClutEntries = clutFormat == GE_CMODE_32BIT_ABGR8888 ? 256 : 512;
|
||||
|
||||
ClutTexture *tex = new ClutTexture();
|
||||
|
||||
Draw::TextureDesc desc{};
|
||||
desc.width = texturePixels;
|
||||
desc.width = maxClutEntries;
|
||||
desc.height = 1;
|
||||
desc.depth = 1;
|
||||
desc.mipLevels = 1;
|
||||
@ -81,24 +81,49 @@ Draw::Texture *TextureShaderCache::GetClutTexture(GEPaletteFormat clutFormat, co
|
||||
desc.initData.push_back((const uint8_t *)rawClut);
|
||||
break;
|
||||
case GEPaletteFormat::GE_CMODE_16BIT_BGR5650:
|
||||
ConvertRGB565ToRGBA8888((u32 *)convTemp, (const u16 *)rawClut, texturePixels);
|
||||
ConvertRGB565ToRGBA8888((u32 *)convTemp, (const u16 *)rawClut, maxClutEntries);
|
||||
desc.initData.push_back(convTemp);
|
||||
break;
|
||||
case GEPaletteFormat::GE_CMODE_16BIT_ABGR5551:
|
||||
ConvertRGBA5551ToRGBA8888((u32 *)convTemp, (const u16 *)rawClut, texturePixels);
|
||||
ConvertRGBA5551ToRGBA8888((u32 *)convTemp, (const u16 *)rawClut, maxClutEntries);
|
||||
desc.initData.push_back(convTemp);
|
||||
break;
|
||||
case GEPaletteFormat::GE_CMODE_16BIT_ABGR4444:
|
||||
ConvertRGBA4444ToRGBA8888((u32 *)convTemp, (const u16 *)rawClut, texturePixels);
|
||||
ConvertRGBA4444ToRGBA8888((u32 *)convTemp, (const u16 *)rawClut, maxClutEntries);
|
||||
desc.initData.push_back(convTemp);
|
||||
break;
|
||||
}
|
||||
|
||||
int lastR = 0;
|
||||
int lastG = 0;
|
||||
int lastB = 0;
|
||||
int lastA = 0;
|
||||
|
||||
int rampLength = 0;
|
||||
// Quick check for how many continouosly growing entries we have at the start.
|
||||
// Bilinearly filtering CLUTs only really makes sense for this kind of ramp.
|
||||
for (int i = 0; i < maxClutEntries; i++) {
|
||||
rampLength = i + 1;
|
||||
int r = desc.initData[0][i * 4];
|
||||
int g = desc.initData[0][i * 4 + 1];
|
||||
int b = desc.initData[0][i * 4 + 2];
|
||||
int a = desc.initData[0][i * 4 + 3];
|
||||
if (r < lastR || g < lastG || b < lastB || a < lastA) {
|
||||
break;
|
||||
} else {
|
||||
lastR = r;
|
||||
lastG = g;
|
||||
lastB = b;
|
||||
lastA = a;
|
||||
}
|
||||
}
|
||||
|
||||
tex->texture = draw_->CreateTexture(desc);
|
||||
tex->lastFrame = gpuStats.numFlips;
|
||||
tex->rampLength = rampLength;
|
||||
|
||||
texCache_[clutId] = tex;
|
||||
return tex->texture;
|
||||
return *tex;
|
||||
}
|
||||
|
||||
void TextureShaderCache::Clear() {
|
||||
|
@ -39,6 +39,7 @@ class ClutTexture {
|
||||
public:
|
||||
Draw::Texture *texture;
|
||||
int lastFrame;
|
||||
int rampLength;
|
||||
};
|
||||
|
||||
// For CLUT depal shaders, and other pre-bind texture shaders.
|
||||
@ -49,7 +50,7 @@ public:
|
||||
~TextureShaderCache();
|
||||
|
||||
TextureShader *GetDepalettizeShader(uint32_t clutMode, GETextureFormat texFormat, GEBufferFormat pixelFormat);
|
||||
Draw::Texture *GetClutTexture(GEPaletteFormat clutFormat, const u32 clutHash, u32 *rawClut);
|
||||
ClutTexture GetClutTexture(GEPaletteFormat clutFormat, const u32 clutHash, u32 *rawClut);
|
||||
|
||||
Draw::SamplerState *GetSampler();
|
||||
|
||||
|
@ -225,7 +225,7 @@ void TextureCacheGLES::BindTexture(TexCacheEntry *entry) {
|
||||
int maxLevel = (entry->status & TexCacheEntry::STATUS_NO_MIPS) ? 0 : entry->maxLevel;
|
||||
SamplerCacheKey samplerKey = GetSamplingParams(maxLevel, entry);
|
||||
ApplySamplingParams(samplerKey);
|
||||
gstate_c.SetUseShaderDepal(false);
|
||||
gstate_c.SetUseShaderDepal(false, false);
|
||||
}
|
||||
|
||||
void TextureCacheGLES::Unbind() {
|
||||
|
@ -529,9 +529,10 @@ struct GPUStateCache {
|
||||
bool IsDirty(u64 what) const {
|
||||
return (dirty & what) != 0ULL;
|
||||
}
|
||||
void SetUseShaderDepal(bool depal) {
|
||||
void SetUseShaderDepal(bool depal, bool smoothed) {
|
||||
if (depal != useShaderDepal) {
|
||||
useShaderDepal = depal;
|
||||
useSmoothedShaderDepal = smoothed;
|
||||
Dirty(DIRTY_FRAGMENTSHADER_STATE);
|
||||
}
|
||||
}
|
||||
@ -635,6 +636,7 @@ struct GPUStateCache {
|
||||
int spline_num_points_u;
|
||||
|
||||
bool useShaderDepal;
|
||||
bool useSmoothedShaderDepal;
|
||||
GEBufferFormat depalFramebufferFormat;
|
||||
|
||||
u32 getRelativeAddress(u32 data) const;
|
||||
|
@ -402,7 +402,7 @@ void TextureCacheVulkan::BindTexture(TexCacheEntry *entry) {
|
||||
curSampler_ = samplerCache_.GetOrCreateSampler(samplerKey);
|
||||
imageView_ = entry->vkTex->GetImageView();
|
||||
drawEngine_->SetDepalTexture(VK_NULL_HANDLE);
|
||||
gstate_c.SetUseShaderDepal(false);
|
||||
gstate_c.SetUseShaderDepal(false, false);
|
||||
}
|
||||
|
||||
void TextureCacheVulkan::ApplySamplingParams(const SamplerCacheKey &key) {
|
||||
|
@ -1276,10 +1276,3 @@ UCKS45048 = true
|
||||
UCJS18030 = true
|
||||
UCJS18047 = true
|
||||
NPJG00015 = true
|
||||
|
||||
[SmoothedDepal]
|
||||
# Test Drive Unlimited smoothed CLUT lookups. See comments in #13355
|
||||
ULET00386 = true
|
||||
ULES00637 = true
|
||||
ULKS46126 = true
|
||||
ULUS10249 = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user