Skip to content

Commit c2037e8

Browse files
committed
Add alwaysRecalculateTextureHashes option for games that dynamically update textures
This option can help in games that dynamically update existing textures. Remix normally does not update the hash after texture creation which can lead to issues with texture replacements or texture tagging.
1 parent cda9f2e commit c2037e8

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

src/d3d9/d3d9_common_texture.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -658,9 +658,13 @@ namespace dxvk {
658658
if (m_type != D3DRTYPE_TEXTURE || (m_desc.Usage & D3DUSAGE_DEPTHSTENCIL))
659659
return;
660660

661+
const bool alwaysRecalculateHash = RtxOptions::alwaysRecalculateTextureHashes();
662+
661663
if (m_image->getHash() != 0) {
662-
// Already setup.
663-
return;
664+
if (!alwaysRecalculateHash) {
665+
// Already setup.
666+
return;
667+
}
664668
}
665669

666670
// Use subresource 0 for hashing
@@ -682,6 +686,14 @@ namespace dxvk {
682686
} else {
683687
imageHash = XXH3_64bits(buffer->mapPtr(0), buffer->info().size);
684688
}
689+
690+
if (alwaysRecalculateHash) {
691+
// Release old texture if hash changed
692+
if (m_image->getHash() != imageHash) {
693+
ImGUI::ReleaseTexture(m_image->getHash());
694+
}
695+
}
696+
685697
// save hash to dxvkImage
686698
m_image->setHash(imageHash);
687699

src/dxvk/imgui/dxvk_imgui.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2595,7 +2595,8 @@ namespace dxvk {
25952595

25962596
if (IMGUI_ADD_TOOLTIP(ImGui::BeginTabItem("Step 1: Categorize Textures", nullptr, tab_item_flags), "Select texture definitions for Remix")) {
25972597
spacing();
2598-
ImGui::Checkbox("Preserve discarded textures", &RtxOptions::keepTexturesForTaggingObject());
2598+
ImGui::Checkbox("Preserve Discarded Textures", &RtxOptions::keepTexturesForTaggingObject());
2599+
ImGui::Checkbox("Always Recalculate Hashes", &RtxOptions::alwaysRecalculateTextureHashesObject());
25992600
separator();
26002601

26012602
// set thumbnail size

src/dxvk/rtx_render/rtx_options.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,11 @@ namespace dxvk {
11061106
"Whether or not to use slower XXH64 hash on texture upload.\n"
11071107
"New projects should not enable this option as this solely exists for compatibility with older hashing schemes.");
11081108

1109+
RTX_OPTION("rtx", bool, alwaysRecalculateTextureHashes, false,
1110+
"Use this option to recalculate the hash of a texture every time it is used, as streaming systems might override textures with other textures when they are no longer in use.\n"
1111+
"This might result in the wrong textures being used on meshes, as Remix normally does not recalculate texture hashes for performance reasons.\n"
1112+
"You may need to restart to see the full effect.");
1113+
11091114
RTX_OPTION("rtx", bool, serializeChangedOptionOnly, true, "");
11101115

11111116
RTX_OPTION("rtx", uint32_t, applicationId, 102100511, "Used to uniquely identify the application to DLSS. Generally should not be changed without good reason.");

0 commit comments

Comments
 (0)