Set MTL::TextureUsageShaderRead during capture

To be consistent with replay created textures set MTL::TextureUsageShaderRead on textures created during capture. This override is not serialized.

PR Feedback
This commit is contained in:
Jake Turner
2022-08-21 12:40:54 +01:00
committed by Baldur Karlsson
parent ce51361c83
commit 08d07ddc0d
+6
View File
@@ -652,6 +652,12 @@ WrappedMTLTexture *WrappedMTLDevice::Common_NewTexture(RDMTL::TextureDescriptor
{
MTL::Texture *realMTLTexture;
MTL::TextureDescriptor *realDescriptor(descriptor);
// Ensure the created textures can be read by a shader
// Metal driver will treat TextureUsageUnknown as all options
MTL::TextureUsage usage = realDescriptor->usage();
if(usage != MTL::TextureUsageUnknown)
realDescriptor->setUsage((MTL::TextureUsage)(usage | MTL::TextureUsageShaderRead));
SERIALISE_TIME_CALL(realMTLTexture = !ioSurfaceTexture ? Unwrap(this)->newTexture(realDescriptor)
: Unwrap(this)->newTexture(
realDescriptor, iosurface, plane));