This commit is contained in:
StarBeats 2024-12-11 17:42:08 +08:00
parent cfce0a877c
commit 46d283d0b6
22 changed files with 770 additions and 2277 deletions

View File

@ -38,7 +38,7 @@ MonoBehaviour:
m_MainLightRenderingMode: 1 m_MainLightRenderingMode: 1
m_MainLightShadowsSupported: 1 m_MainLightShadowsSupported: 1
m_MainLightShadowmapResolution: 1024 m_MainLightShadowmapResolution: 1024
m_AdditionalLightsRenderingMode: 1 m_AdditionalLightsRenderingMode: 2
m_AdditionalLightsPerObjectLimit: 4 m_AdditionalLightsPerObjectLimit: 4
m_AdditionalLightShadowsSupported: 0 m_AdditionalLightShadowsSupported: 0
m_AdditionalLightsShadowmapResolution: 2048 m_AdditionalLightsShadowmapResolution: 2048
@ -116,4 +116,4 @@ MonoBehaviour:
m_ShadowCascades: 0 m_ShadowCascades: 0
superResolution: 0 superResolution: 0
sSRenderScale: 0 sSRenderScale: 0
vrsRate: 0 vrsRate: 3

View File

@ -181,10 +181,10 @@ MonoBehaviour:
m_OverrideState: 0 m_OverrideState: 0
m_Value: 3 m_Value: 3
hueShiftAmount: hueShiftAmount:
m_OverrideState: 0 m_OverrideState: 1
m_Value: 0 m_Value: 0
detectPaperWhite: detectPaperWhite:
m_OverrideState: 0 m_OverrideState: 1
m_Value: 0 m_Value: 0
paperWhite: paperWhite:
m_OverrideState: 0 m_OverrideState: 0

View File

@ -1,31 +1,31 @@
[ [
{ {
"directory": "G:\\TJURP\\NativeRenderPlugin", "directory": "G:\\TJURP\\NativeRenderPlugin",
"arguments": ["C:\\Users\\xinyt\\AppData\\Local\\OpenHarmony\\Sdk\\12\\native\\llvm\\bin\\clang.exe", "-c", "-Qunused-arguments", "-D__MUSL__", "--target=aarch64-linux-ohos", "--sysroot=C:/Users/xinyt/AppData/Local/OpenHarmony/Sdk/12/native/sysroot", "-fPIC", "-std=c++20", "-Igl3w", "-IUnity", "-DSUPPORT_VULKAN=1", "-DSUPPORT_OPENGL_UNIFIED=1", "-DSUPPORT_OPENGL_ES=1", "-DOHOS=1", "-IC:\\Program Files\\Huawei\\DevEco Studio\\sdk\\default\\hms\\native\\sysroot\\usr\\include", "-DMYCLANG", "-DOHOS_STL=c++_shared", "-o", "build\\.objs\\GfxPluginNativeRender\\harmonyos\\aarch64\\debug\\RenderAPI.cpp.o", "RenderAPI.cpp"], "arguments": ["C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX64\\x64\\cl.exe", "/c", "/nologo", "/std:c++20", "/Igl3w", "/IUnity", "/IC:\\VulkanSDK\\1.3.283.0\\Include", "/DNOMINMAX", "/DSUPPORT_D3D11=1", "/DSUPPORT_D3D12=1", "/DSUPPORT_VULKAN=1", "/EHsc", "/Fobuild\\.objs\\GfxPluginNativeRender\\windows\\x64\\release\\RenderAPI.cpp.obj", "RenderAPI.cpp"],
"file": "RenderAPI.cpp" "file": "RenderAPI.cpp"
}, },
{ {
"directory": "G:\\TJURP\\NativeRenderPlugin", "directory": "G:\\TJURP\\NativeRenderPlugin",
"arguments": ["C:\\Users\\xinyt\\AppData\\Local\\OpenHarmony\\Sdk\\12\\native\\llvm\\bin\\clang.exe", "-c", "-Qunused-arguments", "-D__MUSL__", "--target=aarch64-linux-ohos", "--sysroot=C:/Users/xinyt/AppData/Local/OpenHarmony/Sdk/12/native/sysroot", "-fPIC", "-std=c++20", "-Igl3w", "-IUnity", "-DSUPPORT_VULKAN=1", "-DSUPPORT_OPENGL_UNIFIED=1", "-DSUPPORT_OPENGL_ES=1", "-DOHOS=1", "-IC:\\Program Files\\Huawei\\DevEco Studio\\sdk\\default\\hms\\native\\sysroot\\usr\\include", "-DMYCLANG", "-DOHOS_STL=c++_shared", "-o", "build\\.objs\\GfxPluginNativeRender\\harmonyos\\aarch64\\debug\\RenderAPI_D3D11.cpp.o", "RenderAPI_D3D11.cpp"], "arguments": ["C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX64\\x64\\cl.exe", "/c", "/nologo", "/std:c++20", "/Igl3w", "/IUnity", "/IC:\\VulkanSDK\\1.3.283.0\\Include", "/DNOMINMAX", "/DSUPPORT_D3D11=1", "/DSUPPORT_D3D12=1", "/DSUPPORT_VULKAN=1", "/EHsc", "/Fobuild\\.objs\\GfxPluginNativeRender\\windows\\x64\\release\\RenderAPI_D3D11.cpp.obj", "RenderAPI_D3D11.cpp"],
"file": "RenderAPI_D3D11.cpp" "file": "RenderAPI_D3D11.cpp"
}, },
{ {
"directory": "G:\\TJURP\\NativeRenderPlugin", "directory": "G:\\TJURP\\NativeRenderPlugin",
"arguments": ["C:\\Users\\xinyt\\AppData\\Local\\OpenHarmony\\Sdk\\12\\native\\llvm\\bin\\clang.exe", "-c", "-Qunused-arguments", "-D__MUSL__", "--target=aarch64-linux-ohos", "--sysroot=C:/Users/xinyt/AppData/Local/OpenHarmony/Sdk/12/native/sysroot", "-fPIC", "-std=c++20", "-Igl3w", "-IUnity", "-DSUPPORT_VULKAN=1", "-DSUPPORT_OPENGL_UNIFIED=1", "-DSUPPORT_OPENGL_ES=1", "-DOHOS=1", "-IC:\\Program Files\\Huawei\\DevEco Studio\\sdk\\default\\hms\\native\\sysroot\\usr\\include", "-DMYCLANG", "-DOHOS_STL=c++_shared", "-o", "build\\.objs\\GfxPluginNativeRender\\harmonyos\\aarch64\\debug\\RenderAPI_D3D12.cpp.o", "RenderAPI_D3D12.cpp"], "arguments": ["C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX64\\x64\\cl.exe", "/c", "/nologo", "/std:c++20", "/Igl3w", "/IUnity", "/IC:\\VulkanSDK\\1.3.283.0\\Include", "/DNOMINMAX", "/DSUPPORT_D3D11=1", "/DSUPPORT_D3D12=1", "/DSUPPORT_VULKAN=1", "/EHsc", "/Fobuild\\.objs\\GfxPluginNativeRender\\windows\\x64\\release\\RenderAPI_D3D12.cpp.obj", "RenderAPI_D3D12.cpp"],
"file": "RenderAPI_D3D12.cpp" "file": "RenderAPI_D3D12.cpp"
}, },
{ {
"directory": "G:\\TJURP\\NativeRenderPlugin", "directory": "G:\\TJURP\\NativeRenderPlugin",
"arguments": ["C:\\Users\\xinyt\\AppData\\Local\\OpenHarmony\\Sdk\\12\\native\\llvm\\bin\\clang.exe", "-c", "-Qunused-arguments", "-D__MUSL__", "--target=aarch64-linux-ohos", "--sysroot=C:/Users/xinyt/AppData/Local/OpenHarmony/Sdk/12/native/sysroot", "-fPIC", "-std=c++20", "-Igl3w", "-IUnity", "-DSUPPORT_VULKAN=1", "-DSUPPORT_OPENGL_UNIFIED=1", "-DSUPPORT_OPENGL_ES=1", "-DOHOS=1", "-IC:\\Program Files\\Huawei\\DevEco Studio\\sdk\\default\\hms\\native\\sysroot\\usr\\include", "-DMYCLANG", "-DOHOS_STL=c++_shared", "-o", "build\\.objs\\GfxPluginNativeRender\\harmonyos\\aarch64\\debug\\RenderAPI_OpenGLCoreES.cpp.o", "RenderAPI_OpenGLCoreES.cpp"], "arguments": ["C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX64\\x64\\cl.exe", "/c", "/nologo", "/std:c++20", "/Igl3w", "/IUnity", "/IC:\\VulkanSDK\\1.3.283.0\\Include", "/DNOMINMAX", "/DSUPPORT_D3D11=1", "/DSUPPORT_D3D12=1", "/DSUPPORT_VULKAN=1", "/EHsc", "/Fobuild\\.objs\\GfxPluginNativeRender\\windows\\x64\\release\\RenderAPI_OpenGLCoreES.cpp.obj", "RenderAPI_OpenGLCoreES.cpp"],
"file": "RenderAPI_OpenGLCoreES.cpp" "file": "RenderAPI_OpenGLCoreES.cpp"
}, },
{ {
"directory": "G:\\TJURP\\NativeRenderPlugin", "directory": "G:\\TJURP\\NativeRenderPlugin",
"arguments": ["C:\\Users\\xinyt\\AppData\\Local\\OpenHarmony\\Sdk\\12\\native\\llvm\\bin\\clang.exe", "-c", "-Qunused-arguments", "-D__MUSL__", "--target=aarch64-linux-ohos", "--sysroot=C:/Users/xinyt/AppData/Local/OpenHarmony/Sdk/12/native/sysroot", "-fPIC", "-std=c++20", "-Igl3w", "-IUnity", "-DSUPPORT_VULKAN=1", "-DSUPPORT_OPENGL_UNIFIED=1", "-DSUPPORT_OPENGL_ES=1", "-DOHOS=1", "-IC:\\Program Files\\Huawei\\DevEco Studio\\sdk\\default\\hms\\native\\sysroot\\usr\\include", "-DMYCLANG", "-DOHOS_STL=c++_shared", "-o", "build\\.objs\\GfxPluginNativeRender\\harmonyos\\aarch64\\debug\\RenderAPI_Vulkan.cpp.o", "RenderAPI_Vulkan.cpp"], "arguments": ["C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX64\\x64\\cl.exe", "/c", "/nologo", "/std:c++20", "/Igl3w", "/IUnity", "/IC:\\VulkanSDK\\1.3.283.0\\Include", "/DNOMINMAX", "/DSUPPORT_D3D11=1", "/DSUPPORT_D3D12=1", "/DSUPPORT_VULKAN=1", "/EHsc", "/Fobuild\\.objs\\GfxPluginNativeRender\\windows\\x64\\release\\RenderAPI_Vulkan.cpp.obj", "RenderAPI_Vulkan.cpp"],
"file": "RenderAPI_Vulkan.cpp" "file": "RenderAPI_Vulkan.cpp"
}, },
{ {
"directory": "G:\\TJURP\\NativeRenderPlugin", "directory": "G:\\TJURP\\NativeRenderPlugin",
"arguments": ["C:\\Users\\xinyt\\AppData\\Local\\OpenHarmony\\Sdk\\12\\native\\llvm\\bin\\clang.exe", "-c", "-Qunused-arguments", "-D__MUSL__", "--target=aarch64-linux-ohos", "--sysroot=C:/Users/xinyt/AppData/Local/OpenHarmony/Sdk/12/native/sysroot", "-fPIC", "-std=c++20", "-Igl3w", "-IUnity", "-DSUPPORT_VULKAN=1", "-DSUPPORT_OPENGL_UNIFIED=1", "-DSUPPORT_OPENGL_ES=1", "-DOHOS=1", "-IC:\\Program Files\\Huawei\\DevEco Studio\\sdk\\default\\hms\\native\\sysroot\\usr\\include", "-DMYCLANG", "-DOHOS_STL=c++_shared", "-o", "build\\.objs\\GfxPluginNativeRender\\harmonyos\\aarch64\\debug\\RenderingPlugin.cpp.o", "RenderingPlugin.cpp"], "arguments": ["C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.41.34120\\bin\\HostX64\\x64\\cl.exe", "/c", "/nologo", "/std:c++20", "/Igl3w", "/IUnity", "/IC:\\VulkanSDK\\1.3.283.0\\Include", "/DNOMINMAX", "/DSUPPORT_D3D11=1", "/DSUPPORT_D3D12=1", "/DSUPPORT_VULKAN=1", "/EHsc", "/Fobuild\\.objs\\GfxPluginNativeRender\\windows\\x64\\release\\RenderingPlugin.cpp.obj", "RenderingPlugin.cpp"],
"file": "RenderingPlugin.cpp" "file": "RenderingPlugin.cpp"
}] }]

View File

@ -42,46 +42,46 @@
// Which graphics device APIs we possibly support? // Which graphics device APIs we possibly support?
#if UNITY_METRO // #if UNITY_METRO
#define SUPPORT_D3D11 1 // #define SUPPORT_D3D11 1
#if WINDOWS_UWP // #if WINDOWS_UWP
#define SUPPORT_D3D12 1 // #define SUPPORT_D3D12 1
#endif // #endif
#elif UNITY_WIN // #elif UNITY_WIN
#ifndef SUPPORT_VULKAN // // #ifndef SUPPORT_VULKAN
#define SUPPORT_D3D11 1 // comment this out if you don't have D3D11 header/library files // // #define SUPPORT_D3D11 1 // comment this out if you don't have D3D11 header/library files
#define SUPPORT_D3D12 0 // comment this out if you don't have D3D12 header/library files // // #define SUPPORT_D3D12 0 // comment this out if you don't have D3D12 header/library files
#define SUPPORT_OPENGL_UNIFIED 1 // // #define SUPPORT_OPENGL_UNIFIED 1
#define SUPPORT_OPENGL_CORE 1 // // #define SUPPORT_OPENGL_CORE 1
#define SUPPORT_VULKAN 0 // Requires Vulkan SDK to be installed // // #define SUPPORT_VULKAN 0 // Requires Vulkan SDK to be installed
#else // // #else
#define SUPPORT_D3D11 0 // comment this out if you don't have D3D11 header/library files // // #define SUPPORT_D3D11 0 // comment this out if you don't have D3D11 header/library files
#define SUPPORT_D3D12 0 // comment this out if you don't have D3D12 header/library files // // #define SUPPORT_D3D12 0 // comment this out if you don't have D3D12 header/library files
#endif // // #endif
#elif UNITY_IOS || UNITY_TVOS || UNITY_ANDROID || UNITY_WEBGL // #elif UNITY_IOS || UNITY_TVOS || UNITY_ANDROID || UNITY_WEBGL
#ifndef SUPPORT_OPENGL_UNIFIED // #ifndef SUPPORT_OPENGL_UNIFIED
#define SUPPORT_OPENGL_UNIFIED SUPPORT_OPENGL_ES // #define SUPPORT_OPENGL_UNIFIED SUPPORT_OPENGL_ES
#endif // #endif
#ifndef SUPPORT_VULKAN // #ifndef SUPPORT_VULKAN
#define SUPPORT_VULKAN 0 // #define SUPPORT_VULKAN 0
#endif // #endif
#elif UNITY_OSX || UNITY_LINUX // #elif UNITY_OSX || UNITY_LINUX
#define SUPPORT_OPENGL_UNIFIED 1 // #define SUPPORT_OPENGL_UNIFIED 1
#define SUPPORT_OPENGL_CORE 1 // #define SUPPORT_OPENGL_CORE 1
#elif UNITY_EMBEDDED_LINUX // #elif UNITY_EMBEDDED_LINUX
#define SUPPORT_OPENGL_UNIFIED 1 // #define SUPPORT_OPENGL_UNIFIED 1
#define SUPPORT_OPENGL_ES 1 // #define SUPPORT_OPENGL_ES 1
#ifndef SUPPORT_VULKAN // #ifndef SUPPORT_VULKAN
#define SUPPORT_VULKAN 0 // #define SUPPORT_VULKAN 0
#endif // #endif
#elif UNITY_QNX // #elif UNITY_QNX
#define SUPPORT_OPENGL_UNIFIED 1 // #define SUPPORT_OPENGL_UNIFIED 1
#define SUPPORT_OPENGL_ES 1 // #define SUPPORT_OPENGL_ES 1
#endif // #endif
#if UNITY_IOS || UNITY_TVOS || UNITY_OSX // #if UNITY_IOS || UNITY_TVOS || UNITY_OSX
#define SUPPORT_METAL 1 // #define SUPPORT_METAL 1
#endif // #endif

View File

@ -20,6 +20,7 @@ enum GraphicsFeature
METAL_FX_TEMPORAL_SR, METAL_FX_TEMPORAL_SR,
VIVO_TEMPORAL_SR, VIVO_TEMPORAL_SR,
QCOM_AFME, QCOM_AFME,
XESS13,
MAX_CNT MAX_CNT
}; };
@ -57,9 +58,6 @@ public:
// Reversed Z is used on modern platforms, and improves depth buffer precision. // Reversed Z is used on modern platforms, and improves depth buffer precision.
virtual bool getUsesReverseZ() = 0; virtual bool getUsesReverseZ() = 0;
// Returns the native resource pointer to either unity render buffer or
// to the resource created by the plugin (i.e ID3D12Resource* in case of DX12)
virtual void* getRenderTexture() { return nullptr; }
// Sets the underlying resource to unity RenderBuffer // Sets the underlying resource to unity RenderBuffer
// see https://docs.unity3d.com/ScriptReference/RenderBuffer.html // see https://docs.unity3d.com/ScriptReference/RenderBuffer.html

View File

@ -16,32 +16,13 @@ public:
RenderAPI_D3D11(); RenderAPI_D3D11();
virtual ~RenderAPI_D3D11() { } virtual ~RenderAPI_D3D11() { }
virtual void ProcessDeviceEvent(UnityGfxDeviceEventType type, IUnityInterfaces* interfaces); virtual void processDeviceEvent(UnityGfxDeviceEventType type, IUnityInterfaces* interfaces);
virtual bool GetUsesReverseZ() { return (int)m_Device->GetFeatureLevel() >= (int)D3D_FEATURE_LEVEL_10_0; } virtual bool getUsesReverseZ() { return (int)m_Device->GetFeatureLevel() >= (int)D3D_FEATURE_LEVEL_10_0; }
virtual void initSupportFeature() override;
virtual void DrawSimpleTriangles(const float worldMatrix[16], int triangleCount, const void* verticesFloat3Byte4);
virtual void* BeginModifyTexture(void* textureHandle, int textureWidth, int textureHeight, int* outRowPitch);
virtual void EndModifyTexture(void* textureHandle, int textureWidth, int textureHeight, int rowPitch, void* dataPtr);
virtual void* BeginModifyVertexBuffer(void* bufferHandle, size_t* outBufferSize);
virtual void EndModifyVertexBuffer(void* bufferHandle);
private:
void CreateResources();
void ReleaseResources();
private: private:
ID3D11Device* m_Device; ID3D11Device* m_Device;
ID3D11Buffer* m_VB; // vertex buffer
ID3D11Buffer* m_CB; // constant buffer
ID3D11VertexShader* m_VertexShader;
ID3D11PixelShader* m_PixelShader;
ID3D11InputLayout* m_InputLayout;
ID3D11RasterizerState* m_RasterState;
ID3D11BlendState* m_BlendState;
ID3D11DepthStencilState* m_DepthState;
}; };
@ -74,50 +55,15 @@ float4 PS(float4 color : COLOR) : SV_TARGET
// fxc /Tvs_4_0_level_9_3 /EVS source.hlsl /Fh outVS.h /Qstrip_reflect /Qstrip_debug /Qstrip_priv // fxc /Tvs_4_0_level_9_3 /EVS source.hlsl /Fh outVS.h /Qstrip_reflect /Qstrip_debug /Qstrip_priv
// fxc /Tps_4_0_level_9_3 /EPS source.hlsl /Fh outPS.h /Qstrip_reflect /Qstrip_debug /Qstrip_priv // fxc /Tps_4_0_level_9_3 /EPS source.hlsl /Fh outPS.h /Qstrip_reflect /Qstrip_debug /Qstrip_priv
// and results pasted & formatted to take less lines here // and results pasted & formatted to take less lines here
const BYTE kVertexShaderCode[] =
{
68,88,66,67,86,189,21,50,166,106,171,1,10,62,115,48,224,137,163,129,1,0,0,0,168,2,0,0,4,0,0,0,48,0,0,0,0,1,0,0,4,2,0,0,84,2,0,0,
65,111,110,57,200,0,0,0,200,0,0,0,0,2,254,255,148,0,0,0,52,0,0,0,1,0,36,0,0,0,48,0,0,0,48,0,0,0,36,0,1,0,48,0,0,0,0,0,
4,0,1,0,0,0,0,0,0,0,0,0,1,2,254,255,31,0,0,2,5,0,0,128,0,0,15,144,31,0,0,2,5,0,1,128,1,0,15,144,5,0,0,3,0,0,15,128,
0,0,85,144,2,0,228,160,4,0,0,4,0,0,15,128,1,0,228,160,0,0,0,144,0,0,228,128,4,0,0,4,0,0,15,128,3,0,228,160,0,0,170,144,0,0,228,128,
2,0,0,3,0,0,15,128,0,0,228,128,4,0,228,160,4,0,0,4,0,0,3,192,0,0,255,128,0,0,228,160,0,0,228,128,1,0,0,2,0,0,12,192,0,0,228,128,
1,0,0,2,0,0,15,224,1,0,228,144,255,255,0,0,83,72,68,82,252,0,0,0,64,0,1,0,63,0,0,0,89,0,0,4,70,142,32,0,0,0,0,0,4,0,0,0,
95,0,0,3,114,16,16,0,0,0,0,0,95,0,0,3,242,16,16,0,1,0,0,0,101,0,0,3,242,32,16,0,0,0,0,0,103,0,0,4,242,32,16,0,1,0,0,0,
1,0,0,0,104,0,0,2,1,0,0,0,54,0,0,5,242,32,16,0,0,0,0,0,70,30,16,0,1,0,0,0,56,0,0,8,242,0,16,0,0,0,0,0,86,21,16,0,
0,0,0,0,70,142,32,0,0,0,0,0,1,0,0,0,50,0,0,10,242,0,16,0,0,0,0,0,70,142,32,0,0,0,0,0,0,0,0,0,6,16,16,0,0,0,0,0,
70,14,16,0,0,0,0,0,50,0,0,10,242,0,16,0,0,0,0,0,70,142,32,0,0,0,0,0,2,0,0,0,166,26,16,0,0,0,0,0,70,14,16,0,0,0,0,0,
0,0,0,8,242,32,16,0,1,0,0,0,70,14,16,0,0,0,0,0,70,142,32,0,0,0,0,0,3,0,0,0,62,0,0,1,73,83,71,78,72,0,0,0,2,0,0,0,
8,0,0,0,56,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,7,7,0,0,65,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,1,0,0,0,
15,15,0,0,80,79,83,73,84,73,79,78,0,67,79,76,79,82,0,171,79,83,71,78,76,0,0,0,2,0,0,0,8,0,0,0,56,0,0,0,0,0,0,0,0,0,0,0,
3,0,0,0,0,0,0,0,15,0,0,0,62,0,0,0,0,0,0,0,1,0,0,0,3,0,0,0,1,0,0,0,15,0,0,0,67,79,76,79,82,0,83,86,95,80,111,115,
105,116,105,111,110,0,171,171
};
const BYTE kPixelShaderCode[]=
{
68,88,66,67,196,65,213,199,14,78,29,150,87,236,231,156,203,125,244,112,1,0,0,0,32,1,0,0,4,0,0,0,48,0,0,0,124,0,0,0,188,0,0,0,236,0,0,0,
65,111,110,57,68,0,0,0,68,0,0,0,0,2,255,255,32,0,0,0,36,0,0,0,0,0,36,0,0,0,36,0,0,0,36,0,0,0,36,0,0,0,36,0,1,2,255,255,
31,0,0,2,0,0,0,128,0,0,15,176,1,0,0,2,0,8,15,128,0,0,228,176,255,255,0,0,83,72,68,82,56,0,0,0,64,0,0,0,14,0,0,0,98,16,0,3,
242,16,16,0,0,0,0,0,101,0,0,3,242,32,16,0,0,0,0,0,54,0,0,5,242,32,16,0,0,0,0,0,70,30,16,0,0,0,0,0,62,0,0,1,73,83,71,78,
40,0,0,0,1,0,0,0,8,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,15,15,0,0,67,79,76,79,82,0,171,171,79,83,71,78,
44,0,0,0,1,0,0,0,8,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,15,0,0,0,83,86,95,84,65,82,71,69,84,0,171,171
};
RenderAPI_D3D11::RenderAPI_D3D11() RenderAPI_D3D11::RenderAPI_D3D11()
: m_Device(NULL) : m_Device(NULL)
, m_VB(NULL)
, m_CB(NULL)
, m_VertexShader(NULL)
, m_PixelShader(NULL)
, m_InputLayout(NULL)
, m_RasterState(NULL)
, m_BlendState(NULL)
, m_DepthState(NULL)
{ {
} }
void RenderAPI_D3D11::ProcessDeviceEvent(UnityGfxDeviceEventType type, IUnityInterfaces* interfaces) void RenderAPI_D3D11::processDeviceEvent(UnityGfxDeviceEventType type, IUnityInterfaces* interfaces)
{ {
switch (type) switch (type)
{ {
@ -125,175 +71,16 @@ void RenderAPI_D3D11::ProcessDeviceEvent(UnityGfxDeviceEventType type, IUnityInt
{ {
IUnityGraphicsD3D11* d3d = interfaces->Get<IUnityGraphicsD3D11>(); IUnityGraphicsD3D11* d3d = interfaces->Get<IUnityGraphicsD3D11>();
m_Device = d3d->GetDevice(); m_Device = d3d->GetDevice();
CreateResources();
break; break;
} }
case kUnityGfxDeviceEventShutdown: case kUnityGfxDeviceEventShutdown:
ReleaseResources();
break; break;
} }
} }
void RenderAPI_D3D11::initSupportFeature()
void RenderAPI_D3D11::CreateResources()
{ {
D3D11_BUFFER_DESC desc;
memset(&desc, 0, sizeof(desc));
// vertex buffer
desc.Usage = D3D11_USAGE_DEFAULT;
desc.ByteWidth = 1024;
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
m_Device->CreateBuffer(&desc, NULL, &m_VB);
// constant buffer
desc.Usage = D3D11_USAGE_DEFAULT;
desc.ByteWidth = 64; // hold 1 matrix
desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
desc.CPUAccessFlags = 0;
m_Device->CreateBuffer(&desc, NULL, &m_CB);
// shaders
HRESULT hr;
hr = m_Device->CreateVertexShader(kVertexShaderCode, sizeof(kVertexShaderCode), nullptr, &m_VertexShader);
if (FAILED(hr))
OutputDebugStringA("Failed to create vertex shader.\n");
hr = m_Device->CreatePixelShader(kPixelShaderCode, sizeof(kPixelShaderCode), nullptr, &m_PixelShader);
if (FAILED(hr))
OutputDebugStringA("Failed to create pixel shader.\n");
// input layout
if (m_VertexShader)
{
D3D11_INPUT_ELEMENT_DESC s_DX11InputElementDesc[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "COLOR", 0, DXGI_FORMAT_R8G8B8A8_UNORM, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};
m_Device->CreateInputLayout(s_DX11InputElementDesc, 2, kVertexShaderCode, sizeof(kVertexShaderCode), &m_InputLayout);
}
// render states
D3D11_RASTERIZER_DESC rsdesc;
memset(&rsdesc, 0, sizeof(rsdesc));
rsdesc.FillMode = D3D11_FILL_SOLID;
rsdesc.CullMode = D3D11_CULL_NONE;
rsdesc.DepthClipEnable = TRUE;
m_Device->CreateRasterizerState(&rsdesc, &m_RasterState);
D3D11_DEPTH_STENCIL_DESC dsdesc;
memset(&dsdesc, 0, sizeof(dsdesc));
dsdesc.DepthEnable = TRUE;
dsdesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ZERO;
dsdesc.DepthFunc = GetUsesReverseZ() ? D3D11_COMPARISON_GREATER_EQUAL : D3D11_COMPARISON_LESS_EQUAL;
m_Device->CreateDepthStencilState(&dsdesc, &m_DepthState);
D3D11_BLEND_DESC bdesc;
memset(&bdesc, 0, sizeof(bdesc));
bdesc.RenderTarget[0].BlendEnable = FALSE;
bdesc.RenderTarget[0].RenderTargetWriteMask = 0xF;
m_Device->CreateBlendState(&bdesc, &m_BlendState);
} }
void RenderAPI_D3D11::ReleaseResources()
{
SAFE_RELEASE(m_VB);
SAFE_RELEASE(m_CB);
SAFE_RELEASE(m_VertexShader);
SAFE_RELEASE(m_PixelShader);
SAFE_RELEASE(m_InputLayout);
SAFE_RELEASE(m_RasterState);
SAFE_RELEASE(m_BlendState);
SAFE_RELEASE(m_DepthState);
}
void RenderAPI_D3D11::DrawSimpleTriangles(const float worldMatrix[16], int triangleCount, const void* verticesFloat3Byte4)
{
ID3D11DeviceContext* ctx = NULL;
m_Device->GetImmediateContext(&ctx);
// Set basic render state
ctx->OMSetDepthStencilState(m_DepthState, 0);
ctx->RSSetState(m_RasterState);
ctx->OMSetBlendState(m_BlendState, NULL, 0xFFFFFFFF);
// Update constant buffer - just the world matrix in our case
ctx->UpdateSubresource(m_CB, 0, NULL, worldMatrix, 64, 0);
// Set shaders
ctx->VSSetConstantBuffers(0, 1, &m_CB);
ctx->VSSetShader(m_VertexShader, NULL, 0);
ctx->PSSetShader(m_PixelShader, NULL, 0);
// Update vertex buffer
const int kVertexSize = 12 + 4;
ctx->UpdateSubresource(m_VB, 0, NULL, verticesFloat3Byte4, triangleCount * 3 * kVertexSize, 0);
// set input assembler data and draw
ctx->IASetInputLayout(m_InputLayout);
ctx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
UINT stride = kVertexSize;
UINT offset = 0;
ctx->IASetVertexBuffers(0, 1, &m_VB, &stride, &offset);
ctx->Draw(triangleCount * 3, 0);
ctx->Release();
}
void* RenderAPI_D3D11::BeginModifyTexture(void* textureHandle, int textureWidth, int textureHeight, int* outRowPitch)
{
const int rowPitch = textureWidth * 4;
// Just allocate a system memory buffer here for simplicity
unsigned char* data = new unsigned char[rowPitch * textureHeight];
*outRowPitch = rowPitch;
return data;
}
void RenderAPI_D3D11::EndModifyTexture(void* textureHandle, int textureWidth, int textureHeight, int rowPitch, void* dataPtr)
{
ID3D11Texture2D* d3dtex = (ID3D11Texture2D*)textureHandle;
assert(d3dtex);
ID3D11DeviceContext* ctx = NULL;
m_Device->GetImmediateContext(&ctx);
// Update texture data, and free the memory buffer
ctx->UpdateSubresource(d3dtex, 0, NULL, dataPtr, rowPitch, 0);
delete[] (unsigned char*)dataPtr;
ctx->Release();
}
void* RenderAPI_D3D11::BeginModifyVertexBuffer(void* bufferHandle, size_t* outBufferSize)
{
ID3D11Buffer* d3dbuf = (ID3D11Buffer*)bufferHandle;
assert(d3dbuf);
D3D11_BUFFER_DESC desc;
d3dbuf->GetDesc(&desc);
*outBufferSize = desc.ByteWidth;
ID3D11DeviceContext* ctx = NULL;
m_Device->GetImmediateContext(&ctx);
D3D11_MAPPED_SUBRESOURCE mapped;
ctx->Map(d3dbuf, 0, D3D11_MAP_WRITE_DISCARD, 0, &mapped);
ctx->Release();
return mapped.pData;
}
void RenderAPI_D3D11::EndModifyVertexBuffer(void* bufferHandle)
{
ID3D11Buffer* d3dbuf = (ID3D11Buffer*)bufferHandle;
assert(d3dbuf);
ID3D11DeviceContext* ctx = NULL;
m_Device->GetImmediateContext(&ctx);
ctx->Unmap(d3dbuf, 0);
ctx->Release();
}
#endif // #if SUPPORT_D3D11 #endif // #if SUPPORT_D3D11

File diff suppressed because it is too large Load Diff

View File

@ -522,7 +522,7 @@ void RenderAPI_Vulkan::disableVRS()
vrs_enable = false; vrs_enable = false;
} }
void RenderAPI_Vulkan::enableFGExtrapolation() void RenderAPI_Vulkan::enableFGExtrapolation(void* data)
{ {
} }

View File

@ -128,7 +128,7 @@ static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void *data)
} }
case NativeRenderingEvent::EnableFGExtrapolation: case NativeRenderingEvent::EnableFGExtrapolation:
{ {
s_current_api->enableFGExtrapolation(); s_current_api->enableFGExtrapolation(data);
break; break;
} }
case NativeRenderingEvent::DisableFGExtrapolation: case NativeRenderingEvent::DisableFGExtrapolation:
@ -171,37 +171,37 @@ extern "C" UNITY_INTERFACE_EXPORT bool GetFeatureSupport(int feature)
// DX12 plugin specific // DX12 plugin specific
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
extern "C" UNITY_INTERFACE_EXPORT void *UNITY_INTERFACE_API GetRenderTexture() //extern "C" UNITY_INTERFACE_EXPORT void *UNITY_INTERFACE_API GetRenderTexture()
{ //{
return s_current_api->getRenderTexture(); // return s_current_api->getRenderTexture();
} //}
//
extern "C" UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API SetRenderTexture(UnityRenderBuffer rb) //extern "C" UNITY_INTERFACE_EXPORT void UNITY_INTERFACE_API SetRenderTexture(UnityRenderBuffer rb)
{ //{
s_current_api->setRenderTextureResource(rb); // s_current_api->setRenderTextureResource(rb);
} //}
//
extern "C" UNITY_INTERFACE_EXPORT bool UNITY_INTERFACE_API IsSwapChainAvailable() //extern "C" UNITY_INTERFACE_EXPORT bool UNITY_INTERFACE_API IsSwapChainAvailable()
{ //{
return s_current_api->isSwapChainAvailable(); // return s_current_api->isSwapChainAvailable();
} //}
//
extern "C" UNITY_INTERFACE_EXPORT unsigned int UNITY_INTERFACE_API GetPresentFlags() //extern "C" UNITY_INTERFACE_EXPORT unsigned int UNITY_INTERFACE_API GetPresentFlags()
{ //{
return s_current_api->getPresentFlags(); // return s_current_api->getPresentFlags();
} //}
//
extern "C" UNITY_INTERFACE_EXPORT unsigned int UNITY_INTERFACE_API GetSyncInterval() //extern "C" UNITY_INTERFACE_EXPORT unsigned int UNITY_INTERFACE_API GetSyncInterval()
{ //{
return s_current_api->getSyncInterval(); // return s_current_api->getSyncInterval();
} //}
//
extern "C" UNITY_INTERFACE_EXPORT unsigned int UNITY_INTERFACE_API GetBackBufferWidth() //extern "C" UNITY_INTERFACE_EXPORT unsigned int UNITY_INTERFACE_API GetBackBufferWidth()
{ //{
return s_current_api->getBackbufferHeight(); // return s_current_api->getBackbufferHeight();
} //}
//
extern "C" UNITY_INTERFACE_EXPORT unsigned int UNITY_INTERFACE_API GetBackBufferHeight() //extern "C" UNITY_INTERFACE_EXPORT unsigned int UNITY_INTERFACE_API GetBackBufferHeight()
{ //{
return s_current_api->getBackbufferWidth(); // return s_current_api->getBackbufferWidth();
} //}

View File

@ -7,6 +7,14 @@ if (is_plat("windows")) then
add_cxflags("/EHsc") add_cxflags("/EHsc")
end end
option("use_dx11")
set_showmenu(true)
set_default(false)
option("use_dx12")
set_showmenu(true)
set_default(false)
option("use_vulkan") option("use_vulkan")
set_showmenu(true) set_showmenu(true)
set_default(false) set_default(false)
@ -30,6 +38,16 @@ target("GfxPluginNativeRender")
add_linkdirs("C:/VulkanSDK/1.3.283.0/Lib") add_linkdirs("C:/VulkanSDK/1.3.283.0/Lib")
end end
if is_plat("windows") then
set_kind("shared")
if has_config("use_dx11") then
add_defines("SUPPORT_D3D11=1")
end
if has_config("use_dx12") then
add_defines("SUPPORT_D3D12=1")
end
end
if has_config("use_vulkan") then if has_config("use_vulkan") then
set_kind("shared") set_kind("shared")
add_defines("SUPPORT_VULKAN=1") add_defines("SUPPORT_VULKAN=1")

View File

@ -248,11 +248,28 @@ namespace UnityEngine.Rendering.Universal.Internal
cmd.IssuePluginEventAndData(RenderingPlugin.GetRenderEventAndDataFunc(), (int)RenderingPlugin.NativeRenderingEvent.EnableVRS, p); cmd.IssuePluginEventAndData(RenderingPlugin.GetRenderEventAndDataFunc(), (int)RenderingPlugin.NativeRenderingEvent.EnableVRS, p);
context.ExecuteCommandBuffer(cmd); context.ExecuteCommandBuffer(cmd);
cmd.Clear(); cmd.Clear();
#if DX12
// DX12 下会 context.DrawRenderers 重新设置 view port 和 scissor rect
cmd.SetViewport(camera.pixelRect);
cmd.EnableScissorRect(camera.pixelRect);
#endif
} }
#if DX12
RendererUtils.RendererListDesc rendererListDesc = new (data.m_ShaderTagIdList.ToArray(), renderingData.cullResults,camera);
rendererListDesc.layerMask = camera.cullingMask;
rendererListDesc.sortingCriteria = sortFlags;
rendererListDesc.renderQueueRange = filterSettings.renderQueueRange;
rendererListDesc.layerMask = filterSettings.layerMask;
rendererListDesc.excludeObjectMotionVectors = false;
rendererListDesc.rendererConfiguration = drawSettings.perObjectData;
rendererListDesc.stateBlock = data.m_RenderStateBlock;
cmd.DrawRendererList(context.CreateRendererList(rendererListDesc));
#else
context.DrawRenderers(renderingData.cullResults, ref drawSettings, ref filterSettings, ref data.m_RenderStateBlock); context.DrawRenderers(renderingData.cullResults, ref drawSettings, ref filterSettings, ref data.m_RenderStateBlock);
#endif
if(asset.VRSRate != RenderingPlugin.VRSPluginShadingRate.X1_PER_PIXEL) if (asset.VRSRate != RenderingPlugin.VRSPluginShadingRate.X1_PER_PIXEL)
{ {
cmd.IssuePluginEventAndData(RenderingPlugin.GetRenderEventAndDataFunc(), (int)RenderingPlugin.NativeRenderingEvent.DisableVRS, IntPtr.Zero); cmd.IssuePluginEventAndData(RenderingPlugin.GetRenderEventAndDataFunc(), (int)RenderingPlugin.NativeRenderingEvent.DisableVRS, IntPtr.Zero);
} }

View File

@ -1,5 +1,7 @@
using System; using System;
using System.Collections.Generic;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace X.Rendering.Feature namespace X.Rendering.Feature
{ {
public static class RenderingPlugin public static class RenderingPlugin
@ -64,13 +66,31 @@ namespace X.Rendering.Feature
METAL_FX_TEMPORAL_SR, METAL_FX_TEMPORAL_SR,
VIVO_TEMPORAL_SR, VIVO_TEMPORAL_SR,
QCOM_AFME, QCOM_AFME,
XESS13,
MAX_CNT MAX_CNT
}; };
public static bool GetFeatureSupport(GraphicsFeature feature) static Dictionary<GraphicsFeature, bool> featureSupports = null;
public static void InitSupportFeatures()
{ {
return GetFeatureSupport((int)feature); featureSupports = new();
UnityEngine.Debug.Log(UnityEngine.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);
}
} }
} }

View File

@ -36,7 +36,6 @@ namespace X.Rendering.Feature
//} //}
} }
public override void Create() public override void Create()
{ {
gsr1 = new GSRV1(v1settings); gsr1 = new GSRV1(v1settings);

View File

@ -22,6 +22,11 @@ namespace X.Rendering.Feature
DLSS1, DLSS1,
DLSS2, DLSS2,
DLSS3, DLSS3,
/// <summary>
/// Intel XeSS 1.3.1
/// <see cref="https://github.com/intel/xess.git"/>
/// </summary>
XESS13,
} }
public enum ERenderScale public enum ERenderScale

View File

@ -23,6 +23,7 @@ namespace UnityEngine.Rendering.Universal
var renderer = GetRenderer(this.m_DefaultRendererIndex); var renderer = GetRenderer(this.m_DefaultRendererIndex);
foreach (var item in renderer.rendererFeatures) foreach (var item in renderer.rendererFeatures)
{ {
if (item is ISuperResolutionFeature isr) if (item is ISuperResolutionFeature isr)
{ {
isr.SetSR(superResolution); isr.SetSR(superResolution);
@ -58,6 +59,7 @@ namespace UnityEngine.Rendering.Universal
protected override void OnValidate() protected override void OnValidate()
{ {
base.OnValidate(); base.OnValidate();
RenderingPlugin.InitSupportFeatures();
UpdateSSSettings(); UpdateSSSettings();
} }
} }

View File

@ -5,7 +5,7 @@
"com.unity.ide.rider": "3.0.31", "com.unity.ide.rider": "3.0.31",
"com.unity.ide.visualstudio": "2.0.22", "com.unity.ide.visualstudio": "2.0.22",
"com.unity.ide.vscode": "1.2.5", "com.unity.ide.vscode": "1.2.5",
"com.unity.inputsystem": "1.7.0", "com.unity.inputsystem": "1.11.0",
"com.unity.learn.iet-framework": "3.1.3", "com.unity.learn.iet-framework": "3.1.3",
"com.unity.memoryprofiler": "1.1.1", "com.unity.memoryprofiler": "1.1.1",
"com.unity.recorder": "4.0.3", "com.unity.recorder": "4.0.3",

View File

@ -1,7 +1,7 @@
{ {
"dependencies": { "dependencies": {
"com.unity.burst": { "com.unity.burst": {
"version": "1.8.16", "version": "1.8.17",
"depth": 1, "depth": 1,
"source": "registry", "source": "registry",
"dependencies": { "dependencies": {
@ -66,7 +66,7 @@
"url": "https://packages.tuanjie.cn" "url": "https://packages.tuanjie.cn"
}, },
"com.unity.inputsystem": { "com.unity.inputsystem": {
"version": "1.7.0", "version": "1.11.0",
"depth": 0, "depth": 0,
"source": "registry", "source": "registry",
"dependencies": { "dependencies": {

View File

@ -266,7 +266,6 @@ PlayerSettings:
- {fileID: 0} - {fileID: 0}
- {fileID: 0} - {fileID: 0}
- {fileID: 0} - {fileID: 0}
- {fileID: 11400000, guid: 9e7be553448fa2546aea5752021cbcf7, type: 2}
metroInputSource: 0 metroInputSource: 0
wsaTransparentSwapchain: 0 wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1 m_HolographicPauseOnTrackingLoss: 1
@ -770,7 +769,7 @@ PlayerSettings:
m_APIs: 0b000000 m_APIs: 0b000000
m_Automatic: 0 m_Automatic: 0
- m_BuildTarget: WindowsStandaloneSupport - m_BuildTarget: WindowsStandaloneSupport
m_APIs: 15000000 m_APIs: 120000001500000002000000
m_Automatic: 0 m_Automatic: 0
- m_BuildTarget: LinuxStandaloneSupport - m_BuildTarget: LinuxStandaloneSupport
m_APIs: 15000000 m_APIs: 15000000
@ -1172,7 +1171,7 @@ PlayerSettings:
hmiPlayerDataPath: hmiPlayerDataPath:
hmiForceSRGBBlit: 1 hmiForceSRGBBlit: 1
embeddedLinuxEnableGamepadInput: 1 embeddedLinuxEnableGamepadInput: 1
hmiLogStartupTiming: 0 logStartupTiming: 0
hmiCpuConfiguration: hmiCpuConfiguration:
openHarmonySplashScreen: {fileID: 0} openHarmonySplashScreen: {fileID: 0}
openHarmonySplashScreenScale: 0 openHarmonySplashScreenScale: 0

View File

@ -1,3 +1,3 @@
m_EditorVersion: 2022.3.38t1 m_EditorVersion: 2022.3.48t1
m_EditorVersionWithRevision: 2022.3.38t1 (2816c3a8c7c3) m_EditorVersionWithRevision: 2022.3.48t1 (8ad5b9288c6b)
m_TuanjieEditorVersion: 1.3.1 m_TuanjieEditorVersion: 1.3.4

View File

@ -9,17 +9,17 @@ EditorUserSettings:
value: 0257020252075b0b5a0b5b2345715a444f4e402b7a2d22667f7c4b35e7b16769 value: 0257020252075b0b5a0b5b2345715a444f4e402b7a2d22667f7c4b35e7b16769
flags: 0 flags: 0
RecentlyUsedSceneGuid-1: RecentlyUsedSceneGuid-1:
value: 5a57555407545f0b5e0f5f764277594914161e2b787977692b714e64e4b2363b
flags: 0
RecentlyUsedSceneGuid-2:
value: 01060c075556080e0956597315775b14104e4179282b25662b2c1c31b7b63068 value: 01060c075556080e0956597315775b14104e4179282b25662b2c1c31b7b63068
flags: 0 flags: 0
RecentlyUsedSceneGuid-3: RecentlyUsedSceneGuid-2:
value: 5b00515154055e035459547042705a44154f1e2c2e2e7f677e7d4567e1b9376d value: 5b00515154055e035459547042705a44154f1e2c2e2e7f677e7d4567e1b9376d
flags: 0 flags: 0
RecentlyUsedSceneGuid-4: RecentlyUsedSceneGuid-3:
value: 57050d5004060d590f56087046700f4445164c7e7a7824312e7c4e6bb0e1376d value: 57050d5004060d590f56087046700f4445164c7e7a7824312e7c4e6bb0e1376d
flags: 0 flags: 0
RecentlyUsedSceneGuid-4:
value: 5a57555407545f0b5e0f5f764277594914161e2b787977692b714e64e4b2363b
flags: 0
vcSharedLogLevel: vcSharedLogLevel:
value: 0d5e400f0650 value: 0d5e400f0650
flags: 0 flags: 0

File diff suppressed because it is too large Load Diff