Skip to content

Conversation

@xtfo
Copy link
Contributor

@xtfo xtfo commented Nov 6, 2025

Commit 0b87f53 added a conditional check on the shared texture handle, preventing memory capture in D3D9.

D3D10 and D3D11 use a capture struct with a union whose variants overlap in memory, so the check still accessed the union member, which worked in practice but is undefined behavior.

Fix the capture detection for D3D9 memory capture, and update the D3D10/D3D11 checks to evaluate only the active union variant to remove the undefined behavior.

Description

Motivation and Context

Fix D3D9 memory capture.
Fix C++ UB.

How Has This Been Tested?

Tested D3D9, D3D10 and D3D11 game capture with both memory and shared texture capture.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

Commit 0b87f53 added a conditional check on the shared texture handle,
preventing memory capture in D3D9.

D3D10 and D3D11 use a capture struct with a union whose variants
overlap in memory, so the check still accessed the union member,
which worked in practice but is undefined behavior.

Fix the capture detection for D3D9 memory capture, and update the
D3D10/D3D11 checks to evaluate only the active union variant to
remove the undefined behavior.
@Fenrirthviti
Copy link
Member

Can you provide an example application that this affected to test against?

@xtfo
Copy link
Contributor Author

xtfo commented Nov 6, 2025

Anything that uses D3D9. I tested with Portal. Just remember to disable MSAA, memory capture is not compatible with it. That was something I noticed while fixing this, and I may fix that in a future PR.

@WizardCM WizardCM added Bug Fix Non-breaking change which fixes an issue Windows Affects Windows labels Nov 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Fix Non-breaking change which fixes an issue Windows Affects Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants