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

Don't make texture views where not necessary #2061

Closed
wants to merge 1 commit into from

Conversation

etang-cw
Copy link
Contributor

@etang-cw etang-cw commented Nov 7, 2023

This is mainly to work around a bug in macOS Sonoma where Radeon Pro 580Xs read black if you attempt to sample a D24S8 texture through a texture view that was previously copied from (so texture goes from copy source → shader read with texture view) [FB13342692]

But less texture views also makes things easier to track in the Xcode shader debugger, so might as well apply it always

Not necessary, just use the source texture directly
Copy link
Contributor

@billhollings billhollings left a comment

Choose a reason for hiding this comment

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

Thanks very much for catching this, and suggesting an improvement.

This is a bit odd though. Under what conditions does [baseTexture pixelFormat] == mtlPixFmt work, but the check, a couple of lines above, here doesn't?

if (mtlPixFmt == _mtlPixFmt) { return _image->getMTLTexture(_planeIndex); }

Also a couple of nits about with formatting.

@@ -91,7 +91,10 @@
lock_guard<mutex> lock(_image->_lock);
mtlTex = _mtlTextureViews[mtlPixFmt];
if ( !mtlTex ) {
mtlTex = [baseTexture newTextureViewWithPixelFormat: mtlPixFmt]; // retained
if ([baseTexture pixelFormat] == mtlPixFmt)
Copy link
Contributor

Choose a reason for hiding this comment

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

MoltenVK convention is to use Obj-C property . syntax where possible, and avoid hanging if-statements. Please use baseTexture.pixelFormat, and wrap the if & else content statements in {} (and with the braces on the same line as the if & else where possible). See elsewhere for examples.

@etang-cw
Copy link
Contributor Author

etang-cw commented Nov 9, 2023

Looks like the issue was actually "fixed" by an update to the game that happened while I was testing and slightly changed how the game renders, hiding the issue. The actual reason for the texture view was that it needed a R001 swizzle, so we'll have to wait for Apple to fix the bug.

@etang-cw etang-cw closed this Nov 9, 2023
@etang-cw etang-cw deleted the LessViews branch November 9, 2023 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants