From c2e1fd61978124609a0d7920d732c3efab293143 Mon Sep 17 00:00:00 2001 From: connan Date: Wed, 18 Dec 2024 14:27:45 +0800 Subject: [PATCH] vrr --- NativeRenderPlugin/RenderAPI_Metal.mm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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]; }