107 lines
3.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using UnityEngine;
namespace X.Rendering.Feature
{
public static class RenderingPlugin
{
#if (PLATFORM_IOS || PLATFORM_TVOS || PLATFORM_BRATWURST ) && !UNITY_EDITOR
[DllImport("__Internal")]
#else
[DllImport("GfxPluginNativeRender")]
#endif
public static extern IntPtr GetRenderEventAndDataFunc();
#if (PLATFORM_IOS || PLATFORM_TVOS || PLATFORM_BRATWURST ) && !UNITY_EDITOR
[DllImport("__Internal")]
#else
[DllImport("GfxPluginNativeRender")]
#endif
private static extern bool GetFeatureSupport(int feature);
#if (PLATFORM_IOS || PLATFORM_TVOS || PLATFORM_BRATWURST ) && !UNITY_EDITOR
[DllImport("__Internal")]
#else
[DllImport("GfxPluginNativeRender")]
#endif
public static extern bool GetInputResolution(int outw, int outh, int quality, ref int width, ref int height);
//#if (PLATFORM_IOS || PLATFORM_TVOS || PLATFORM_BRATWURST ) && !UNITY_EDITOR
// [DllImport("__Internal")]
//#else
// [DllImport("GfxPluginNativeRender")]
//#endif
// public static extern bool DoFGExtrapolation(IntPtr src, IntPtr data, IntPtr dst);
public enum NativeRenderingEvent
{
EnableVRS = 1,
DisableVRS,
EnableFGExtrapolation,
PreFGExtrapolation,
DoFGExtrapolation,
PostFGExtrapolation,
DisableFGExtrapolation,
SpatialUpScale,
EnableXESS1,
DoXESS1,
UpdateXESS1Config,
DisableXESS1,
};
public enum VRSPluginShadingRate
{
X1_PER_PIXEL,
X1_PER_2X1_PIXELS,
X1_PER_1X2_PIXELS,
X1_PER_2X2_PIXELS,
X1_PER_4X2_PIXELS,
X1_PER_2X4_PIXELS,
X1_PER_4X4_PIXELS,
};
public enum GraphicsFeature
{
VRS_DRAW = 0,
VRS_PRIMITIVE,
VRS_ATTACHMENT,
HW_SPATIAL_SR,
METAL_VRR,
HW_AISR,
HW_ADAPTIVE_VRS,
HW_FG_INTERPOLATE,
HW_FG_EXTRAPOLATION,
METAL_FX_SPATIAL_SR,
METAL_FX_TEMPORAL_SR,
VIVO_TEMPORAL_SR,
QCOM_AFME,
XESS13,
MAX_CNT
};
static Dictionary<GraphicsFeature, bool> featureSupports = null;
public static void InitSupportFeatures()
{
featureSupports = new();
UnityEngine.Debug.Log(SystemInfo.graphicsDeviceType);
for (int i = 0; i < (int)GraphicsFeature.MAX_CNT; ++i)
{
featureSupports[(GraphicsFeature)i] = GetFeatureSupport(i);
UnityEngine.Debug.Log($"feature->{(GraphicsFeature)i}:{featureSupports[(GraphicsFeature)i]}");
}
}
public static bool GetFeatureSupport(GraphicsFeature feature)
{
if (featureSupports != null)
{
return featureSupports[feature];
}
return GetFeatureSupport((int)feature);
}
}
}