Skip to content

GS: add texture replacement wildcard aliases#14584

Open
FrederickCampbell wants to merge 2 commits into
PCSX2:masterfrom
FrederickCampbell:texturefix-wildcard-aliases
Open

GS: add texture replacement wildcard aliases#14584
FrederickCampbell wants to merge 2 commits into
PCSX2:masterfrom
FrederickCampbell:texturefix-wildcard-aliases

Conversation

@FrederickCampbell

@FrederickCampbell FrederickCampbell commented Jun 12, 2026

Copy link
Copy Markdown

Description of Changes

Adds wildcard alias support for hardware texture replacements.

The new alias format allows a replacement filename to omit the source texture hash and match by CLUT hash plus texture state bits instead:

$-CLUTHash-bits.png
$-CLUTHash-rWIDTHxHEIGHT-bits.png

For example:

$-93e00f7acd524278-00001a13.png

can match exact filenames such as:

3f1a11ddd3a520fd-93e00f7acd524278-00001a13.png
58c39500d315e46-93e00f7acd524278-00001a13.png
c508f0f1068b0fc4-93e00f7acd524278-00001a13.png

Exact replacement filenames are still checked first. Wildcard aliases are fallback-only.

This also updates dump suppression so alias-covered exact variants are not dumped repeatedly, and recursively scans existing files under the dumps folder so valid dumps moved into subfolders are not redumped into the root dump folder.

Rationale behind Changes

Some games can dump multiple visually identical texture replacement candidates where only the first texture hash changes. This makes replacement packs harder to maintain because creators may need to duplicate the same replacement image under many exact filenames.

The alias format lets pack authors keep one replacement image for these cases while preserving the existing exact filename system.

Suggested Testing Steps

  1. Build PCSX2.

  2. Enable texture replacement loading.

  3. Add a wildcard replacement alias, for example:

    $-93e00f7acd524278-00001a13.png
    
  4. Remove or move the exact replacement filenames covered by that alias.

  5. Boot a game that previously produced multiple exact filenames sharing the same CLUT hash and texture state bits.

  6. Confirm the wildcard alias loads in place of the exact filenames.

  7. Enable texture dumping.

  8. Confirm alias-covered exact variants are not dumped repeatedly.

  9. Move a valid dump into a subfolder under dumps and confirm it is not redumped into the root dumps folder.

Manual testing performed:

  • Built successfully on Windows using Visual Studio Build Tools 2022.
  • Tested with Kingdom Hearts Final Mix texture replacements.
  • Verified that $-93e00f7acd524278-00001a13.png replaced multiple Sora HUD exact filenames that share the same CLUT hash and texture state bits.
  • Verified that existing exact filenames could be removed while the wildcard alias continued to load correctly.

Did you use AI to help find, test, or implement this issue or feature?

Yes. I used ChatGPT for implementation planning assistance, local scripting/build troubleshooting, and drafting PR text. I manually reviewed the changes, built the project locally, tested the feature in-game, and can explain the implementation and testing.

@JordanTheToaster

Copy link
Copy Markdown
Member

Please use the provided PR template.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for submitting a contribution to PCSX2

As this is your first pull request, please be aware of the contributing guidelines.

Additionally, as per recent changes in GitHub Actions, your pull request will need to be approved by a maintainer before GitHub Actions can run against it. You can find more information about this change here.

Please be patient until this happens. In the meantime if you'd like to confirm the builds are passing, you have the option of opening a PR on your own fork, just make sure your fork's master branch is up to date!

@FrederickCampbell

Copy link
Copy Markdown
Author

Thanks, updated the PR body to follow the provided template and added the AI usage disclosure from the contributing guidelines.

@JordanTheToaster JordanTheToaster requested a review from F0bes June 12, 2026 16:00
@mirh

mirh commented Jun 16, 2026

Copy link
Copy Markdown

@Kupo91 @TheKrzysiek @Pandavenom @superostrich at long last #6826 is delivered

@FrederickCampbell

Copy link
Copy Markdown
Author

What are we thinking?

@Pandavenom

Copy link
Copy Markdown

What or who are we waiting for? :)

};
static_assert(sizeof(TextureName) == 32, "ReplacementTextureName is expected size");

struct TextureAliasName // 24 bytes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you name this "TextureAliasName"?

@FrederickCampbell FrederickCampbell Jun 26, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s basically the wildcard version of TextureName. It keeps all the parts used for matching, except TEX0Hash, since $ is replacing that part.

I called it an “alias” because one replacement file can cover multiple full texture names, but thinking about it, WildcardTextureName is probably clearer and matches the existing TextureName wording better.

@JordanTheToaster JordanTheToaster added this to the Release 2.X milestone Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants