This commit is contained in:
connan 2024-12-18 14:27:45 +08:00
parent af699b5c7e
commit c2e1fd6197

View File

@ -30,6 +30,7 @@ public:
virtual void spatialUpScale(void*data); virtual void spatialUpScale(void*data);
private: private:
id <MTLFXSpatialScaler> mfx_spatial_scaler; id <MTLFXSpatialScaler> mfx_spatial_scaler;
id <MTLCommandQueue> commandQueue;
IUnityGraphicsMetal* metal_graphics; IUnityGraphicsMetal* metal_graphics;
}; };
@ -97,19 +98,20 @@ void RenderAPI_Metal::spatialUpScale(void* data)
desc.colorProcessingMode = MTLFXSpatialScalerColorProcessingModeLinear; desc.colorProcessingMode = MTLFXSpatialScalerColorProcessingModeLinear;
mfx_spatial_scaler = [desc newSpatialScalerWithDevice:_device]; mfx_spatial_scaler = [desc newSpatialScalerWithDevice:_device];
if (mfx_spatial_scaler == nil) commandQueue = [_device newCommandQueue];
{
return;
}
} }
if (mfx_spatial_scaler == nil || commandQueue == nil)
{
return;
}
mfx_spatial_scaler.colorTexture = srctex; mfx_spatial_scaler.colorTexture = srctex;
mfx_spatial_scaler.outputTexture = dsttex; mfx_spatial_scaler.outputTexture = dsttex;
// if(!cmd) // if(!cmd)
{ {
id <MTLCommandQueue> _commandQueue = [_device newCommandQueue]; id <MTLCommandBuffer> upscaleCommandBuffer = [commandQueue commandBuffer];
id <MTLCommandBuffer> upscaleCommandBuffer = [_commandQueue commandBuffer];
upscaleCommandBuffer.label = @"Upscale Command Buffer"; upscaleCommandBuffer.label = @"Upscale Command Buffer";
[mfx_spatial_scaler encodeToCommandBuffer:upscaleCommandBuffer]; [mfx_spatial_scaler encodeToCommandBuffer:upscaleCommandBuffer];
[upscaleCommandBuffer commit]; [upscaleCommandBuffer commit];
} }