diff --git a/NativeRenderPlugin/RenderAPI_Metal.mm b/NativeRenderPlugin/RenderAPI_Metal.mm index 170e070..a568a65 100644 --- a/NativeRenderPlugin/RenderAPI_Metal.mm +++ b/NativeRenderPlugin/RenderAPI_Metal.mm @@ -30,6 +30,7 @@ public: virtual void spatialUpScale(void*data); private: id mfx_spatial_scaler; + id commandQueue; IUnityGraphicsMetal* metal_graphics; }; @@ -97,19 +98,20 @@ void RenderAPI_Metal::spatialUpScale(void* data) desc.colorProcessingMode = MTLFXSpatialScalerColorProcessingModeLinear; mfx_spatial_scaler = [desc newSpatialScalerWithDevice:_device]; - if (mfx_spatial_scaler == nil) - { - return; - } + commandQueue = [_device newCommandQueue]; } + + if (mfx_spatial_scaler == nil || commandQueue == nil) + { + return; + } + mfx_spatial_scaler.colorTexture = srctex; mfx_spatial_scaler.outputTexture = dsttex; // if(!cmd) { - id _commandQueue = [_device newCommandQueue]; - id upscaleCommandBuffer = [_commandQueue commandBuffer]; + id upscaleCommandBuffer = [commandQueue commandBuffer]; upscaleCommandBuffer.label = @"Upscale Command Buffer"; - [mfx_spatial_scaler encodeToCommandBuffer:upscaleCommandBuffer]; [upscaleCommandBuffer commit]; }