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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion MoltenVK/MoltenVK/GPUObjects/MVKImage.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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.

mtlTex = [baseTexture retain];
else
mtlTex = [baseTexture newTextureViewWithPixelFormat: mtlPixFmt]; // retained
_mtlTextureViews[mtlPixFmt] = mtlTex;
}
}
Expand Down
Loading