[hgiMetal] Runtime test for fragment discard return
authordavidgyu <davidgyu@users.noreply.github.com>
Sat, 3 Feb 2024 04:03:48 +0000 (20:03 -0800)
committerpixar-oss <pixar-oss@users.noreply.github.com>
Mon, 5 Feb 2024 20:21:06 +0000 (12:21 -0800)
commitbdadc172cac2488c6d33cd301d922ccb101e3f85
treeff70ef74f75b6b4f3202697af0ac54c1293e207d
parent81ed2de35b611a764835ef39e80dea275c9938a5
[hgiMetal] Runtime test for fragment discard return

A previous fix made sure to return from the fragment shader main
function after executing discard_fragment() in order to avoid
undesired side effects from buffer writes, e.g. when collecting
translucent fragments for Order Independent Translucent (OIT)
rendering.

This introduces a runtime check to disable this early return on
systems where it can cause other problems with performance or
functionality.

This follows the pattern used directly in the lines above
to detect and implement a similar sort of workaround for
AMD Vega GPU devices. Ideally, we'd check for something
like MTLGPUFamilyApple9 feature support or inspect the device
architecture name, but we also want to maintain build
compatibility with earlier versions of Xcode and the macOS SDK.

(Internal change: 2314233)
pxr/imaging/hgiMetal/capabilities.h
pxr/imaging/hgiMetal/capabilities.mm
pxr/imaging/hgiMetal/shaderFunction.mm
pxr/imaging/hgiMetal/shaderGenerator.h
pxr/imaging/hgiMetal/shaderGenerator.mm