This commit is contained in:
StarBeats 2024-12-12 17:41:33 +08:00
parent 46d283d0b6
commit c5a7d12e01
27 changed files with 1746 additions and 226 deletions

Binary file not shown.

View File

@ -0,0 +1,27 @@
fileFormatVersion: 2
guid: CXtK5iilVi2vEbG9dAhdz7u8sY5CU6sNVZp12U9UqlsjYk/4wrgr5h0=
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
userData:
assetBundleName:
assetBundleVariant:

View File

@ -28,7 +28,7 @@ MonoBehaviour:
m_SupportsHDR: 1
m_HDRColorBufferPrecision: 0
m_MSAA: 1
m_RenderScale: 1
m_RenderScale: 0.6
m_UpscalingFilter: 0
m_FsrOverrideSharpness: 1
m_FsrSharpness: 1
@ -114,6 +114,6 @@ MonoBehaviour:
m_PrefilterNativeRenderPass: 1
m_ShaderVariantLogLevel: 0
m_ShadowCascades: 0
superResolution: 0
sSRenderScale: 0
vrsRate: 3
superResolution: 14
sSRenderScale: 4
vrsRate: 0

View File

@ -80,7 +80,8 @@ MonoBehaviour:
- {fileID: 2459758869679212578}
- {fileID: 1524480044783497712}
- {fileID: 6334271670068977784}
m_RendererFeatureMap: bc3f630842f2e70dd6a559c442a94bfd4529d15534f2d3de228858dca8d12222f0f17d10860a28157820480586dae757
- {fileID: 1342351342872651138}
m_RendererFeatureMap: bc3f630842f2e70dd6a559c442a94bfd4529d15534f2d3de228858dca8d12222f0f17d10860a28157820480586dae7578265b12b6ffda012
m_UseNativeRenderPass: 1
postProcessData: {fileID: 11400000, guid: 41439944d30ece34e96484bdb6645b55, type: 2}
shaders:
@ -132,6 +133,35 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_Active: 1
_baseProfile: {fileID: 11400000, guid: f2d4d916a6612574cad220d125febbf2, type: 2}
--- !u!114 &1342351342872651138
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c3c4391133b9f3142b57264047029ec5, type: 3}
m_Name: XESS
m_EditorClassIdentifier:
m_Active: 1
xess1ConfigParam:
OutputWidth: 1920
OutputHeight: 1080
Quality: 103
UseHiResMotionVectors: 1
UseJitteredMotionVectors: 0
UseMotionVectorsInNDC: 0
UseExposureTexture: 0
UseResponsiveMask: 0
UseAutoExposure: 0
EnableProfiling: 0
VelocityScaleX: 1
VelocityScaleY: 1
JitterScaleX: 1
JitterScaleY: 1
ExposureScale: 1
--- !u!114 &1524480044783497712
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@ -1,31 +1,36 @@
[
{
"directory": "G:\\TJURP\\NativeRenderPlugin",
"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"],
"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", "/Iexternal\\include", "/Ifeatures", "/DNOMINMAX", "/DSUPPORT_D3D11=1", "/DSUPPORT_D3D12=1", "/DSUPPORT_VULKAN=1", "/EHsc", "/Fobuild\\.objs\\GfxPluginNativeRender\\windows\\x64\\release\\features\\xess1\\xess.cpp.obj", "features\\xess1\\xess.cpp"],
"file": "features\\xess1\\xess.cpp"
},
{
"directory": "G:\\TJURP\\NativeRenderPlugin",
"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", "/Iexternal\\include", "/Ifeatures", "/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"
},
{
"directory": "G:\\TJURP\\NativeRenderPlugin",
"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"],
"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", "/Iexternal\\include", "/Ifeatures", "/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"
},
{
"directory": "G:\\TJURP\\NativeRenderPlugin",
"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"],
"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", "/Iexternal\\include", "/Ifeatures", "/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"
},
{
"directory": "G:\\TJURP\\NativeRenderPlugin",
"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"],
"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", "/Iexternal\\include", "/Ifeatures", "/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"
},
{
"directory": "G:\\TJURP\\NativeRenderPlugin",
"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"],
"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", "/Iexternal\\include", "/Ifeatures", "/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"
},
{
"directory": "G:\\TJURP\\NativeRenderPlugin",
"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"],
"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", "/Iexternal\\include", "/Ifeatures", "/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"
}]

View File

@ -19,7 +19,62 @@
"map": "cpp",
"unordered_map": "cpp",
"utility": "cpp",
"system_error": "cpp"
"system_error": "cpp",
"span": "cpp",
"atomic": "cpp",
"bit": "cpp",
"cctype": "cpp",
"charconv": "cpp",
"chrono": "cpp",
"clocale": "cpp",
"cmath": "cpp",
"compare": "cpp",
"concepts": "cpp",
"cstdarg": "cpp",
"cstddef": "cpp",
"cstdint": "cpp",
"cstdio": "cpp",
"cstdlib": "cpp",
"cstring": "cpp",
"ctime": "cpp",
"cwchar": "cpp",
"cwctype": "cpp",
"exception": "cpp",
"expected": "cpp",
"forward_list": "cpp",
"functional": "cpp",
"iomanip": "cpp",
"ios": "cpp",
"iosfwd": "cpp",
"iostream": "cpp",
"istream": "cpp",
"limits": "cpp",
"locale": "cpp",
"memory": "cpp",
"mutex": "cpp",
"new": "cpp",
"optional": "cpp",
"ostream": "cpp",
"ratio": "cpp",
"set": "cpp",
"sstream": "cpp",
"stdexcept": "cpp",
"stop_token": "cpp",
"streambuf": "cpp",
"string": "cpp",
"thread": "cpp",
"type_traits": "cpp",
"typeinfo": "cpp",
"variant": "cpp",
"xfacet": "cpp",
"xlocale": "cpp",
"xlocbuf": "cpp",
"xlocinfo": "cpp",
"xlocmes": "cpp",
"xlocmon": "cpp",
"xlocnum": "cpp",
"xloctime": "cpp",
"xtr1common": "cpp"
},
"workbench.colorCustomizations": {
"editor.lineHighlightBackground": "#1073cf2d",

View File

@ -91,6 +91,12 @@ public:
virtual void spatialUpScale(void* src, void* data, void* dst) {}
virtual bool getFeatureSupport(GraphicsFeature feature);
virtual void enableXESS1(void* data) {}
virtual void doXESS1(void* data) {}
virtual void configXESS1(void* data) {}
virtual void disableXESS1() {}
protected:
virtual void initSupportFeature() = 0;

View File

@ -19,6 +19,8 @@
#include <map>
#include <iostream>
#include "xess1/xess.h"
#define ReturnOnFail(x, hr, OnFailureMsg, onFailureReturnValue) hr = x; if(FAILED(hr)){OutputDebugStringA(OnFailureMsg); return onFailureReturnValue;}
#define D3D12_DEFAULT_HEAP_TRIANGLE_BUFFER_NAME L"Native Plugin Default Heap Triangle Vertex Buffer"
@ -28,219 +30,256 @@
// Compiled from:
/*
cbuffer MyCB : register(b0)
{
float4x4 worldMatrix;
}
void VS(float3 pos : POSITION, float4 color : COLOR, out float4 ocolor : COLOR, out float4 opos : SV_Position)
{
opos = mul(worldMatrix, float4(pos, 1));
ocolor = color;
}
float4 PS(float4 color : COLOR) : SV_TARGET
{
return color;
}
cbuffer MyCB : register(b0)
{
float4x4 worldMatrix;
}
void VS(float3 pos : POSITION, float4 color : COLOR, out float4 ocolor : COLOR, out float4 opos : SV_Position)
{
opos = mul(worldMatrix, float4(pos, 1));
ocolor = color;
}
float4 PS(float4 color : COLOR) : SV_TARGET
{
return color;
}
*/
// using:
/*
dxc -T vs_6_0 -E VSMain -Fo vertex_shader .\shaders.hlsl -Qstrip_reflect -Qstrip_debug
dxc -T ps_6_0 -E PSMain -Fo pixel_shader .\shaders.hlsl -Qstrip_reflect -Qstrip_debug
dxc -T vs_6_0 -E VSMain -Fo vertex_shader .\shaders.hlsl -Qstrip_reflect -Qstrip_debug
dxc -T ps_6_0 -E PSMain -Fo pixel_shader .\shaders.hlsl -Qstrip_reflect -Qstrip_debug
*/
extern void unityLog(const char* msg);
static void handle_hr(HRESULT hr, const char* error = "")
{
if (FAILED(hr))
{
OutputDebugStringA(error);
std::cerr << error << "\n";
abort();
}
if (FAILED(hr))
{
OutputDebugStringA(error);
std::cerr << error << "\n";
abort();
}
}
struct D3D12MemoryObject
{
ID3D12Resource* resource;
void* mapped;
D3D12_HEAP_TYPE heapType;
D3D12_RESOURCE_FLAGS resourceFlags;
UINT64 deviceMemorySize;
ID3D12Resource* resource;
void* mapped;
D3D12_HEAP_TYPE heapType;
D3D12_RESOURCE_FLAGS resourceFlags;
UINT64 deviceMemorySize;
};
struct D3D12DefaultBufferMemoryObject
{
D3D12MemoryObject uploadResource;
D3D12MemoryObject defaultResource;
D3D12MemoryObject uploadResource;
D3D12MemoryObject defaultResource;
};
class RenderAPI_D3D12 : public RenderAPI
{
public:
RenderAPI_D3D12();
virtual ~RenderAPI_D3D12() override { }
RenderAPI_D3D12();
virtual ~RenderAPI_D3D12() override {}
virtual void processDeviceEvent(UnityGfxDeviceEventType type, IUnityInterfaces* interfaces) override;
virtual bool getUsesReverseZ() override { return true; }
virtual void processDeviceEvent(UnityGfxDeviceEventType type, IUnityInterfaces* interfaces) override;
virtual bool getUsesReverseZ() override { return true; }
virtual bool isSwapChainAvailable() override;
virtual unsigned int getPresentFlags() override;
virtual unsigned int getSyncInterval() override;
virtual unsigned int getBackbufferWidth() override;
virtual unsigned int getBackbufferHeight() override;
virtual bool isSwapChainAvailable() override;
virtual unsigned int getPresentFlags() override;
virtual unsigned int getSyncInterval() override;
virtual unsigned int getBackbufferWidth() override;
virtual unsigned int getBackbufferHeight() override;
virtual void enableVRS(int vrsEnum) override;
virtual void disableVRS() override;
virtual void enableVRS(int vrsEnum) override;
virtual void disableVRS() override;
virtual void initSupportFeature() override;
virtual void initSupportFeature() override;
virtual void enableXESS1(void* data) override;
virtual void doXESS1(void* data) override;
virtual void disableXESS1() override;
virtual void configXESS1(void* data) override;
IUnityGraphicsD3D12v7* s_d3d12;
IUnityGraphicsD3D12v7* s_d3d12;
XessV13* xess;
};
RenderAPI* CreateRenderAPI_D3D12()
{
return new RenderAPI_D3D12();
return new RenderAPI_D3D12();
}
RenderAPI_D3D12::RenderAPI_D3D12()
: s_d3d12(NULL)
: s_d3d12(NULL)
{
}
UINT64 CalcByteAlignedValue(unsigned int byteSize, unsigned int byteAlignment)
{
UINT byteAlignmentMinusOne = byteAlignment - 2;
return (byteSize + byteAlignmentMinusOne) & ~byteAlignmentMinusOne;
UINT byteAlignmentMinusOne = byteAlignment - 2;
return (byteSize + byteAlignmentMinusOne) & ~byteAlignmentMinusOne;
}
void RenderAPI_D3D12::processDeviceEvent(UnityGfxDeviceEventType type, IUnityInterfaces* interfaces)
{
switch (type)
{
case kUnityGfxDeviceEventInitialize:
s_d3d12 = interfaces->Get<IUnityGraphicsD3D12v7>();
switch (type)
{
case kUnityGfxDeviceEventInitialize:
s_d3d12 = interfaces->Get<IUnityGraphicsD3D12v7>();
UnityD3D12PluginEventConfig config_1;
config_1.graphicsQueueAccess = kUnityD3D12GraphicsQueueAccess_DontCare;
config_1.flags = kUnityD3D12EventConfigFlag_SyncWorkerThreads | kUnityD3D12EventConfigFlag_ModifiesCommandBuffersState | kUnityD3D12EventConfigFlag_EnsurePreviousFrameSubmission;
config_1.ensureActiveRenderTextureIsBound = true;
s_d3d12->ConfigureEvent(1, &config_1);
UnityD3D12PluginEventConfig config_1;
config_1.graphicsQueueAccess = kUnityD3D12GraphicsQueueAccess_DontCare;
config_1.flags = kUnityD3D12EventConfigFlag_SyncWorkerThreads | kUnityD3D12EventConfigFlag_ModifiesCommandBuffersState | kUnityD3D12EventConfigFlag_EnsurePreviousFrameSubmission;
config_1.ensureActiveRenderTextureIsBound = true;
s_d3d12->ConfigureEvent(1, &config_1);
UnityD3D12PluginEventConfig config_2;
config_2.graphicsQueueAccess = kUnityD3D12GraphicsQueueAccess_Allow;
config_2.flags = kUnityD3D12EventConfigFlag_SyncWorkerThreads | kUnityD3D12EventConfigFlag_ModifiesCommandBuffersState | kUnityD3D12EventConfigFlag_EnsurePreviousFrameSubmission;
config_2.ensureActiveRenderTextureIsBound = false;
s_d3d12->ConfigureEvent(2, &config_2);
initSupportFeature();
break;
case kUnityGfxDeviceEventShutdown:
break;
}
UnityD3D12PluginEventConfig config_2;
config_2.graphicsQueueAccess = kUnityD3D12GraphicsQueueAccess_Allow;
config_2.flags = kUnityD3D12EventConfigFlag_SyncWorkerThreads | kUnityD3D12EventConfigFlag_ModifiesCommandBuffersState | kUnityD3D12EventConfigFlag_EnsurePreviousFrameSubmission;
config_2.ensureActiveRenderTextureIsBound = false;
s_d3d12->ConfigureEvent(2, &config_2);
xess = new XessV13(s_d3d12->GetDevice());
initSupportFeature();
break;
case kUnityGfxDeviceEventShutdown:
break;
}
}
bool RenderAPI_D3D12::isSwapChainAvailable()
{
return s_d3d12->GetSwapChain();
return s_d3d12->GetSwapChain();
}
unsigned int RenderAPI_D3D12::getPresentFlags()
{
return s_d3d12->GetPresentFlags();
return s_d3d12->GetPresentFlags();
};
unsigned int RenderAPI_D3D12::getSyncInterval()
{
return s_d3d12->GetSyncInterval();
return s_d3d12->GetSyncInterval();
}
unsigned int RenderAPI_D3D12::getBackbufferWidth()
{
IDXGISwapChain* swap_chain = s_d3d12->GetSwapChain();
if (!swap_chain)
return 0;
IDXGISwapChain* swap_chain = s_d3d12->GetSwapChain();
if (!swap_chain)
return 0;
DXGI_SWAP_CHAIN_DESC desc;
handle_hr(swap_chain->GetDesc(&desc), "Failed to get DXGI swap chain desc\n");
DXGI_SWAP_CHAIN_DESC desc;
handle_hr(swap_chain->GetDesc(&desc), "Failed to get DXGI swap chain desc\n");
return desc.BufferDesc.Width;
return desc.BufferDesc.Width;
}
unsigned int RenderAPI_D3D12::getBackbufferHeight()
{
IDXGISwapChain* swap_chain = s_d3d12->GetSwapChain();
if (!swap_chain)
return 0;
IDXGISwapChain* swap_chain = s_d3d12->GetSwapChain();
if (!swap_chain)
return 0;
DXGI_SWAP_CHAIN_DESC desc;
handle_hr(swap_chain->GetDesc(&desc), "Failed to get DXGI swap chain desc\n");
DXGI_SWAP_CHAIN_DESC desc;
handle_hr(swap_chain->GetDesc(&desc), "Failed to get DXGI swap chain desc\n");
return desc.BufferDesc.Height;
return desc.BufferDesc.Height;
}
static D3D12_SHADING_RATE vrs_argment_size_table[] = {
D3D12_SHADING_RATE_1X1,
D3D12_SHADING_RATE_2X1,
D3D12_SHADING_RATE_1X2,
D3D12_SHADING_RATE_2X2,
D3D12_SHADING_RATE_4X2,
D3D12_SHADING_RATE_2X4,
D3D12_SHADING_RATE_4X4
D3D12_SHADING_RATE_1X1,
D3D12_SHADING_RATE_2X1,
D3D12_SHADING_RATE_1X2,
D3D12_SHADING_RATE_2X2,
D3D12_SHADING_RATE_4X2,
D3D12_SHADING_RATE_2X4,
D3D12_SHADING_RATE_4X4
};
void RenderAPI_D3D12::enableVRS(int vrsEnum)
{
UnityGraphicsD3D12RecordingState recordingState;
if (!s_d3d12->CommandRecordingState(&recordingState))
{
return;
}
ID3D12GraphicsCommandList* cmdLst = recordingState.commandList;
reinterpret_cast<ID3D12GraphicsCommandList5*>(cmdLst)->RSSetShadingRate(vrs_argment_size_table[vrsEnum], nullptr);
UnityGraphicsD3D12RecordingState recordingState;
if (!s_d3d12->CommandRecordingState(&recordingState))
{
return;
}
ID3D12GraphicsCommandList* cmdLst = recordingState.commandList;
reinterpret_cast<ID3D12GraphicsCommandList5*>(cmdLst)->RSSetShadingRate(vrs_argment_size_table[vrsEnum], nullptr);
}
void RenderAPI_D3D12::disableVRS()
{
UnityGraphicsD3D12RecordingState recordingState;
if (!s_d3d12->CommandRecordingState(&recordingState))
{
return;
}
ID3D12GraphicsCommandList* cmdLst = recordingState.commandList;
reinterpret_cast<ID3D12GraphicsCommandList5*>(cmdLst)->RSSetShadingRate(D3D12_SHADING_RATE_1X1, nullptr);
UnityGraphicsD3D12RecordingState recordingState;
if (!s_d3d12->CommandRecordingState(&recordingState))
{
return;
}
ID3D12GraphicsCommandList* cmdLst = recordingState.commandList;
reinterpret_cast<ID3D12GraphicsCommandList5*>(cmdLst)->RSSetShadingRate(D3D12_SHADING_RATE_1X1, nullptr);
}
void RenderAPI_D3D12::initSupportFeature()
{
D3D12_FEATURE_DATA_D3D12_OPTIONS6 options = {};
s_d3d12->GetDevice()->CheckFeatureSupport(
D3D12_FEATURE_D3D12_OPTIONS6,
&options,
sizeof(options));
if (options.VariableShadingRateTier == D3D12_VARIABLE_SHADING_RATE_TIER_1)
{
support_features[GraphicsFeature::VRS_DRAW] = true;
}
else if (options.VariableShadingRateTier == D3D12_VARIABLE_SHADING_RATE_TIER_2)
{
support_features[GraphicsFeature::VRS_DRAW] = true;
support_features[GraphicsFeature::VRS_PRIMITIVE] = true;
support_features[GraphicsFeature::VRS_ATTACHMENT] = true;
}
D3D12_FEATURE_DATA_D3D12_OPTIONS6 options = {};
s_d3d12->GetDevice()->CheckFeatureSupport(
D3D12_FEATURE_D3D12_OPTIONS6,
&options,
sizeof(options));
if (options.VariableShadingRateTier == D3D12_VARIABLE_SHADING_RATE_TIER_1)
{
support_features[GraphicsFeature::VRS_DRAW] = true;
}
else if (options.VariableShadingRateTier == D3D12_VARIABLE_SHADING_RATE_TIER_2)
{
support_features[GraphicsFeature::VRS_DRAW] = true;
support_features[GraphicsFeature::VRS_PRIMITIVE] = true;
support_features[GraphicsFeature::VRS_ATTACHMENT] = true;
}
if (options.AdditionalShadingRatesSupported)
{
// xxx: 一般用不到这么高级别
// 表示支持 2x4、4x2 和 4x4
}
if (options.AdditionalShadingRatesSupported)
{
// xxx: 一般用不到这么高级别
// 表示支持 2x4、4x2 和 4x4
}
support_features[GraphicsFeature::XESS13] = true;
support_features[GraphicsFeature::XESS13] = true;
}
void RenderAPI_D3D12::enableXESS1(void* data)
{
xess->enable([](const char* msg)
{
unityLog(msg);
}
);
}
void RenderAPI_D3D12::doXESS1(void* data)
{
UnityGraphicsD3D12RecordingState recordingState;
if (!s_d3d12->CommandRecordingState(&recordingState))
{
return;
}
xess->execute(data, recordingState.commandList);
}
void RenderAPI_D3D12::disableXESS1()
{
xess->disable();
}
void RenderAPI_D3D12::configXESS1(void* data)
{
//s_d3d12->GetCommandQueue()->Wait(s_d3d12->GetFrameFence(), 5);
xess->configxess(data);
}
#undef ReturnOnFail

View File

@ -106,6 +106,10 @@ enum NativeRenderingEvent
PostFGExtrapolation,
DisableFGExtrapolation,
// SpatialUpScale,
EnableXESS1,
DoXESS1,
UpdateXESS1Config,
DisableXESS1,
};
static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void *data)
@ -143,12 +147,33 @@ static void UNITY_INTERFACE_API OnRenderEventAndData(int eventID, void *data)
{
break;
}
case NativeRenderingEvent::DoFGExtrapolation:
{
AFMEParam *param = (AFMEParam *)data;
s_current_api->doFGExtrapolation(param->src, param->data, param->dst);
break;
}
case NativeRenderingEvent::EnableXESS1:
{
s_current_api->enableXESS1(data);
break;
}
case NativeRenderingEvent::DisableXESS1:
{
s_current_api->disableXESS1();
break;
}
case NativeRenderingEvent::UpdateXESS1Config:
{
s_current_api->configXESS1(data);
break;
}
case NativeRenderingEvent::DoXESS1:
{
s_current_api->doXESS1(data);
break;
}
default:
break;
}

View File

@ -336,8 +336,8 @@ typedef struct UnityRenderingExtTextureUpdateParamsV1
unsigned int textureID; // texture ID of the texture to be updated.
UnityRenderingExtTextureFormat format; // format of the texture to be updated
unsigned int width; // width of the texture
unsigned int height; // height of the texture
unsigned int InputWidth; // width of the texture
unsigned int InputHeight; // height of the texture
unsigned int bpp; // texture bytes per pixel.
} UnityRenderingExtTextureUpdateParamsV1;
@ -353,8 +353,8 @@ typedef struct UnityRenderingExtTextureUpdateParamsV2
intptr_t textureID; // texture ID of the texture to be updated.
unsigned int userData; // user defined data. Set by the plugin
UnityRenderingExtTextureFormat format; // format of the texture to be updated
unsigned int width; // width of the texture
unsigned int height; // height of the texture
unsigned int InputWidth; // width of the texture
unsigned int InputHeight; // height of the texture
unsigned int bpp; // texture bytes per pixel.
} UnityRenderingExtTextureUpdateParamsV2;

View File

@ -0,0 +1,395 @@
/*******************************************************************************
* Copyright (C) 2021 Intel Corporation
*
* This software and the related documents are Intel copyrighted materials, and
* your use of them is governed by the express license under which they were
* provided to you ("License"). Unless the License provides otherwise, you may
* not use, modify, copy, publish, distribute, disclose or transmit this
* software or the related documents without Intel's prior written permission.
*
* This software and the related documents are provided as is, with no express
* or implied warranties, other than those that are expressly stated in the
* License.
******************************************************************************/
#ifndef XESS_H
#define XESS_H
#ifdef XESS_SHARED_LIB
#ifdef _WIN32
#ifdef XESS_EXPORT_API
#define XESS_API __declspec(dllexport)
#else
#define XESS_API __declspec(dllimport)
#endif
#else
#define XESS_API __attribute__((visibility("default")))
#endif
#else
#define XESS_API
#endif
#if !defined _MSC_VER || (_MSC_VER >= 1929)
#define XESS_PRAGMA(x) _Pragma(#x)
#else
#define XESS_PRAGMA(x) __pragma(x)
#endif
#define XESS_PACK_B_X(x) XESS_PRAGMA(pack(push, x))
#define XESS_PACK_E() XESS_PRAGMA(pack(pop))
#define XESS_PACK_B() XESS_PACK_B_X(8)
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _xess_context_handle_t* xess_context_handle_t;
XESS_PACK_B()
/**
* @brief X<sup>e</sup>SS version.
*
* X<sup>e</sup>SS uses major.minor.patch version format and Numeric 90+ scheme for development stage builds.
*/
typedef struct _xess_version_t
{
/** A major version increment indicates a new API and potentially a
* break in functionality. */
uint16_t major;
/** A minor version increment indicates incremental changes such as
* optional inputs or flags. This does not break existing functionality. */
uint16_t minor;
/** A patch version increment may include performance or quality tweaks or fixes for known issues.
* There's no change in the interfaces.
* Versions beyond 90 used for development builds to change the interface for the next release.
*/
uint16_t patch;
/** Reserved for future use. */
uint16_t reserved;
} xess_version_t;
XESS_PACK_E()
XESS_PACK_B()
/**
* @brief 2D variable.
*/
typedef struct _xess_2d_t
{
uint32_t x;
uint32_t y;
} xess_2d_t;
XESS_PACK_E()
/**
* @brief 2D coordinates.
*/
typedef xess_2d_t xess_coord_t;
/**
* @brief X<sup>e</sup>SS quality settings.
*/
typedef enum _xess_quality_settings_t
{
XESS_QUALITY_SETTING_ULTRA_PERFORMANCE = 100,
XESS_QUALITY_SETTING_PERFORMANCE = 101,
XESS_QUALITY_SETTING_BALANCED = 102,
XESS_QUALITY_SETTING_QUALITY = 103,
XESS_QUALITY_SETTING_ULTRA_QUALITY = 104,
XESS_QUALITY_SETTING_ULTRA_QUALITY_PLUS = 105,
XESS_QUALITY_SETTING_AA = 106,
} xess_quality_settings_t;
/**
* @brief X<sup>e</sup>SS initialization flags.
*/
typedef enum _xess_init_flags_t
{
XESS_INIT_FLAG_NONE = 0,
/** Use motion vectors at target resolution. */
XESS_INIT_FLAG_HIGH_RES_MV = 1 << 0,
/** Use inverted (increased precision) depth encoding */
XESS_INIT_FLAG_INVERTED_DEPTH = 1 << 1,
/** Use exposure texture to scale input color. */
XESS_INIT_FLAG_EXPOSURE_SCALE_TEXTURE = 1 << 2,
/** Use responsive pixel mask texture. */
XESS_INIT_FLAG_RESPONSIVE_PIXEL_MASK = 1 << 3,
/** Use velocity in NDC */
XESS_INIT_FLAG_USE_NDC_VELOCITY = 1 << 4,
/** Use external descriptor heap */
XESS_INIT_FLAG_EXTERNAL_DESCRIPTOR_HEAP = 1 << 5,
/** Disable tonemapping for input and output */
XESS_INIT_FLAG_LDR_INPUT_COLOR = 1 << 6,
/** Remove jitter from input velocity*/
XESS_INIT_FLAG_JITTERED_MV = 1 << 7,
/** Enable automatic exposure calculation. */
XESS_INIT_FLAG_ENABLE_AUTOEXPOSURE = 1 << 8
} xess_init_flags_t;
XESS_PACK_B()
/**
* @brief Properties for internal X<sup>e</sup>SS resources.
*/
typedef struct _xess_properties_t
{
/** Required amount of descriptors for X<sup>e</sup>SS */
uint32_t requiredDescriptorCount;
/** The heap size required by X<sup>e</sup>SS for temporary buffer storage. */
uint64_t tempBufferHeapSize;
/** The heap size required by X<sup>e</sup>SS for temporary texture storage. */
uint64_t tempTextureHeapSize;
} xess_properties_t;
XESS_PACK_E()
/**
* @brief X<sup>e</sup>SS return codes.
*/
typedef enum _xess_result_t
{
/** Warning. Folder to store dump data doesn't exist. Write operation skipped.*/
XESS_RESULT_WARNING_NONEXISTING_FOLDER = 1,
/** An old or outdated driver. */
XESS_RESULT_WARNING_OLD_DRIVER = 2,
/** X<sup>e</sup>SS operation was successful. */
XESS_RESULT_SUCCESS = 0,
/** X<sup>e</sup>SS not supported on the GPU. An SM 6.4 capable GPU is required. */
XESS_RESULT_ERROR_UNSUPPORTED_DEVICE = -1,
/** An unsupported driver. */
XESS_RESULT_ERROR_UNSUPPORTED_DRIVER = -2,
/** Execute called without initialization. */
XESS_RESULT_ERROR_UNINITIALIZED = -3,
/** Invalid argument such as descriptor handles. */
XESS_RESULT_ERROR_INVALID_ARGUMENT = -4,
/** Not enough available GPU memory. */
XESS_RESULT_ERROR_DEVICE_OUT_OF_MEMORY = -5,
/** Device function such as resource or descriptor creation. */
XESS_RESULT_ERROR_DEVICE = -6,
/** The function is not implemented */
XESS_RESULT_ERROR_NOT_IMPLEMENTED = -7,
/** Invalid context. */
XESS_RESULT_ERROR_INVALID_CONTEXT = -8,
/** Operation not finished yet. */
XESS_RESULT_ERROR_OPERATION_IN_PROGRESS = -9,
/** Operation not supported in current configuration. */
XESS_RESULT_ERROR_UNSUPPORTED = -10,
/** The library cannot be loaded. */
XESS_RESULT_ERROR_CANT_LOAD_LIBRARY = -11,
/** Unknown internal failure */
XESS_RESULT_ERROR_UNKNOWN = -1000,
} xess_result_t;
/**
* @brief X<sup>e</sup>SS logging level
*/
typedef enum _xess_logging_level_t
{
XESS_LOGGING_LEVEL_DEBUG = 0,
XESS_LOGGING_LEVEL_INFO = 1,
XESS_LOGGING_LEVEL_WARNING = 2,
XESS_LOGGING_LEVEL_ERROR = 3
} xess_logging_level_t;
/**
* A logging callback provided by the application. This callback can be called from other threads.
* Message pointer are only valid inside function and may be invalid right after return call.
* Message is a null-terminated utf-8 string
*/
typedef void (*xess_app_log_callback_t)(const char *message, xess_logging_level_t loggingLevel);
#ifndef XESS_TYPES_ONLY
/** @addtogroup xess XeSS API exports
* @{
*/
/**
* @brief Gets the X<sup>e</sup>SS version. This is baked into the X<sup>e</sup>SS SDK release.
* @param[out] pVersion Returned X<sup>e</sup>SS version.
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessGetVersion(xess_version_t* pVersion);
/**
* @brief Gets the version of the loaded Intel XeFX library. When running on Intel platforms
* this function will return the version of the loaded Intel XeFX library, for other
* platforms 0.0.0 will be returned.
* @param hContext The X<sup>e</sup>SS context handle.
* @param[out] pVersion Returned Intel XeFX library version.
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessGetIntelXeFXVersion(xess_context_handle_t hContext,
xess_version_t* pVersion);
/**
* @brief Gets X<sup>e</sup>SS internal resources properties.
* @param hContext The X<sup>e</sup>SS context handle.
* @param pOutputResolution Output resolution to calculate properties for.
* @param[out] pBindingProperties Returned properties.
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessGetProperties(xess_context_handle_t hContext,
const xess_2d_t* pOutputResolution, xess_properties_t* pBindingProperties);
/**
* @brief Get the input resolution for a specified output resolution for a given quality setting.
* X<sup>e</sup>SS expects all the input buffers except motion vectors to be in the returned resolution.
* Motion vectors can be either in output resolution (XESS_INIT_FLAG_HIGH_RES_MV) or
* returned resolution (default).
*
* @param hContext The X<sup>e</sup>SS context handle.
* @param pOutputResolution Output resolution to calculate input resolution for.
* @param qualitySettings Desired quality setting.
* @param[out] pInputResolution Required input resolution.
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessGetInputResolution(xess_context_handle_t hContext,
const xess_2d_t* pOutputResolution, xess_quality_settings_t qualitySettings,
xess_2d_t* pInputResolution);
/**
* @brief Get the optimal input resolution and possible range for a specified output resolution for a given quality setting.
* X<sup>e</sup>SS expects all the input buffers except motion vectors to be in the returned resolution range
* and all input buffers to be in the same resolution.
* Motion vectors can be either in output resolution (XESS_INIT_FLAG_HIGH_RES_MV) or
* in the same resolution as other input buffers (by default).
*
* @note Aspect ratio of the input resolution must be the same as for the output resolution.
*
* @param hContext The X<sup>e</sup>SS context handle.
* @param pOutputResolution Output resolution to calculate input resolution for.
* @param qualitySettings Desired quality setting.
* @param[out] pInputResolutionOptimal Optimal input resolution.
* @param[out] pInputResolutionMin Required minimal input resolution.
* @param[out] pInputResolutionMax Required maximal input resolution.
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessGetOptimalInputResolution(xess_context_handle_t hContext,
const xess_2d_t* pOutputResolution, xess_quality_settings_t qualitySettings,
xess_2d_t* pInputResolutionOptimal, xess_2d_t* pInputResolutionMin, xess_2d_t* pInputResolutionMax);
/**
* @brief Gets jitter scale value.
* @param hContext The X<sup>e</sup>SS context handle.
* @param[out] pX Jitter scale pointer for the X axis.
* @param[out] pY Jitter scale pointer for the Y axis.
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessGetJitterScale(xess_context_handle_t hContext, float* pX, float* pY);
/**
* @brief Gets velocity scale value.
* @param hContext The X<sup>e</sup>SS context handle.
* @param[out] pX Velocity scale pointer for the X axis.
* @param[out] pY Velocity scale pointer for the Y axis.
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessGetVelocityScale(xess_context_handle_t hContext, float* pX, float* pY);
/**
* @brief Destroys the X<sup>e</sup>SS context.
* The user must ensure that any pending command lists are completed before destroying the context.
* @param hContext: The X<sup>e</sup>SS context handle.
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessDestroyContext(xess_context_handle_t hContext);
/**
* @brief Sets jitter scale value
*
* @param hContext The X<sup>e</sup>SS context handle.
* @param x scale for the X axis
* @param y scale for the Y axis
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessSetJitterScale(xess_context_handle_t hContext, float x, float y);
/**
* @brief Sets velocity scale value
*
* @param hContext The X<sup>e</sup>SS context handle.
* @param x scale for the X axis
* @param y scale for the Y axis
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessSetVelocityScale(xess_context_handle_t hContext, float x, float y);
/**
* @brief Sets exposure scale value
*
* This value will be applied on top of any passed exposure value or automatically calculated exposure.
*
* @param hContext The X<sup>e</sup>SS context handle.
* @param scale scale value.
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessSetExposureMultiplier(xess_context_handle_t hContext, float scale);
/**
* @brief Gets exposure scale value
*
* @param hContext The X<sup>e</sup>SS context handle.
* @param[out] pScale Exposure scale pointer.
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessGetExposureMultiplier(xess_context_handle_t hContext, float *pScale);
/**
* @brief Sets logging callback
*
* @param hContext The X<sup>e</sup>SS context handle.
* @param loggingLevel Minimum logging level for logging callback.
* @param loggingCallback Logging callback
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessSetLoggingCallback(xess_context_handle_t hContext,
xess_logging_level_t loggingLevel, xess_app_log_callback_t loggingCallback);
/**
* @brief Indicates if the installed driver supports best X<sup>e</sup>SS experience.
*
* @param hContext The X<sup>e</sup>SS context handle.
* @return xessIsOptimalDriver returns XESS_RESULT_SUCCESS, or XESS_RESULT_WARNING_OLD_DRIVER
* if installed driver may result in degraded performance or visual quality.
* xessD3D12CreateContext(..) will return XESS_RESULT_ERROR_UNSUPPORTED_DRIVER if driver does
* not support X<sup>e</sup>SS at all.
*/
XESS_API xess_result_t xessIsOptimalDriver(xess_context_handle_t hContext);
/**
* @brief Forces usage of legacy (pre 1.3.0) scale factors
*
* Following scale factors will be appied:
* @li XESS_QUALITY_SETTING_ULTRA_PERFORMANCE: 3.0
* @li XESS_QUALITY_SETTING_PERFORMANCE: 2.0
* @li XESS_QUALITY_SETTING_BALANCED: 1.7
* @li XESS_QUALITY_SETTING_QUALITY: 1.5
* @li XESS_QUALITY_SETTING_ULTRA_QUALITY: 1.3
* @li XESS_QUALITY_SETTING_AA: 1.0
* In order to apply new scale factors application should call xessGetOptimalInputResolution and
* initialization function (xess*Init)
*
* @param hContext The X<sup>e</sup>SS context handle.
* @param force if set to true legacy scale factors will be forced, if set to false - scale factors
* will be selected by X<sup>e</sup>SS
*
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessForceLegacyScaleFactors(xess_context_handle_t hContext, bool force);
/** @}*/
#endif
// Enum size checks. All enums must be 4 bytes
typedef char sizecheck__LINE__[ (sizeof(xess_quality_settings_t) == 4) ? 1 : -1];
typedef char sizecheck__LINE__[ (sizeof(xess_init_flags_t) == 4) ? 1 : -1];
typedef char sizecheck__LINE__[ (sizeof(xess_result_t) == 4) ? 1 : -1];
typedef char sizecheck__LINE__[ (sizeof(xess_logging_level_t) == 4) ? 1 : -1];
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,193 @@
/*******************************************************************************
* Copyright (C) 2021 Intel Corporation
*
* This software and the related documents are Intel copyrighted materials, and
* your use of them is governed by the express license under which they were
* provided to you ("License"). Unless the License provides otherwise, you may
* not use, modify, copy, publish, distribute, disclose or transmit this
* software or the related documents without Intel's prior written permission.
*
* This software and the related documents are provided as is, with no express
* or implied warranties, other than those that are expressly stated in the
* License.
******************************************************************************/
#ifndef XESS_D3D12_H
#define XESS_D3D12_H
#include <d3d12.h>
#include "xess.h"
#ifdef __cplusplus
extern "C" {
#endif
XESS_PACK_B()
/**
* @brief Execution parameters for X<sup>e</sup>SS D3D12.
*/
typedef struct _xess_d3d12_execute_params_t
{
/** Input color texture. Must be in NON_PIXEL_SHADER_RESOURCE state.*/
ID3D12Resource *pColorTexture;
/** Input motion vector texture. Must be in NON_PIXEL_SHADER_RESOURCE state.*/
ID3D12Resource *pVelocityTexture;
/** Optional depth texture. Required if XESS_INIT_FLAG_HIGH_RES_MV has not been specified.
* Must be in NON_PIXEL_SHADER_RESOURCE state.*/
ID3D12Resource *pDepthTexture;
/** Optional 1x1 exposure scale texture. Required if XESS_INIT_FLAG_EXPOSURE_TEXTURE has been
* specified. Must be in NON_PIXEL_SHADER_RESOURCE state */
ID3D12Resource *pExposureScaleTexture;
/** Optional responsive pixel mask texture. Required if XESS_INIT_FLAG_RESPONSIVE_PIXEL_MASK
* has been specified. Must be in NON_PIXEL_SHADER_RESOURCE state */
ID3D12Resource *pResponsivePixelMaskTexture;
/** Output texture in target resolution. Must be in UNORDERED_ACCESS state.*/
ID3D12Resource *pOutputTexture;
/** Jitter X coordinate in the range [-0.5, 0.5]. */
float jitterOffsetX;
/** Jitter Y coordinate in the range [-0.5, 0.5]. */
float jitterOffsetY;
/** Optional input color scaling. Default is 1. */
float ExposureScale;
/** Resets the history accumulation in this frame. */
uint32_t ResetHistory;
/** Input color width. */
uint32_t inputWidth;
/** Input color height. */
uint32_t inputHeight;
/** Base coordinate for the input color in the texture. Default is (0,0). */
xess_coord_t inputColorBase;
/** Base coordinate for the input motion vector in the texture. Default is (0,0). */
xess_coord_t inputMotionVectorBase;
/** Base coordinate for the input depth in the texture. Default is (0,0). */
xess_coord_t inputDepthBase;
/** Base coordinate for the input responsive pixel mask in the texture. Default is (0,0). */
xess_coord_t inputResponsiveMaskBase;
/** Reserved parameter. */
xess_coord_t reserved0;
/** Base coordinate for the output color. Default is (0,0). */
xess_coord_t outputColorBase;
/** Optional external descriptor heap. */
ID3D12DescriptorHeap* pDescriptorHeap;
/** Offset in external descriptor heap in bytes.*/
uint32_t descriptorHeapOffset;
} xess_d3d12_execute_params_t;
XESS_PACK_E()
XESS_PACK_B()
/**
* @brief Initialization parameters for X<sup>e</sup>SS D3D12.
*/
typedef struct _xess_d3d12_init_params_t
{
/** Output width and height. */
xess_2d_t outputResolution;
/** Quality setting */
xess_quality_settings_t qualitySetting;
/** Initialization flags. */
uint32_t initFlags;
/** Specifies the node mask for internally created resources on
* multi-adapter systems. */
uint32_t creationNodeMask;
/** Specifies the node visibility mask for internally created resources
* on multi-adapter systems. */
uint32_t visibleNodeMask;
/** Optional externally allocated buffer storage for X<sup>e</sup>SS. If NULL the
* storage is allocated internally. If allocated, the heap type must be
* D3D12_HEAP_TYPE_DEFAULT. This heap is not accessed by the CPU. */
ID3D12Heap* pTempBufferHeap;
/** Offset in the externally allocated heap for temporary buffer storage. */
uint64_t bufferHeapOffset;
/** Optional externally allocated texture storage for X<sup>e</sup>SS. If NULL the
* storage is allocated internally. If allocated, the heap type must be
* D3D12_HEAP_TYPE_DEFAULT. This heap is not accessed by the CPU. */
ID3D12Heap* pTempTextureHeap;
/** Offset in the externally allocated heap for temporary texture storage. */
uint64_t textureHeapOffset;
/** Pointer to pipeline library. If not NULL will be used for pipeline caching. */
ID3D12PipelineLibrary *pPipelineLibrary;
} xess_d3d12_init_params_t;
XESS_PACK_E()
/** @addtogroup xess-d3d12 XeSS D3D12 API exports
* @{
*/
/**
* @brief Create an X<sup>e</sup>SS D3D12 context.
* @param pDevice: A D3D12 device created by the user.
* @param[out] phContext: Returned xess context handle.
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessD3D12CreateContext(
ID3D12Device* pDevice, xess_context_handle_t* phContext);
/**
* @brief Initiates pipeline build process
* This function can only be called between @ref xessD3D12CreateContext and
* @ref xessD3D12Init
* This call initiates build of DX12 pipelines and kernel compilation
* This call can be blocking (if @p blocking set to true) or non-blocking.
* In case of non-blocking call library will wait for pipeline build on call to
* @ref xessD3D12Init
* If @p pPipelineLibrary passed to this call - same pipeline library must be passed
* to @ref xessD3D12Init
*
* @param hContext The X<sup>e</sup>SS context handle.
* @param pPipelineLibrary Optional pointer to pipeline library for pipeline caching.
* @param blocking Wait for kernel compilation and pipeline creation to finish or not
* @param initFlags Initialization flags. *Must* be identical to flags passed to @ref xessD3D12Init
*/
XESS_API xess_result_t xessD3D12BuildPipelines(xess_context_handle_t hContext,
ID3D12PipelineLibrary *pPipelineLibrary, bool blocking, uint32_t initFlags);
/**
* @brief Initialize X<sup>e</sup>SS D3D12.
* This is a blocking call that initializes X<sup>e</sup>SS and triggers internal
* resources allocation and JIT for the X<sup>e</sup>SS kernels. The user must ensure that
* any pending command lists are completed before re-initialization. When
* During initialization, X<sup>e</sup>SS can create staging buffers and copy queues to
* upload internal data. These will be destroyed at the end of initialization.
*
* @note X<sup>e</sup>SS supports devices starting from D3D12_RESOURCE_HEAP_TIER_1, which means
* that buffers and textures can not live in the same resource heap.
*
* @param hContext: The X<sup>e</sup>SS context handle.
* @param pInitParams: Initialization parameters.
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessD3D12Init(
xess_context_handle_t hContext, const xess_d3d12_init_params_t* pInitParams);
/**
* @brief Get X<sup>e</sup>SS D3D12 initialization parameters.
*
* @note This function will return @ref XESS_RESULT_ERROR_UNINITIALIZED if @ref xessD3D12Init has not been called.
*
* @param hContext: The X<sup>e</sup>SS context handle.
* @param[out] pInitParams: Returned initialization parameters.
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessD3D12GetInitParams(
xess_context_handle_t hContext, xess_d3d12_init_params_t* pInitParams);
/**
* @brief Record X<sup>e</sup>SS upscaling commands into the command list.
* @param hContext: The X<sup>e</sup>SS context handle.
* @param pCommandList: The command list for X<sup>e</sup>SS commands.
* @param pExecParams: Execution parameters.
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessD3D12Execute(xess_context_handle_t hContext,
ID3D12GraphicsCommandList* pCommandList, const xess_d3d12_execute_params_t* pExecParams);
/** @}*/
#ifdef __cplusplus
}
#endif
#endif // XESS_D3D12_H

View File

@ -0,0 +1,129 @@
/*******************************************************************************
* Copyright (C) 2021 Intel Corporation
*
* This software and the related documents are Intel copyrighted materials, and
* your use of them is governed by the express license under which they were
* provided to you ("License"). Unless the License provides otherwise, you may
* not use, modify, copy, publish, distribute, disclose or transmit this
* software or the related documents without Intel's prior written permission.
*
* This software and the related documents are provided as is, with no express
* or implied warranties, other than those that are expressly stated in the
* License.
******************************************************************************/
#ifndef XESS_D3D12_DEBUG_H
#define XESS_D3D12_DEBUG_H
#include <d3d12.h>
#include "xess.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef XESS_D3D12_DEBUG_ENABLE_PROFILING
#define XESS_D3D12_DEBUG_ENABLE_PROFILING (1U << 30)
#endif
XESS_PACK_B()
typedef struct _xess_resources_to_dump_t
{
/** Total resource count. In case it equal to zero content of other structure members is undefined.*/
uint32_t resource_count;
/** Pointer to an internal array of D3D12 resources. Array length is `resource_count`.*/
ID3D12Resource* const* resources;
/** Pointer to an internal array of D3D12 resource names. Array length is `resource_count`.*/
const char* const* resource_names;
/* Pointer to an internal array of suggested resource dump modes. Array length is `resource_count.`
* If as_tensor is 0 (FALSE), then it is suggested to dump resource as RGBA texture.*/
const uint32_t* as_tensor; // 0 = false
/* Pointer to an internal array of paddings to be used during resource dump. Array length is `resource_count`.
* Padding is assumed to be symmetrical across spatial dimensions and has same value for both borders in each dimension.*/
const uint32_t* border_pixels_to_skip_count;
/* Pointer to an internal array of channel count for each resource. If resource dimension is "buffer" value is non zero,
* count is zero otherwise. Array length is `resource_count`.*/
const uint32_t* tensor_channel_count;
/* Pointer to an internal array of tensor width for each resource. Width must include padding on both sides.
* If resource dimension is "buffer" value is non zero, * count is zero otherwise. Array length is `resource_count`.*/
const uint32_t* tensor_width;
/* Pointer to an internal array of tensor width for each resource. Height must include padding on both sides.
* If resource dimension is "buffer" value is non zero, * count is zero otherwise. Array length is `resource_count`.*/
const uint32_t* tensor_height;
} xess_resources_to_dump_t;
XESS_PACK_E()
XESS_PACK_B()
typedef struct _xess_profiled_frame_data_t
{
/** Execution index in context's instance. */
uint64_t frame_index;
/** Total labeled gpu duration records stored in gpu_duration* arrays.*/
uint64_t gpu_duration_record_count;
/** Pointer to an internal array of duration names.*/
const char* const* gpu_duration_names;
/** Pointer to an internal array of duration values. [seconds]*/
const double* gpu_duration_values;
} xess_profiled_frame_data_t;
XESS_PACK_E()
XESS_PACK_B()
typedef struct _xess_profiling_data_t
{
/** Total profiled frame records storage in frames/executions array.*/
uint64_t frame_count;
/** Pointers to an internal storage with per frame/execution data.*/
xess_profiled_frame_data_t* frames;
/** Flag indicating if more profiling data will be available when GPU finishes
* executing submitted frames.
* Useful to collect profiling data without forcing full CPU-GPU sync.
* Zero value indicates no pending profiling data.
*/
uint32_t any_profiling_data_in_flight;
} xess_profiling_data_t;
XESS_PACK_E()
/** @addtogroup xess-d3d12-debug XeSS D3D12 API debug exports
* @{
*/
/**
* @brief Query X<sup>e</sup>SS model to retrieve internal resources marked for dumping for further
* debug and inspection.
* @param hContext: The X<sup>e</sup>SS context handle.
* @param pResourcesToDump: Pointer to user-provided pointer to structure to be filled with
* debug resource array, their names and recommended dumping parameters. pResourcesToDump must not be null,
* In case of failure (xess_result_t is not equal to XESS_RESULT_SUCCESS) **pResourcesToDump contents is undefined and must not be used.
* In case of success, *pResourcesToDump may still be null, if no internal resources were added to dumping queue.
* Build configuration for certain implementations may have dumping functionality compiled-out and XESS_RESULT_ERROR_NOT_IMPLEMENTED return code.
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessD3D12GetResourcesToDump(xess_context_handle_t hContext, xess_resources_to_dump_t** pResourcesToDump);
/**
* @brief Query X<sup>e</sup>SS model performance data for past executions. To enable performance collection,
* context must be initialized with XESS_D3D12_DEBUG_ENABLE_PROFILING flag added to xess_d3d12_init_params_t::initFlags.
* If profiling is enabled, user must poll for profiling data after executing one or more command lists, otherwise
* implementation will keep growing internal CPU buffers to accommodate all profiling data available.
* Due to async nature of execution on GPU, data may not be available after submitting command lists to device queue.
* It is advised to check `any_profiling_data_in_flight` flag in case all workloads has been submitted, but profiling
* data for some frames is still not available.
* Data pointed to by pProfilingData item(s) belongs to context instance and
* is valid until next call to xessD3D12GetProfilingData for owning context.
* @param hContext: The X<sup>e</sup>SS context handle.
* @param pProfilingData: pointer to profiling data structure to be filled by implementation.
* @return X<sup>e</sup>SS return status code.
*/
XESS_API xess_result_t xessD3D12GetProfilingData(xess_context_handle_t hContext, xess_profiling_data_t** pProfilingData);
/** @}*/
#ifdef __cplusplus
}
#endif
#endif // XESS_D3D12_H

View File

@ -0,0 +1,127 @@
/*******************************************************************************
* Copyright (C) 2021 Intel Corporation
*
* This software and the related documents are Intel copyrighted materials, and
* your use of them is governed by the express license under which they were
* provided to you ("License"). Unless the License provides otherwise, you may
* not use, modify, copy, publish, distribute, disclose or transmit this
* software or the related documents without Intel's prior written permission.
*
* This software and the related documents are provided as is, with no express
* or implied warranties, other than those that are expressly stated in the
* License.
******************************************************************************/
#ifndef XESS_DEBUG_H
#define XESS_DEBUG_H
#include "xess.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief X<sup>e</sup>SS network type.
*/
typedef enum _xess_network_model_t
{
XESS_NETWORK_MODEL_KPSS = 0,
XESS_NETWORK_MODEL_SPLAT = 1,
XESS_NETWORK_MODEL_3 = 2,
XESS_NETWORK_MODEL_4 = 3,
XESS_NETWORK_MODEL_5 = 4,
XESS_NETWORK_MODEL_6 = 5,
XESS_NETWORK_MODEL_UNKNOWN = 0x7FFFFFFF,
} xess_network_model_t;
typedef enum _xess_dump_element_bits_t
{
XESS_DUMP_INPUT_COLOR = 0x01,
XESS_DUMP_INPUT_VELOCITY = 0x02,
XESS_DUMP_INPUT_DEPTH = 0x04,
XESS_DUMP_INPUT_EXPOSURE_SCALE = 0x08,
XESS_DUMP_INPUT_RESPONSIVE_PIXEL_MASK = 0x10,
XESS_DUMP_OUTPUT = 0x20,
XESS_DUMP_HISTORY = 0x40,
XESS_DUMP_EXECUTION_PARAMETERS = 0x80, ///< All parameters passed to xessExecute
XESS_DUMP_ALL_INPUTS = XESS_DUMP_INPUT_COLOR | XESS_DUMP_INPUT_VELOCITY |
XESS_DUMP_INPUT_DEPTH | XESS_DUMP_INPUT_EXPOSURE_SCALE |
XESS_DUMP_INPUT_RESPONSIVE_PIXEL_MASK | XESS_DUMP_EXECUTION_PARAMETERS,
XESS_DUMP_ALL = 0x7FFFFFFF,
} xess_dump_element_bits_t;
typedef uint32_t xess_dump_elements_mask_t;
XESS_PACK_B()
typedef struct _xess_dump_parameters_t
{
/**
* NULL-terminated ASCII string to *existing folder* where dump files should be written.
* Library do not create the folder.
* Files in provided folder will be overwritten.
*/
const char *path;
/** Frame index. Will be used as start for frame sequence. */
uint32_t frame_idx;
/** Frame count to dump. Few frames less may be dumped due to possible frames in flight in
* application
*/
uint32_t frame_count;
/** Bitset showing set of elements that must be dumped. Element will be dumped if it exists
* and corresponding bit is not 0.
* Since it's meaningless to call Dump with empty set value of 0 will mean DUMP_ALL_INPUTS
*/
xess_dump_elements_mask_t dump_elements_mask;
/** In case of depth render target with TYPELESS format it is not always possible
* to interpret depth values during dumping process.
*/
} xess_dump_parameters_t;
XESS_PACK_E()
/** @addtogroup xess-debug XeSS API debug exports
* @{
*/
/**
* @brief Select network to be used by X<sup>e</sup>SS
*
* Selects network model to use by X<sup>e</sup>SS.
* After call to this function - X<sup>e</sup>SS init function *must* be called
*/
XESS_API xess_result_t xessSelectNetworkModel(xess_context_handle_t hContext, xess_network_model_t network);
/**
* @brief Dumps sequence of frames to the provided folder
*
* Call to this function initiates a dump for selected elements.
* X<sup>e</sup>SS SDK uses RAM cache to reduce dump overhead. Application should provide reasonable
* value for @ref xess_dump_parameters_t::frame_count frames (about 50 megs needed per cached frame).
* To enable several dumps per run application should provide correct
* @ref xess_dump_parameters_t::frame_idx value. This value used as a start index for frame
* dumping.
* After call to this function - each call to @ref xessD3D12Execute will result in new frame dumped to
* RAM cache.
* After @ref xess_dump_parameters_t::frame_count frames application will be blocked on call to
* @ref xessD3D12Execute in order to save cached frames to disk. This operation can take long time.
* Repetitive calls to this function can result in XESS_RESULT_ERROR_OPERATION_IN_PROGRESS which means that
* frame dump is in progress.
*
* @param hContext X<sup>e</sup>SS context
* @param dump_parameters dump configuration
* @return operation status
*/
XESS_API xess_result_t xessStartDump(xess_context_handle_t hContext, const xess_dump_parameters_t *dump_parameters);
/** @}*/
// Enum size checks. All enums must be 4 bytes
typedef char sizecheck__LINE__[ (sizeof(xess_network_model_t) == 4) ? 1 : -1];
typedef char sizecheck__LINE__[ (sizeof(xess_dump_element_bits_t) == 4) ? 1 : -1];
#ifdef __cplusplus
}
#endif
#endif

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,270 @@
#include "xess1/xess.h"
#include "xess/xess_d3d12_debug.h"
static std::function<void(const char*)>log_func = {};
const char *ResultToString(xess_result_t result)
{
switch (result)
{
case XESS_RESULT_WARNING_NONEXISTING_FOLDER:
return "Warning Nonexistent Folder";
case XESS_RESULT_WARNING_OLD_DRIVER:
return "Warning Old Driver";
case XESS_RESULT_SUCCESS:
return "Success";
case XESS_RESULT_ERROR_UNSUPPORTED_DEVICE:
return "Unsupported Device";
case XESS_RESULT_ERROR_UNSUPPORTED_DRIVER:
return "Unsupported Driver";
case XESS_RESULT_ERROR_UNINITIALIZED:
return "Uninitialized";
case XESS_RESULT_ERROR_INVALID_ARGUMENT:
return "Invalid Argument";
case XESS_RESULT_ERROR_DEVICE_OUT_OF_MEMORY:
return "Device Out of Memory";
case XESS_RESULT_ERROR_DEVICE:
return "Device Error";
case XESS_RESULT_ERROR_NOT_IMPLEMENTED:
return "Not Implemented";
case XESS_RESULT_ERROR_INVALID_CONTEXT:
return "Invalid Context";
case XESS_RESULT_ERROR_OPERATION_IN_PROGRESS:
return "Operation in Progress";
case XESS_RESULT_ERROR_UNSUPPORTED:
return "Unsupported";
case XESS_RESULT_ERROR_CANT_LOAD_LIBRARY:
return "Cannot Load Library";
case XESS_RESULT_ERROR_UNKNOWN:
default:
return "Unknown";
}
}
void LogCallback(const char* msg, xess_logging_level_t level)
{
if (level >= xess_logging_level_t::XESS_LOGGING_LEVEL_WARNING)
{
log_func(msg);
}
}
bool XessV13::enable(std::function<void(const char*)> log_cb)
{
if (inited)
{
return true;
}
log_func = log_cb;
xess_version_t ver;
xess_result_t ret = xessGetVersion(&ver);
if (ret != XESS_RESULT_SUCCESS)
{
log_func(ResultToString(ret));
return false;
}
char buf[128];
sprintf_s(buf, "XeSS: Version -%u.%u.%u", ver.major, ver.minor, ver.patch);
log_func(buf);
ret = xessD3D12CreateContext(device, &xess_context);
if (ret != XESS_RESULT_SUCCESS || !xess_context)
{
xess_context = nullptr;
log_func(ResultToString(ret));
return false;
}
if (XESS_RESULT_WARNING_OLD_DRIVER == xessIsOptimalDriver(xess_context))
{
log_func("Important notice: Please install the latest graphics driver from your vendor for optimal Intel(R) XeSS performance and visual quality.");
}
ret = xessSetLoggingCallback(xess_context, XESS_LOGGING_LEVEL_DEBUG, LogCallback);
if (ret != XESS_RESULT_SUCCESS)
{
log_func(ResultToString(ret));
return false;
}
log_func("xessD3D12CreateContext done");
xessForceLegacyScaleFactors(xess_context, false);
return true;
}
void XessV13::disable()
{
if (!inited)
{
return;
}
xessDestroyContext(xess_context);
log_func("xessDestroyContext done");
xess_context = nullptr;
inited = false;
}
struct Xess1ConfigParam
{
uint32_t OutputWidth;
/// Output buffer height.
uint32_t OutputHeight;
/// Quality level of XeSS.
int Quality;
/// If we are in High-Res motion vectors mode.
bool UseHiResMotionVectors;
/// If motion vectors are jittered.
bool UseJitteredMotionVectors;
/// If motion vectors are in Normalized Device Coordinate (NDC).
bool UseMotionVectorsInNDC;
/// If use exposure texture.
bool UseExposureTexture;
/// If use responsive mask.
bool UseResponsiveMask;
/// If use auto exposure.
bool UseAutoExposure;
/// If enable GPU profiling.
bool EnableProfiling;
float VelocityScaleX;
float VelocityScaleY;
float JitterScaleX;
float JitterScaleY;
float ExposureScale;
};
struct Xess1ExecParam
{
float Jitterx;
float Jittery;
int InputWidth;
int InputHeight;
bool ResetHistory;
float ExposureScale;
void* ColorTexture;
void* VelocityTexture;
void* OutputTexture;
};
bool XessV13::configxess(void* data)
{
xess_d3d12_init_params_t params{};
Xess1ConfigParam* config = (Xess1ConfigParam*)data;
params.outputResolution.x = config->OutputWidth;
params.outputResolution.y = config->OutputHeight;
params.qualitySetting = (xess_quality_settings_t)config->Quality;
params.initFlags = config->UseHiResMotionVectors ? XESS_INIT_FLAG_HIGH_RES_MV : 0;
if (config->UseJitteredMotionVectors)
{
params.initFlags |= XESS_INIT_FLAG_JITTERED_MV;
}
if (config->UseMotionVectorsInNDC)
{
params.initFlags |= XESS_INIT_FLAG_USE_NDC_VELOCITY;
}
if (config->UseExposureTexture)
{
params.initFlags |= XESS_INIT_FLAG_EXPOSURE_SCALE_TEXTURE;
}
if (config->UseResponsiveMask)
{
params.initFlags |= XESS_INIT_FLAG_RESPONSIVE_PIXEL_MASK;
}
if (config->UseAutoExposure)
{
params.initFlags |= XESS_INIT_FLAG_ENABLE_AUTOEXPOSURE;
}
if (config->EnableProfiling)
{
params.initFlags |= XESS_D3D12_DEBUG_ENABLE_PROFILING;
}
params.pPipelineLibrary = nullptr;
log_func("xessD3D12Init");
xess_result_t ret = xessD3D12Init(xess_context, &params);
if (ret != XESS_RESULT_SUCCESS)
{
log_func(ResultToString(ret));
return false;
}
log_func("xessD3D12Init done");
ret = xessSetVelocityScale(xess_context, config->VelocityScaleX, config->VelocityScaleY);
if (ret != XESS_RESULT_SUCCESS)
{
log_func(ResultToString(ret));
return false;
}
ret = xessSetJitterScale(xess_context, config->JitterScaleX, config->JitterScaleY);
if (ret != XESS_RESULT_SUCCESS)
{
log_func(ResultToString(ret));
return false;
}
ret = xessSetExposureMultiplier(xess_context, config->ExposureScale);
if (ret != XESS_RESULT_SUCCESS)
{
log_func(ResultToString(ret));
return false;
}
inited = true;
return true;
}
void XessV13::execute(void* data, ID3D12GraphicsCommandList* cmd_list)
{
Xess1ExecParam* param = (Xess1ExecParam*)data;
xess_d3d12_execute_params_t params{};
params.jitterOffsetX = param->Jitterx;
params.jitterOffsetY = param->Jittery;
params.inputWidth = param->InputWidth;
params.inputHeight = param->InputHeight;
params.ResetHistory = param->ResetHistory ? 1 : 0;
params.ExposureScale = param->ExposureScale;
params.pColorTexture = (ID3D12Resource*)param->ColorTexture;
params.pVelocityTexture = (ID3D12Resource*)param->VelocityTexture;
params.pOutputTexture = (ID3D12Resource*)param->OutputTexture;
params.pDepthTexture = nullptr;
params.pExposureScaleTexture = nullptr;
params.pResponsivePixelMaskTexture = nullptr;
//params.pDepthTexture = m_InitArguments.UseHiResMotionVectors ? nullptr : Execonfig->DepthTexture->GetResource();
//params.pExposureScaleTexture = !m_InitArguments.UseExposureTexture ? nullptr : Execonfig->ExposureTexture->GetResource();
//params.pResponsivePixelMaskTexture = !m_InitArguments.UseResponsiveMask ? nullptr : Execonfig->ResponsiveMask->GetResource();
xess_result_t ret = xessD3D12Execute(xess_context, cmd_list, &params);
if (ret != XESS_RESULT_SUCCESS)
{
static bool s_Reported = false;
if (!s_Reported)
{
s_Reported = true;
log_func(ResultToString(ret));
}
}
}
bool XessV13::get_input_resolution(uint32_t outw, uint32_t outh, int quality,uint32_t& Width, uint32_t& Height)
{
xess_2d_t inputRes = { 1, 1 };
xess_2d_t outputRes = { outw, outh };
xess_result_t ret = xessGetInputResolution(xess_context, &outputRes, (xess_quality_settings_t) quality, &inputRes);
if (ret != XESS_RESULT_SUCCESS)
{
log_func(ResultToString(ret));
return false;
}
Width = inputRes.x;
Height = inputRes.y;
return true;
}

View File

@ -0,0 +1,38 @@
#pragma once
#if SUPPORT_D3D12
#include <functional>
#include <d3d12.h>
#include "xess/xess.h"
#include "xess/xess_d3d12.h"
enum XessQuality
{
UltraPerformance = 100,
Performance = 101,
Balanced = 102,
Quality = 103,
UltraQuality = 104,
UltraQualityPlus = 105,
NativeAA = 106,
};
struct XessV13 final
{
XessV13(ID3D12Device* device) : device(device), inited(false), xess_context(nullptr) {}
~XessV13() = default;
bool enable(std::function<void(const char*)> log_cb);
void disable();
bool configxess(void* data);
void execute(void* data, ID3D12GraphicsCommandList* cmd_list);
bool get_input_resolution(uint32_t outw, uint32_t outh, int quality, uint32_t& Width, uint32_t& Height);
private:
ID3D12Device* device;
xess_context_handle_t xess_context;
bool inited;
};
#endif

View File

@ -2762,16 +2762,16 @@ GLAPI void APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height)
typedef void (APIENTRYP PFNGLCULLFACEPROC) (GLenum mode);
typedef void (APIENTRYP PFNGLFRONTFACEPROC) (GLenum mode);
typedef void (APIENTRYP PFNGLHINTPROC) (GLenum target, GLenum mode);
typedef void (APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat width);
typedef void (APIENTRYP PFNGLLINEWIDTHPROC) (GLfloat InputWidth);
typedef void (APIENTRYP PFNGLPOINTSIZEPROC) (GLfloat size);
typedef void (APIENTRYP PFNGLPOLYGONMODEPROC) (GLenum face, GLenum mode);
typedef void (APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
typedef void (APIENTRYP PFNGLSCISSORPROC) (GLint x, GLint y, GLsizei InputWidth, GLsizei InputHeight);
typedef void (APIENTRYP PFNGLTEXPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat param);
typedef void (APIENTRYP PFNGLTEXPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
typedef void (APIENTRYP PFNGLTEXPARAMETERIPROC) (GLenum target, GLenum pname, GLint param);
typedef void (APIENTRYP PFNGLTEXPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
typedef void (APIENTRYP PFNGLTEXIMAGE1DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (APIENTRYP PFNGLTEXIMAGE1DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei InputWidth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (APIENTRYP PFNGLTEXIMAGE2DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei InputWidth, GLsizei InputHeight, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (APIENTRYP PFNGLDRAWBUFFERPROC) (GLenum mode);
typedef void (APIENTRYP PFNGLCLEARPROC) (GLbitfield mask);
typedef void (APIENTRYP PFNGLCLEARCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
@ -2792,7 +2792,7 @@ typedef void (APIENTRYP PFNGLDEPTHFUNCPROC) (GLenum func);
typedef void (APIENTRYP PFNGLPIXELSTOREFPROC) (GLenum pname, GLfloat param);
typedef void (APIENTRYP PFNGLPIXELSTOREIPROC) (GLenum pname, GLint param);
typedef void (APIENTRYP PFNGLREADBUFFERPROC) (GLenum mode);
typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels);
typedef void (APIENTRYP PFNGLREADPIXELSPROC) (GLint x, GLint y, GLsizei InputWidth, GLsizei InputHeight, GLenum format, GLenum type, GLvoid *pixels);
typedef void (APIENTRYP PFNGLGETBOOLEANVPROC) (GLenum pname, GLboolean *params);
typedef void (APIENTRYP PFNGLGETDOUBLEVPROC) (GLenum pname, GLdouble *params);
typedef GLenum (APIENTRYP PFNGLGETERRORPROC) (void);
@ -2806,7 +2806,7 @@ typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERFVPROC) (GLenum target, GLint l
typedef void (APIENTRYP PFNGLGETTEXLEVELPARAMETERIVPROC) (GLenum target, GLint level, GLenum pname, GLint *params);
typedef GLboolean (APIENTRYP PFNGLISENABLEDPROC) (GLenum cap);
typedef void (APIENTRYP PFNGLDEPTHRANGEPROC) (GLdouble near, GLdouble far);
typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei width, GLsizei height);
typedef void (APIENTRYP PFNGLVIEWPORTPROC) (GLint x, GLint y, GLsizei InputWidth, GLsizei InputHeight);
#endif
#ifndef GL_VERSION_1_1
@ -2831,12 +2831,12 @@ typedef void (APIENTRYP PFNGLDRAWARRAYSPROC) (GLenum mode, GLint first, GLsizei
typedef void (APIENTRYP PFNGLDRAWELEMENTSPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
typedef void (APIENTRYP PFNGLGETPOINTERVPROC) (GLenum pname, GLvoid* *params);
typedef void (APIENTRYP PFNGLPOLYGONOFFSETPROC) (GLfloat factor, GLfloat units);
typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei InputWidth, GLint border);
typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei InputWidth, GLsizei InputHeight, GLint border);
typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei InputWidth);
typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei InputWidth, GLsizei InputHeight);
typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei InputWidth, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei InputWidth, GLsizei InputHeight, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (APIENTRYP PFNGLBINDTEXTUREPROC) (GLenum target, GLuint texture);
typedef void (APIENTRYP PFNGLDELETETEXTURESPROC) (GLsizei n, const GLuint *textures);
typedef void (APIENTRYP PFNGLGENTEXTURESPROC) (GLsizei n, GLuint *textures);
@ -2856,9 +2856,9 @@ GLAPI void APIENTRY glCopyTexSubImage3D (GLenum target, GLint level, GLint xoffs
typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei InputWidth, GLsizei InputHeight, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei InputWidth, GLsizei InputHeight, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei InputWidth, GLsizei InputHeight);
#endif
#ifndef GL_VERSION_1_3
@ -2876,12 +2876,12 @@ GLAPI void APIENTRY glGetCompressedTexImage (GLenum target, GLint level, GLvoid
#endif /* GLCOREARB_PROTOTYPES */
typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLfloat value, GLboolean invert);
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei InputWidth, GLsizei InputHeight, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei InputWidth, GLsizei InputHeight, GLint border, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei InputWidth, GLint border, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei InputWidth, GLsizei InputHeight, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei InputWidth, GLsizei InputHeight, GLenum format, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei InputWidth, GLenum format, GLsizei imageSize, const GLvoid *data);
typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img);
#endif
@ -3451,7 +3451,7 @@ typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer);
typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer);
typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers);
typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers);
typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei InputWidth, GLsizei InputHeight);
typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer);
typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer);
@ -3465,7 +3465,7 @@ typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum
typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target);
typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei InputWidth, GLsizei InputHeight);
typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
#endif
@ -3599,8 +3599,8 @@ GLAPI void APIENTRY glTexImage3DMultisample (GLenum target, GLsizei samples, GLi
GLAPI void APIENTRY glGetMultisamplefv (GLenum pname, GLuint index, GLfloat *val);
GLAPI void APIENTRY glSampleMaski (GLuint index, GLbitfield mask);
#endif /* GLCOREARB_PROTOTYPES */
typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei InputWidth, GLsizei InputHeight, GLboolean fixedsamplelocations);
typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei InputWidth, GLsizei InputHeight, GLsizei depth, GLboolean fixedsamplelocations);
typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val);
typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask);
#endif
@ -4147,7 +4147,7 @@ typedef void (APIENTRYP PFNGLVIEWPORTARRAYVPROC) (GLuint first, GLsizei count, c
typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat w, GLfloat h);
typedef void (APIENTRYP PFNGLVIEWPORTINDEXEDFVPROC) (GLuint index, const GLfloat *v);
typedef void (APIENTRYP PFNGLSCISSORARRAYVPROC) (GLuint first, GLsizei count, const GLint *v);
typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height);
typedef void (APIENTRYP PFNGLSCISSORINDEXEDPROC) (GLuint index, GLint left, GLint bottom, GLsizei InputWidth, GLsizei InputHeight);
typedef void (APIENTRYP PFNGLSCISSORINDEXEDVPROC) (GLuint index, const GLint *v);
typedef void (APIENTRYP PFNGLDEPTHRANGEARRAYVPROC) (GLuint first, GLsizei count, const GLdouble *v);
typedef void (APIENTRYP PFNGLDEPTHRANGEINDEXEDPROC) (GLuint index, GLdouble n, GLdouble f);
@ -4191,7 +4191,7 @@ GLAPI void APIENTRY glGetnUniformdvARB (GLuint program, GLint location, GLsizei
#endif /* GLCOREARB_PROTOTYPES */
typedef GLenum (APIENTRYP PFNGLGETGRAPHICSRESETSTATUSARBPROC) (void);
typedef void (APIENTRYP PFNGLGETNTEXIMAGEARBPROC) (GLenum target, GLint level, GLenum format, GLenum type, GLsizei bufSize, GLvoid *img);
typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data);
typedef void (APIENTRYP PFNGLREADNPIXELSARBPROC) (GLint x, GLint y, GLsizei InputWidth, GLsizei InputHeight, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data);
typedef void (APIENTRYP PFNGLGETNCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLsizei bufSize, GLvoid *img);
typedef void (APIENTRYP PFNGLGETNUNIFORMFVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLfloat *params);
typedef void (APIENTRYP PFNGLGETNUNIFORMIVARBPROC) (GLuint program, GLint location, GLsizei bufSize, GLint *params);
@ -4281,12 +4281,12 @@ GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsize
GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
#endif /* GLCOREARB_PROTOTYPES */
typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei InputWidth);
typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei InputWidth, GLsizei InputHeight);
typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei InputWidth, GLsizei InputHeight, GLsizei depth);
typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei InputWidth);
typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei InputWidth, GLsizei InputHeight);
typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei InputWidth, GLsizei InputHeight, GLsizei depth);
#endif
#ifndef GL_KHR_texture_compression_astc_ldr
@ -4441,12 +4441,12 @@ GLAPI void APIENTRY glInvalidateBufferData (GLuint buffer);
GLAPI void APIENTRY glInvalidateFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments);
GLAPI void APIENTRY glInvalidateSubFramebuffer (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);
#endif /* GLCOREARB_PROTOTYPES */
typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth);
typedef void (APIENTRYP PFNGLINVALIDATETEXSUBIMAGEPROC) (GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei InputWidth, GLsizei InputHeight, GLsizei depth);
typedef void (APIENTRYP PFNGLINVALIDATETEXIMAGEPROC) (GLuint texture, GLint level);
typedef void (APIENTRYP PFNGLINVALIDATEBUFFERSUBDATAPROC) (GLuint buffer, GLintptr offset, GLsizeiptr length);
typedef void (APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC) (GLuint buffer);
typedef void (APIENTRYP PFNGLINVALIDATEFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments);
typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei width, GLsizei height);
typedef void (APIENTRYP PFNGLINVALIDATESUBFRAMEBUFFERPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments, GLint x, GLint y, GLsizei InputWidth, GLsizei InputHeight);
#endif
#ifndef GL_ARB_multi_draw_indirect
@ -4519,10 +4519,10 @@ GLAPI void APIENTRY glTexStorage3DMultisample (GLenum target, GLsizei samples, G
GLAPI void APIENTRY glTextureStorage2DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
GLAPI void APIENTRY glTextureStorage3DMultisampleEXT (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
#endif /* GLCOREARB_PROTOTYPES */
typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
typedef void (APIENTRYP PFNGLTEXSTORAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei InputWidth, GLsizei InputHeight, GLboolean fixedsamplelocations);
typedef void (APIENTRYP PFNGLTEXSTORAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei InputWidth, GLsizei InputHeight, GLsizei depth, GLboolean fixedsamplelocations);
typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei InputWidth, GLsizei InputHeight, GLboolean fixedsamplelocations);
typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DMULTISAMPLEEXTPROC) (GLuint texture, GLenum target, GLsizei samples, GLenum internalformat, GLsizei InputWidth, GLsizei InputHeight, GLsizei depth, GLboolean fixedsamplelocations);
#endif

View File

@ -45,6 +45,13 @@ target("GfxPluginNativeRender")
end
if has_config("use_dx12") then
add_defines("SUPPORT_D3D12=1")
add_includedirs("external/include")
add_linkdirs("external/lib")
add_links("libxess")
add_includedirs("features/")
add_headerfiles("features/**.h")
add_files("features/**.cpp")
end
end

View File

@ -496,14 +496,14 @@ namespace UnityEngine.Rendering.Universal
}
var asset = UniversalRenderPipeline.asset;
// SuperResolution
if (asset.SuperResolution == ESuperResolution.GSR1 || asset.SuperResolution == ESuperResolution.GSR2)
if (asset.SuperResolution == ESuperResolution.GSR1 || asset.SuperResolution == ESuperResolution.GSR2 || asset.SuperResolution == ESuperResolution.XESS13)
{
ref var colorDescriptor = ref cameraData.cameraTargetDescriptor;
colorDescriptor.width = cameraData.camera.pixelWidth;
colorDescriptor.height = cameraData.camera.pixelHeight;
//colorDescriptor.graphicsFormat = GraphicsFormat.R16G16B16A16_SFloat;
//colorDescriptor.enableRandomWrite = true; // compute
colorDescriptor.graphicsFormat = GraphicsFormat.R16G16B16A16_SFloat;
colorDescriptor.enableRandomWrite = true; // compute
renderer.m_ColorBufferSystem.SetCameraSettings(colorDescriptor, FilterMode.Bilinear);

View File

@ -38,8 +38,17 @@ namespace X.Rendering.Feature
{
EnableVRS = 1,
DisableVRS,
EnableFGExtrapolation,
PreFGExtrapolation,
DoFGExtrapolation,
}
PostFGExtrapolation,
DisableFGExtrapolation,
// SpatialUpScale,
EnableXESS1,
DoXESS1,
UpdateXESS1Config,
DisableXESS1,
};
public enum VRSPluginShadingRate
{

View File

@ -1,5 +1,4 @@
using System;
using System.Data.Common;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Experimental.Rendering;

View File

@ -0,0 +1,159 @@
using System;
using System.Runtime.InteropServices;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
namespace X.Rendering.Feature
{
enum XessQuality : int
{
UltraPerformance = 100,
Performance = 101,
Balanced = 102,
Quality = 103,
UltraQuality = 104,
UltraQualityPlus = 105,
NativeAA = 106,
};
[StructLayout(LayoutKind.Sequential), Serializable]
struct Xess1ConfigParam
{
public int OutputWidth;
/// Output buffer height.
public int OutputHeight;
/// Quality level of XeSS.
public XessQuality Quality;
/// If we are in High-Res motion vectors mode.
public bool UseHiResMotionVectors;
/// If motion vectors are jittered.
public bool UseJitteredMotionVectors;
/// If motion vectors are in Normalized Device Coordinate (NDC).
public bool UseMotionVectorsInNDC;
/// If use exposure texture.
public bool UseExposureTexture;
/// If use responsive mask.
public bool UseResponsiveMask;
/// If use auto exposure.
public bool UseAutoExposure;
/// If enable GPU profiling.
public bool EnableProfiling;
public float VelocityScaleX;
public float VelocityScaleY;
public float JitterScaleX;
public float JitterScaleY;
public float ExposureScale;
};
[StructLayout(LayoutKind.Sequential)]
unsafe struct Xess1ExecParam
{
public float Jitterx;
public float Jittery;
public int InputWidth;
public int InputHeight;
public bool ResetHistory;
public float ExposureScale;
public IntPtr ColorTexture;
public IntPtr VelocityTexture;
public IntPtr OutputTexture;
};
internal unsafe class XESS : ScriptableRendererFeature, ISuperResolutionFeature
{
[SerializeField]
Xess1ConfigParam xess1ConfigParam;
private bool needTurnOnXess = false;
private bool needTurnOffXess = false;
IntPtr xess1ExecParamPtr;
IntPtr xess1ConfigParamPtr;
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
{
}
public override void Create()
{
xess1ExecParamPtr = Marshal.AllocHGlobal(sizeof(Xess1ExecParam));
xess1ConfigParamPtr = Marshal.AllocHGlobal(sizeof(Xess1ConfigParam));
needTurnOnXess = true;
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
Marshal.FreeHGlobal(xess1ExecParamPtr);
Marshal.FreeHGlobal(xess1ConfigParamPtr);
}
public void DoSR(CommandBuffer cmd, RTHandle source, RTHandle destination, RTHandle motionVector, ref RenderingData renderingData)
{
Xess1ExecParam* xessexecPtr = (Xess1ExecParam*) xess1ExecParamPtr.ToPointer();
xessexecPtr->ResetHistory = false;
if (needTurnOnXess)
{
needTurnOnXess = false;
Xess1ConfigParam* xesscfgPtr = (Xess1ConfigParam*)xess1ConfigParamPtr.ToPointer();
xesscfgPtr->EnableProfiling = xess1ConfigParam.EnableProfiling;
xesscfgPtr->ExposureScale = xess1ConfigParam.ExposureScale;
xesscfgPtr->JitterScaleX = xess1ConfigParam.JitterScaleX;
xesscfgPtr->JitterScaleY = xess1ConfigParam.JitterScaleY;
xesscfgPtr->OutputHeight = xess1ConfigParam.OutputHeight;
xesscfgPtr->OutputWidth = xess1ConfigParam.OutputWidth;
xesscfgPtr->Quality = xess1ConfigParam.Quality;
xesscfgPtr->UseAutoExposure = xess1ConfigParam.UseAutoExposure;
xesscfgPtr->UseHiResMotionVectors = xess1ConfigParam.UseHiResMotionVectors;
xesscfgPtr->UseJitteredMotionVectors = xess1ConfigParam.UseJitteredMotionVectors;
xesscfgPtr->UseMotionVectorsInNDC = xess1ConfigParam.UseMotionVectorsInNDC;
xesscfgPtr->UseResponsiveMask = xess1ConfigParam.UseResponsiveMask;
xesscfgPtr->VelocityScaleX = xess1ConfigParam.VelocityScaleX;
xesscfgPtr->VelocityScaleY = xess1ConfigParam.VelocityScaleY;
xesscfgPtr->UseExposureTexture = xess1ConfigParam.UseExposureTexture;
cmd.IssuePluginEventAndData(RenderingPlugin.GetRenderEventAndDataFunc(), (int)RenderingPlugin.NativeRenderingEvent.EnableXESS1, IntPtr.Zero);
cmd.IssuePluginEventAndData(RenderingPlugin.GetRenderEventAndDataFunc(), (int)RenderingPlugin.NativeRenderingEvent.UpdateXESS1Config, xess1ConfigParamPtr);
xessexecPtr->ResetHistory = true;
}
xessexecPtr->InputWidth = source.referenceSize.x;
xessexecPtr->InputHeight = source.referenceSize.y;
xessexecPtr->ExposureScale = 1.0f;
xessexecPtr->ColorTexture = source.rt.GetNativeTexturePtr();
xessexecPtr->VelocityTexture = motionVector.rt.GetNativeTexturePtr();
xessexecPtr->OutputTexture = destination.rt.GetNativeTexturePtr();
xessexecPtr->Jitterx = 0;
xessexecPtr->Jittery = 0;
cmd.IssuePluginEventAndData(RenderingPlugin.GetRenderEventAndDataFunc(), (int)RenderingPlugin.NativeRenderingEvent.DoXESS1, xess1ExecParamPtr);
if (needTurnOffXess)
{
needTurnOffXess = false;
cmd.IssuePluginEventAndData(RenderingPlugin.GetRenderEventAndDataFunc(), (int)RenderingPlugin.NativeRenderingEvent.DisableXESS1, IntPtr.Zero);
}
}
public void SetSR(ESuperResolution resolution)
{
switch (resolution)
{
case ESuperResolution.XESS13:
{
SetActive(true);
needTurnOnXess = true;
}
break;
default:
{
SetActive(false);
needTurnOffXess = false;
}
break;
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: XHlMsSmkUnqD7anEmz652oCNyEfaXhRDBzQ7mUApwFc8gavrk9akMoQ=
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -14,14 +14,14 @@ MonoBehaviour:
m_EditorClassIdentifier:
m_PixelRect:
serializedVersion: 2
x: 494
y: 134
width: 1551
height: 1099
x: 2886
y: 183
width: 1934
height: 971
m_ShowMode: 0
m_Title: Project Settings
m_Title: Frame Debugger
m_RootView: {fileID: 4}
m_MinSize: {x: 310, y: 221}
m_MinSize: {x: 1000, y: 521}
m_MaxSize: {x: 4000, y: 4021}
m_Maximized: 0
--- !u!114 &2
@ -43,7 +43,7 @@ MonoBehaviour:
width: 2542
height: 1331
m_ShowMode: 4
m_Title: Console
m_Title: Inspector
m_RootView: {fileID: 13}
m_MinSize: {x: 875, y: 321}
m_MaxSize: {x: 10000, y: 10000}
@ -58,16 +58,16 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 12006, guid: 0000000000000000e000000000000000, type: 0}
m_Name: ProjectSettingsWindow
m_Name: FrameDebuggerWindow
m_EditorClassIdentifier:
m_Children: []
m_Position:
serializedVersion: 2
x: 0
y: 0
width: 1551
height: 1099
m_MinSize: {x: 310, y: 221}
width: 1934
height: 971
m_MinSize: {x: 1000, y: 521}
m_MaxSize: {x: 4000, y: 4021}
m_ActualView: {fileID: 17}
m_Panes:
@ -92,12 +92,12 @@ MonoBehaviour:
serializedVersion: 2
x: 0
y: 0
width: 1551
height: 1099
m_MinSize: {x: 310, y: 221}
width: 1934
height: 971
m_MinSize: {x: 1000, y: 521}
m_MaxSize: {x: 4000, y: 4021}
vertical: 0
controlID: 453
controlID: 184
draggingID: 0
--- !u!114 &5
MonoBehaviour:
@ -171,8 +171,8 @@ MonoBehaviour:
y: 0
width: 701
height: 522
m_MinSize: {x: 102, y: 121}
m_MaxSize: {x: 4002, y: 4021}
m_MinSize: {x: 100, y: 100}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 23}
m_Panes:
- {fileID: 23}
@ -202,7 +202,7 @@ MonoBehaviour:
m_MinSize: {x: 200, y: 50}
m_MaxSize: {x: 16192, y: 8096}
vertical: 0
controlID: 130
controlID: 128
draggingID: 0
--- !u!114 &9
MonoBehaviour:
@ -228,7 +228,7 @@ MonoBehaviour:
m_MinSize: {x: 300, y: 100}
m_MaxSize: {x: 24288, y: 16192}
vertical: 0
controlID: 38
controlID: 164
draggingID: 0
--- !u!114 &10
MonoBehaviour:
@ -275,8 +275,8 @@ MonoBehaviour:
y: 0
width: 439
height: 759
m_MinSize: {x: 201, y: 221}
m_MaxSize: {x: 4001, y: 4021}
m_MinSize: {x: 200, y: 200}
m_MaxSize: {x: 4000, y: 4000}
m_ActualView: {fileID: 21}
m_Panes:
- {fileID: 21}
@ -403,7 +403,7 @@ MonoBehaviour:
m_MinSize: {x: 200, y: 100}
m_MaxSize: {x: 16192, y: 16192}
vertical: 1
controlID: 39
controlID: 127
draggingID: 0
--- !u!114 &17
MonoBehaviour:
@ -414,21 +414,21 @@ MonoBehaviour:
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 13854, guid: 0000000000000000e000000000000000, type: 0}
m_Script: {fileID: 13202, guid: 0000000000000000e000000000000000, type: 0}
m_Name:
m_EditorClassIdentifier:
m_MinSize: {x: 310, y: 200}
m_MinSize: {x: 1000, y: 500}
m_MaxSize: {x: 4000, y: 4000}
m_TitleContent:
m_Text: Project Settings
m_Image: {fileID: -5712115415447495865, guid: 0000000000000000d000000000000000, type: 0}
m_Text: Frame Debugger
m_Image: {fileID: 0}
m_Tooltip:
m_Pos:
serializedVersion: 2
x: 494
y: 134
width: 1551
height: 1078
x: 2886
y: 183
width: 1934
height: 950
m_SerializedDataModeController:
m_DataMode: 0
m_PreferredDataMode: 0
@ -439,16 +439,12 @@ MonoBehaviour:
m_LastAppliedPresetName: Default
m_SaveData: []
m_OverlaysVisible: 1
m_PosLeft: {x: 0, y: 0}
m_PosRight: {x: 0, y: 0}
m_Scope: 1
m_SplitterFlex: 0.2
m_SearchText:
m_TreeWidth: 337.92
m_TreeViewState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 4dcf9b58
m_LastClickedID: 1486606157
m_ExpandedIDs: 53336be2000000007f0eae07
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs:
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@ -505,7 +501,7 @@ MonoBehaviour:
collapsed: 0
displayed: 1
snapOffset: {x: 0, y: 0}
snapOffsetDelta: {x: -171, y: -26}
snapOffsetDelta: {x: -179, y: -26}
snapCorner: 3
id: Tool Settings
index: 0
@ -963,9 +959,9 @@ MonoBehaviour:
m_IsLocked: 0
m_FolderTreeState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 72bb0000
m_LastClickedID: 47986
m_ExpandedIDs: 0000000042b8000044b8000046b8000048b800004ab800004cb800004eb8000050b8000052b8000054b8000056b8000058b800005ab800005cb800005eb8000060b8000000ca9a3bffffff7f
m_SelectedIDs: 7cbb0000
m_LastClickedID: 47996
m_ExpandedIDs: 000000004cb800004eb8000050b8000052b8000054b8000056b8000058b800005ab800005cb800005eb8000060b8000062b8000064b8000066b8000068b800006ab8000000ca9a3bffffff7f
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@ -993,7 +989,7 @@ MonoBehaviour:
scrollPos: {x: 0, y: 0}
m_SelectedIDs:
m_LastClickedID: 0
m_ExpandedIDs: 0000000042b8000044b8000046b8000048b800004ab800004cb800004eb8000050b8000052b8000054b8000056b8000058b800005ab800005cb800005eb8000060b80000
m_ExpandedIDs: 000000004cb800004eb8000050b8000052b8000054b8000056b8000058b800005ab800005cb800005eb8000060b8000062b8000064b8000066b8000068b800006ab80000
m_RenameOverlay:
m_UserAcceptedRename: 0
m_Name:
@ -1133,7 +1129,7 @@ MonoBehaviour:
m_SceneHierarchy:
m_TreeViewState:
scrollPos: {x: 0, y: 0}
m_SelectedIDs: 48030000
m_SelectedIDs: 7cbb0000
m_LastClickedID: 0
m_ExpandedIDs: 3afaffff
m_RenameOverlay:
@ -1207,7 +1203,7 @@ MonoBehaviour:
m_UseMipMap: 0
m_VSyncEnabled: 0
m_Gizmos: 0
m_Stats: 1
m_Stats: 0
m_SelectedSizes: 00000000000000000000000006000000000000000000000000000000000000000000000000000000
m_ZoomArea:
m_HRangeLocked: 0