Skip to content

Commit

Permalink
Fixed typo that has been preventing SK's D3D11 texture cache from eva…
Browse files Browse the repository at this point in the history
…luating the list of freeable textures when cache capacity exceeds user-defined limit for several years... oops?
  • Loading branch information
Kaldaien committed Dec 21, 2024
1 parent 6f17361 commit 794ea8f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
2 changes: 1 addition & 1 deletion include/SpecialK/render/d3d11/d3d11_state_tracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ struct memory_tracking_s
std::atomic <uint64_t> bytes_read = 0ULL;
std::atomic <uint64_t> bytes_written = 0ULL;
std::atomic <uint64_t> bytes_copied = 0ULL;
} lifetime, last_frame;
} lifetime = {}, last_frame = {};


std::atomic <uint32_t> num_maps = 0UL;
Expand Down
26 changes: 13 additions & 13 deletions src/render/d3d11/mod_tools/d3d11_shader_mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ SK_D3D11_ShaderModDlg (SK_TLS* pTLS = SK_TLS_Bottom ())

UINT rtv_idx = 0;

if (live_textures.count (it) != 0)
if (live_textures.contains (it))
{
if (! SK_D3D11_IsValidRTV (it))
{
Expand All @@ -939,16 +939,15 @@ SK_D3D11_ShaderModDlg (SK_TLS* pTLS = SK_TLS_Bottom ())
continue;
}

char szDebugDesc [128] = { };
wchar_t wszDebugDesc [128] = { };
UINT uiDebugLen = 127;

rtv_idx =
rt_indexes [it];

if (rtv_idx != std::numeric_limits <UINT>::max ())
{
uiDebugLen = sizeof (wszDebugDesc) - sizeof (wchar_t);
char szDebugDesc [128] = { };
wchar_t wszDebugDesc [128] = { };
UINT uiDebugLen =
sizeof (wszDebugDesc) - sizeof (wchar_t);

if ( SUCCEEDED (
it->GetPrivateData (
Expand All @@ -966,7 +965,8 @@ SK_D3D11_ShaderModDlg (SK_TLS* pTLS = SK_TLS_Bottom ())

else
{
uiDebugLen = sizeof (szDebugDesc) - sizeof (char);
uiDebugLen =
sizeof (szDebugDesc) - sizeof (char);

if ( SUCCEEDED (
it->GetPrivateData (
Expand Down Expand Up @@ -1229,9 +1229,9 @@ SK_D3D11_ShaderModDlg (SK_TLS* pTLS = SK_TLS_Bottom ())
}


if ( render_textures.size () > (size_t)sel &&
live_textures.count (render_textures [sel]) &&
discard_views.count (render_textures [sel]) == 0 )
if ( render_textures.size () > (size_t)sel &&
live_textures.contains (render_textures [sel]) &&
!discard_views.contains (render_textures [sel]) )
{
SK_ComPtr <ID3D11RenderTargetView>
rt_view (render_textures [sel]);
Expand Down Expand Up @@ -1410,9 +1410,9 @@ SK_D3D11_ShaderModDlg (SK_TLS* pTLS = SK_TLS_Bottom ())
ImGui::EndChildFrame ( );
ImGui::PopStyleColor ( );

if (draw_srv_overlay && pSRV.p != nullptr)
pOverlaySRV = pSRV.p;
else pOverlaySRV = nullptr;
if (draw_srv_overlay)
pOverlaySRV = pSRV.p;
else pOverlaySRV = nullptr;
}

if (bottom_list > 0)
Expand Down
11 changes: 6 additions & 5 deletions src/render/d3d11/tex_mgr/d3d11_tex_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ SK_D3D11_AddTexHash ( const wchar_t* name, uint32_t top_crc32, uint32_t hash )

{
std::scoped_lock <SK_Thread_HybridSpinlock> critical (*hash_cs);
textures.tex_hashes_ex.emplace (tag, name);
textures.tex_hashes_ex.try_emplace (tag, name);
}

SK_D3D11_AddInjectable (top_crc32, hash);
Expand All @@ -651,7 +651,7 @@ SK_D3D11_AddTexHash ( const wchar_t* name, uint32_t top_crc32, uint32_t hash )
{
{
std::scoped_lock <SK_Thread_HybridSpinlock> critical (*hash_cs);
textures.tex_hashes.emplace (top_crc32, name);
textures.tex_hashes.try_emplace (top_crc32, name);
}

if (! SK_D3D11_inject_textures_ffx)
Expand Down Expand Up @@ -941,10 +941,9 @@ SK_D3D11_DumpTexture2D ( _In_ ID3D11Texture2D* pTex, uint32_t crc32c )
wchar_t wszOutName [MAX_PATH + 2] = { };

bool bHasDebugName = false;
std::wstring wszSubDir = L"";

if (SK_D3D11_HasDebugName (pTex))
{
std::wstring
wszSubDir = SK_D3D11_GetDebugNameW (pTex) .empty () ?
SK_UTF8ToWideChar (SK_D3D11_GetDebugNameA (pTex)) :
SK_D3D11_GetDebugNameW (pTex);
Expand Down Expand Up @@ -2045,8 +2044,10 @@ SK_D3D11_TexCacheCheckpoint (void)
}


// This needs to be static, or the texture cache manager
// never releases any memory!
static int iter = 0;

int iter = 0;

static bool init = false;
static ULONGLONG ullMemoryTotal_KiB = 0;
Expand Down

0 comments on commit 794ea8f

Please sign in to comment.