Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

D3D9: Handle binding mismatching texture types #4513

Merged
merged 2 commits into from
Dec 17, 2024

Conversation

K0bin
Copy link
Collaborator

@K0bin K0bin commented Dec 8, 2024

Fixes #4387

Alpha Protocol binds a cube texture to a slot which is declared as a 2d texture in the shader. Binding a mismatching texture type leads yields (0,0,0,0) (yes, alpha 0, unlike binding NULL) on native D3D9. See the table inside the issue.

I also checked that this is checked at draw time, not at the time of the SetTexture call. So binding a shader with a correct texture type afterwards results in correct rendering and the other way around as well.

Because if there's one thing the D3D9 frontend needed, it is more bit field tracking... :)

@K0bin K0bin added the d3d9 label Dec 8, 2024
@K0bin K0bin changed the title D3d9: Handle binding mismatching textures D3D9: Handle binding mismatching textures Dec 8, 2024
@K0bin K0bin changed the title D3D9: Handle binding mismatching textures D3D9: Handle binding mismatching texture types Dec 8, 2024
@K0bin
Copy link
Collaborator Author

K0bin commented Dec 8, 2024

Fun game bug in Alpha Protocol:

warn: Mismatching view type. Slot: 2. Expected: VK_IMAGE_VIEW_TYPE_2D. Got: VK_IMAGE_VIEW_TYPE_CUBE
warn: Mismatching view type. Slot: 2. Expected: VK_IMAGE_VIEW_TYPE_CUBE. Got: VK_IMAGE_VIEW_TYPE_2D

@K0bin K0bin force-pushed the d3d9-texture-type-mismatch branch 3 times, most recently from 0d8fae0 to e664f96 Compare December 9, 2024 22:41
@K0bin K0bin marked this pull request as ready for review December 10, 2024 10:58
@K0bin
Copy link
Collaborator Author

K0bin commented Dec 10, 2024

I also tried it with Star Wars Force Unleashed 2 with forceSamplerTypeSpecConst disabled and didn't see any issues. But at the same time I don't remember how difficult it was to hit the bug that made me enable that option for the game in the first place so idk, I think I'll just keep the option for it for now.

@K0bin K0bin force-pushed the d3d9-texture-type-mismatch branch from e664f96 to c5b2384 Compare December 10, 2024 20:49
@Blisto91
Copy link
Contributor

Tested a few games without issue

@K0bin K0bin force-pushed the d3d9-texture-type-mismatch branch from c5b2384 to 313a399 Compare December 12, 2024 22:43
src/d3d9/d3d9_device.cpp Outdated Show resolved Hide resolved
src/d3d9/d3d9_shader.h Outdated Show resolved Hide resolved
Copy link
Owner

@doitsujin doitsujin left a comment

Choose a reason for hiding this comment

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

nits

@K0bin K0bin force-pushed the d3d9-texture-type-mismatch branch from 313a399 to 7ae2304 Compare December 17, 2024 13:36
@K0bin K0bin force-pushed the d3d9-texture-type-mismatch branch from 7ae2304 to 98e74eb Compare December 17, 2024 13:39
@K0bin
Copy link
Collaborator Author

K0bin commented Dec 17, 2024

Done.

@doitsujin doitsujin merged commit acf93aa into doitsujin:master Dec 17, 2024
3 checks passed
@K0bin K0bin deleted the d3d9-texture-type-mismatch branch December 17, 2024 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[d3d9][regression?] Alpha Protocol weird reflections
4 participants