Skip to content

Commit

Permalink
DO NOT MERGE - Debug for hrydgard#13741.
Browse files Browse the repository at this point in the history
This logs the impacts of hrydgard#13762 so we can see why that helps, even though
it doesn't look like a correct fix.
  • Loading branch information
unknownbrackets committed Oct 13, 2021
1 parent bb64c17 commit a7ee65f
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
22 changes: 22 additions & 0 deletions GPU/Common/TextureCacheCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
#define TEXCACHE_MIN_PRESSURE 16 * 1024 * 1024 // Total in VRAM
#define TEXCACHE_SECOND_MIN_PRESSURE 4 * 1024 * 1024

bool texCacheDebugDifference = false;

// Just for reference

// PSP Color formats:
Expand Down Expand Up @@ -357,6 +359,9 @@ TexCacheEntry *TextureCacheCommon::SetTexture() {
u32 texaddr = gstate.getTextureAddress(level);
if (!Memory::IsValidAddress(texaddr)) {
// Bind a null texture and return.
if (texCacheDebugDifference) {
ERROR_LOG(HLE, "Bad texture found");
}
Unbind();
return nullptr;
}
Expand All @@ -375,6 +380,9 @@ TexCacheEntry *TextureCacheCommon::SetTexture() {
u32 cluthash;
if (hasClut) {
if (clutLastFormat_ != gstate.clutformat) {
if (texCacheDebugDifference) {
ERROR_LOG(HLE, "Clut change detected");
}
// We update here because the clut format can be specified after the load.
UpdateCurrentClut(gstate.getClutPaletteFormat(), gstate.getClutIndexStartPos(), gstate.isClutIndexSimple());
}
Expand All @@ -394,9 +402,15 @@ TexCacheEntry *TextureCacheCommon::SetTexture() {

// Note: It's necessary to reset needshadertexclamp, for otherwise DIRTY_TEXCLAMP won't get set later.
// Should probably revisit how this works..
if (texCacheDebugDifference && gstate_c.needShaderTexClamp) {
ERROR_LOG(HLE, "Clearing shader texclamp?");
}
gstate_c.SetNeedShaderTexclamp(false);
gstate_c.skipDrawReason &= ~SKIPDRAW_BAD_FB_TEXTURE;
if (gstate_c.bgraTexture != isBgraBackend_) {
if (texCacheDebugDifference) {
ERROR_LOG(HLE, "BGRA detected - how?");
}
gstate_c.Dirty(DIRTY_FRAGMENTSHADER_STATE);
}
gstate_c.bgraTexture = isBgraBackend_;
Expand All @@ -412,6 +426,7 @@ TexCacheEntry *TextureCacheCommon::SetTexture() {
// Fall through to the end where we'll delete the entry if there's a framebuffer.
entry->status &= ~TexCacheEntry::STATUS_FRAMEBUFFER_OVERLAP;
match = false;
reason = "framebuffer overlap";
}

bool rehash = entry->GetHashStatus() == TexCacheEntry::STATUS_UNRELIABLE;
Expand All @@ -430,6 +445,7 @@ TexCacheEntry *TextureCacheCommon::SetTexture() {
if (entry->status & TexCacheEntry::STATUS_FORCE_REBUILD) {
match = false;
entry->status &= ~TexCacheEntry::STATUS_FORCE_REBUILD;
reason = "force rebuild";
}

if (match) {
Expand Down Expand Up @@ -489,9 +505,15 @@ TexCacheEntry *TextureCacheCommon::SetTexture() {
nextNeedsChange_ = false;
// Might need a rebuild if the hash fails, but that will be set later.
nextNeedsRebuild_ = false;
if (texCacheDebugDifference) {
INFO_LOG(HLE, "Wasted difference? Or something earlier?");
}
VERBOSE_LOG(G3D, "Texture at %08x found in cache, applying", texaddr);
return entry; //Done!
} else {
if (texCacheDebugDifference) {
ERROR_LOG(HLE, "NOT A MATCH? reason=%s", reason);
}
// Wasn't a match, we will rebuild.
nextChangeReason_ = reason;
nextNeedsChange_ = true;
Expand Down
2 changes: 2 additions & 0 deletions GPU/Common/TextureCacheCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ enum FramebufferNotificationChannel {

#define TEXCACHE_MAX_TEXELS_SCALED (256*256) // Per frame

extern bool texCacheDebugDifference;

struct VirtualFramebuffer;
class TextureReplacer;

Expand Down
9 changes: 8 additions & 1 deletion GPU/Vulkan/DrawEngineVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ enum {
TRANSFORMED_VERTEX_BUFFER_SIZE = VERTEX_BUFFER_MAX * sizeof(TransformedVertex)
};

static bool forceTexParamsDirty = false;

DrawEngineVulkan::DrawEngineVulkan(VulkanContext *vulkan, Draw::DrawContext *draw)
: vulkan_(vulkan),
draw_(draw),
Expand Down Expand Up @@ -601,7 +603,11 @@ void DrawEngineVulkan::DoFlush() {
bool tess = gstate_c.submitType == SubmitType::HW_BEZIER || gstate_c.submitType == SubmitType::HW_SPLINE;

bool textureNeedsApply = false;
if (gstate_c.IsDirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS) && !gstate.isModeClear() && gstate.isTextureMapEnabled()) {
if ((forceTexParamsDirty || gstate_c.IsDirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS)) && !gstate.isModeClear() && gstate.isTextureMapEnabled()) {
texCacheDebugDifference = forceTexParamsDirty && !gstate_c.IsDirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS);
if (texCacheDebugDifference) {
NOTICE_LOG(HLE, "#13741 - Force texture params check for tex %08x", gstate.getTextureAddress(0));
}
textureCache_->SetTexture();
gstate_c.Clean(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS);
textureNeedsApply = true;
Expand Down Expand Up @@ -962,6 +968,7 @@ void DrawEngineVulkan::DoFlush() {
if (lastRenderStepId_ != curRenderStepId) {
// Dirty everything that has dynamic state that will need re-recording.
gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_DEPTHSTENCIL_STATE | DIRTY_BLEND_STATE);
forceTexParamsDirty = true;
lastRenderStepId_ = curRenderStepId;
}

Expand Down

0 comments on commit a7ee65f

Please sign in to comment.