补充漏提交
This commit is contained in:
parent
fbe97cb69e
commit
17d8701725
@ -13,7 +13,8 @@ enum GraphicsFeature
|
||||
VRS_ATTACHMENT,
|
||||
HW_SPATIAL_SR,
|
||||
METAL_VRR,
|
||||
HW_AISR,
|
||||
HW_AI_SPATIAL_SR,
|
||||
HW_AI_TEMPORAL_SR,
|
||||
HW_ADAPTIVE_VRS,
|
||||
HW_FG_INTERPOLATE,
|
||||
HW_FG_EXTRAPOLATION,
|
||||
@ -90,6 +91,8 @@ public:
|
||||
|
||||
virtual void spatialUpScale(void* data) {}
|
||||
|
||||
virtual void temporalScale(void* data) {}
|
||||
|
||||
virtual bool getFeatureSupport(GraphicsFeature feature);
|
||||
|
||||
virtual void SetVKPSOHook(bool enable) {}
|
||||
|
||||
@ -29,11 +29,15 @@ public:
|
||||
|
||||
virtual void spatialUpScale(void*data) override;
|
||||
|
||||
virtual void temporalScale(void*data) override;
|
||||
|
||||
virtual void enableVRS(void* data) override;
|
||||
virtual void disableVRS() override;
|
||||
|
||||
private:
|
||||
id <MTLFXSpatialScaler> mfx_spatial_scaler;
|
||||
id <MTLFXTemporalScaler> mfx_temporal_scaler;
|
||||
bool first_frame_temporal;
|
||||
id <MTLCommandQueue> commandQueue;
|
||||
id <MTLTexture> outTexture;
|
||||
IUnityGraphicsMetal* metal_graphics;
|
||||
@ -78,7 +82,7 @@ void RenderAPI_Metal::initSupportFeature()
|
||||
|
||||
void RenderAPI_Metal::spatialUpScale(void* data)
|
||||
{
|
||||
// if (@available(iOS 16, macOS 13, *))
|
||||
if (@available(iOS 16, macOS 13, *))
|
||||
{
|
||||
struct DataPack
|
||||
{
|
||||
@ -161,6 +165,79 @@ void RenderAPI_Metal::spatialUpScale(void* data)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void RenderAPI_Metal::temporalScale(void* data)
|
||||
{
|
||||
if (@available(iOS 16, macOS 13, *))
|
||||
{
|
||||
struct DataPack
|
||||
{
|
||||
void* src;
|
||||
void* dst;
|
||||
void* depth;
|
||||
void* motion;
|
||||
float jitter_x;
|
||||
float jitter_y;
|
||||
};
|
||||
DataPack* data_pack = static_cast<DataPack*>(data);
|
||||
|
||||
id<MTLTexture> srctex = (__bridge id<MTLTexture>)data_pack->src;
|
||||
id<MTLTexture> dsttex = (__bridge id<MTLTexture>)data_pack->dst;
|
||||
id<MTLTexture> depthtex = (__bridge id<MTLTexture>)data_pack->src;
|
||||
id<MTLTexture> motiontex = (__bridge id<MTLTexture>)data_pack->motion;
|
||||
|
||||
id<MTLDevice> device = metal_graphics->MetalDevice();
|
||||
id<MTLCommandBuffer> cmd = (id<MTLCommandBuffer>)metal_graphics->CurrentCommandBuffer();
|
||||
cmd.label = @"Upscale Command Buffer";
|
||||
if(mfx_temporal_scaler == null)
|
||||
{
|
||||
MTLFXTemporalScalerDescriptor* desc = [[MTLFXTemporalScalerDescriptor alloc]init];
|
||||
desc.inputWidth = [srctex width];
|
||||
desc.inputHeight = [srctex height];
|
||||
desc.outputWidth = [dsttex width];
|
||||
desc.outputHeight = [dsttex height];
|
||||
desc.colorTextureFormat = [srctex pixelFormat];
|
||||
desc.outputTextureFormat = [dsttex pixelFormat];
|
||||
desc.depthTextureFormat = [depthtex pixelFormat];
|
||||
desc.motionTextureFormat = [motiontex pixelFormat];
|
||||
|
||||
mfx_temporal_scaler = [desc newTemporalScalerWithDevice:device];
|
||||
if(commandQueue == null)
|
||||
{
|
||||
commandQueue = [device newCommandQueue];
|
||||
}
|
||||
|
||||
mfx_temporal_scaler.motionVectorScaleX = desc.inputWidth;
|
||||
mfx_temporal_scaler.motionVectorScaleY = desc.inputHeight;
|
||||
first_frame_temporal = true;
|
||||
}
|
||||
|
||||
if (mfx_temporal_scaler == nil || commandQueue == nil)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(!(srctex && dsttex))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mfx_temporal_scaler.reset = first_frame_temporal;
|
||||
mfx_temporal_scaler.colorTexture = srctex;
|
||||
mfx_temporal_scaler.depthTexture = depthtex;
|
||||
mfx_temporal_scaler.motionTexture = motiontex;
|
||||
mfx_temporal_scaler.outputTexture = dsttex;
|
||||
mfx_temporal_scaler.isDepthReversed = false;
|
||||
mfx_temporal_scaler.jitterOffsetX = data_pack->jitter_x;
|
||||
mfx_temporal_scaler.jitterOffsetY = data_pack->jitter_y;
|
||||
|
||||
first_frame_temporal = false;
|
||||
|
||||
[mfx_temporal_scaler encodeToCommandBuffer:cmd];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void RenderAPI_Metal::enableVRS(void* data)
|
||||
{
|
||||
struct DataPack
|
||||
|
||||
@ -210,7 +210,7 @@ void RenderAPI_OpenGLCoreES::initSupportFeature()
|
||||
|
||||
if (strstr(extensions, XEG_NEURAL_UPSCALE_EXTENSION_NAME))
|
||||
{
|
||||
support_features[GraphicsFeature::HW_AISR] = true;
|
||||
support_features[GraphicsFeature::HW_AI_SPATIAL_SR] = true;
|
||||
}
|
||||
|
||||
if (strstr(extensions, XEG_ADAPTIVE_VRS_EXTENSION_NAME))
|
||||
|
||||
@ -578,6 +578,13 @@ void checkXEngine(VkPhysicalDevice physic_device, SupportFeatureList &fl)
|
||||
{
|
||||
fl[GraphicsFeature::HW_ADAPTIVE_VRS] = true;
|
||||
}
|
||||
|
||||
// 查询是否支持时域AI超分
|
||||
if (std::find(supported_extensions.begin(), supported_extensions.end(), XEG_TEMPORAL_UPSCALE_EXTENSION_NAME) ==
|
||||
supported_extensions.end())
|
||||
{
|
||||
fl[GraphicsFeature::HW_AI_TEMPORAL_SR] = true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@ -107,6 +107,7 @@ enum NativeRenderingEvent
|
||||
PostFGExtrapolation,
|
||||
DisableFGExtrapolation,
|
||||
SpatialUpScale,
|
||||
TemporalScale
|
||||
};
|
||||
|
||||
static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void *data)
|
||||
@ -149,6 +150,11 @@ static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void *data)
|
||||
s_current_api->spatialUpScale(data);
|
||||
break;
|
||||
}
|
||||
case NativeRenderingEvent::TemporalScale:
|
||||
{
|
||||
s_current_api->temporalScale(data);
|
||||
break;
|
||||
}
|
||||
case NativeRenderingEvent::DoFGExtrapolation:
|
||||
{
|
||||
AFMEParam *param = (AFMEParam *)data;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user