mirror of
https://github.com/jmarshall23/DoomRTX.git
synced 2026-08-20 12:40:25 +02:00
Framegen now works and increase light bounce to 3.
This commit is contained in:
@@ -17771,6 +17771,7 @@ Version 2
|
|||||||
"light_target" "0 0 -434"
|
"light_target" "0 0 -434"
|
||||||
"light_up" "8 -348 0"
|
"light_up" "8 -348 0"
|
||||||
"light_right" "-272 6 0"
|
"light_right" "-272 6 0"
|
||||||
|
"vls" "1"
|
||||||
}
|
}
|
||||||
// entity 89
|
// entity 89
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,9 +15,9 @@
|
|||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||||
<LocalDebuggerCommand>D:\projects\Doom3\Doom3.exe</LocalDebuggerCommand>
|
<LocalDebuggerCommand>D:\projects\Doom3\Doom3.exe</LocalDebuggerCommand>
|
||||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||||
<LocalDebuggerCommandArguments>+set r_fullscreen 0 +set r_mode 9 +set sv_pure 0 +set fs_game e3</LocalDebuggerCommandArguments>
|
<LocalDebuggerCommandArguments>+set r_fullscreen 0 +set r_mode 9 +set sv_pure 0 </LocalDebuggerCommandArguments>
|
||||||
<LocalDebuggerWorkingDirectory>D:\projects\Doom3</LocalDebuggerWorkingDirectory>
|
<LocalDebuggerWorkingDirectory>D:\projects\Doom3</LocalDebuggerWorkingDirectory>
|
||||||
<LocalDebuggerCommandArgumentsHistory>+set r_fullscreen 0 +set r_mode 9|+set r_fullscreen 1 +set r_mode 9 +set sv_pure 0 +set fs_game e3|+set r_fullscreen 0 +set r_mode 9 +set sv_pure 0 |+set r_fullscreen 0 +set r_mode 9 +set sv_pure 0|+set r_fullscreen 0 +set r_mode 9 +set sv_pure 0 +set fs_game e3|</LocalDebuggerCommandArgumentsHistory>
|
<LocalDebuggerCommandArgumentsHistory>+set r_fullscreen 0 +set r_mode 9|+set r_fullscreen 1 +set r_mode 9 +set sv_pure 0 +set fs_game e3|+set r_fullscreen 0 +set r_mode 9 +set sv_pure 0|+set r_fullscreen 0 +set r_mode 9 +set sv_pure 0 +set fs_game e3|+set r_fullscreen 0 +set r_mode 9 +set sv_pure 0 |</LocalDebuggerCommandArgumentsHistory>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Q4 Debug|x64'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Q4 Debug|x64'">
|
||||||
<LocalDebuggerCommand>D:\projects\Doom3\Quake4.exe</LocalDebuggerCommand>
|
<LocalDebuggerCommand>D:\projects\Doom3\Quake4.exe</LocalDebuggerCommand>
|
||||||
|
|||||||
@@ -178,6 +178,16 @@ SCR_DrawFPS
|
|||||||
==================
|
==================
|
||||||
*/
|
*/
|
||||||
#define FPS_FRAMES 4
|
#define FPS_FRAMES 4
|
||||||
|
static const idVec4 &SCR_FrameTimeColor( int msec ) {
|
||||||
|
if ( msec < 16 ) {
|
||||||
|
return colorGreen;
|
||||||
|
}
|
||||||
|
if ( msec < 30 ) {
|
||||||
|
return colorYellow;
|
||||||
|
}
|
||||||
|
return colorRed;
|
||||||
|
}
|
||||||
|
|
||||||
float SCR_DrawFPS( float y ) {
|
float SCR_DrawFPS( float y ) {
|
||||||
char *s;
|
char *s;
|
||||||
int w;
|
int w;
|
||||||
@@ -208,15 +218,25 @@ float SCR_DrawFPS( float y ) {
|
|||||||
fps = 10000 * FPS_FRAMES / total;
|
fps = 10000 * FPS_FRAMES / total;
|
||||||
fps = (fps + 5)/10;
|
fps = (fps + 5)/10;
|
||||||
|
|
||||||
s = va( "%ifps", fps );
|
const int averageFrameTime = ( total + ( FPS_FRAMES / 2 ) ) / FPS_FRAMES;
|
||||||
|
const int frameGenMultiplier = idMath::ClampInt( 1, 4, cvarSystem->GetCVarInteger( "r_frameGen" ) );
|
||||||
|
const int displayFps = fps * frameGenMultiplier;
|
||||||
|
const int displayFrameTime = ( averageFrameTime + ( frameGenMultiplier / 2 ) ) / frameGenMultiplier;
|
||||||
|
const idVec4 &frameColor = SCR_FrameTimeColor( displayFrameTime );
|
||||||
|
|
||||||
|
if ( frameGenMultiplier >= 2 ) {
|
||||||
|
s = va( "%ifps %dms est (%ir %dms)", displayFps, displayFrameTime, fps, averageFrameTime );
|
||||||
|
} else {
|
||||||
|
s = va( "%ifps %dms", fps, averageFrameTime );
|
||||||
|
}
|
||||||
w = strlen( s ) * BIGCHAR_WIDTH;
|
w = strlen( s ) * BIGCHAR_WIDTH;
|
||||||
|
|
||||||
renderSystem->DrawBigStringExt( (SCREEN_WIDTH - 5.0f) - w, idMath::FtoiFast(y) + 2, s, colorWhite, true, localConsole.charSetShader);
|
renderSystem->DrawBigStringExt( (SCREEN_WIDTH - 5.0f) - w, idMath::FtoiFast(y) + 2, s, frameColor, true, localConsole.charSetShader);
|
||||||
|
|
||||||
y += BIGCHAR_HEIGHT + 4;
|
y += BIGCHAR_HEIGHT + 4;
|
||||||
s = va( "game cpu:%4.1fms render cpu:%4.1fms pt gpu:%4.1fms", com_lastGameFrameMsec, com_lastRenderFrameMsec, com_pathTracingGpuMsec );
|
s = va( "game cpu:%4.1fms render cpu:%4.1fms pt gpu:%4.1fms", com_lastGameFrameMsec, com_lastRenderFrameMsec, com_pathTracingGpuMsec );
|
||||||
w = strlen( s ) * SMALLCHAR_WIDTH;
|
w = strlen( s ) * SMALLCHAR_WIDTH;
|
||||||
renderSystem->DrawSmallStringExt( (SCREEN_WIDTH - 5.0f) - w, idMath::FtoiFast(y) + 2, s, colorWhite, true, localConsole.charSetShader);
|
renderSystem->DrawSmallStringExt( (SCREEN_WIDTH - 5.0f) - w, idMath::FtoiFast(y) + 2, s, frameColor, true, localConsole.charSetShader);
|
||||||
return y + SMALLCHAR_HEIGHT + 4;
|
return y + SMALLCHAR_HEIGHT + 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2434,11 +2434,12 @@ struct glRaytracingLightingState_t
|
|||||||
|
|
||||||
ComPtr<ID3D12PipelineState> denoisePSO;
|
ComPtr<ID3D12PipelineState> denoisePSO;
|
||||||
ComPtr<ID3D12PipelineState> temporalPSO;
|
ComPtr<ID3D12PipelineState> temporalPSO;
|
||||||
glRaytracingTexture_t pathTraceTexture;
|
glRaytracingTexture_t pathTraceTexture[2];
|
||||||
glRaytracingTexture_t temporalTexture;
|
glRaytracingTexture_t temporalTexture;
|
||||||
glRaytracingTexture_t historyTexture[2];
|
glRaytracingTexture_t historyTexture[2];
|
||||||
glRaytracingTexture_t denoiseTemp[2];
|
glRaytracingTexture_t denoiseTemp[2];
|
||||||
uint32_t currentHistoryIndex;
|
uint32_t currentHistoryIndex;
|
||||||
|
uint32_t currentPathTraceIndex;
|
||||||
glRaytracingBuffer_t denoiseConstantBuffer[3];
|
glRaytracingBuffer_t denoiseConstantBuffer[3];
|
||||||
glRaytracingBuffer_t denoiseConstantBufferRing[GL_RAYTRACING_CMD_RING_SIZE][3];
|
glRaytracingBuffer_t denoiseConstantBufferRing[GL_RAYTRACING_CMD_RING_SIZE][3];
|
||||||
void* denoiseConstantBufferMapped[3];
|
void* denoiseConstantBufferMapped[3];
|
||||||
@@ -2474,6 +2475,7 @@ struct glRaytracingLightingState_t
|
|||||||
denoiseHeight = 0;
|
denoiseHeight = 0;
|
||||||
denoiseFormat = DXGI_FORMAT_UNKNOWN;
|
denoiseFormat = DXGI_FORMAT_UNKNOWN;
|
||||||
currentHistoryIndex = 0;
|
currentHistoryIndex = 0;
|
||||||
|
currentPathTraceIndex = 0;
|
||||||
frameCounter = 0;
|
frameCounter = 0;
|
||||||
externalDenoiser = false;
|
externalDenoiser = false;
|
||||||
emissiveTexture = nullptr;
|
emissiveTexture = nullptr;
|
||||||
@@ -4707,7 +4709,7 @@ float3 PathTraceDeterministicLighting(
|
|||||||
float3 skyColorRGB = float3(0.98, 0.55, 0.35);
|
float3 skyColorRGB = float3(0.98, 0.55, 0.35);
|
||||||
float3 skyColor = skyColorRGB * (0.35 + 0.65 * upness);
|
float3 skyColor = skyColorRGB * (0.35 + 0.65 * upness);
|
||||||
|
|
||||||
float3 lightingAccum = gAmbientColor.rgb * (gAmbientColor.a * 0.04);
|
float3 lightingAccum = float3(0, 0, 0); // gAmbientColor.rgb * (gAmbientColor.a * 0.04);
|
||||||
lightingAccum += skyColor * (0.42 * skyVis);
|
lightingAccum += skyColor * (0.42 * skyVis);
|
||||||
lightingAccum += ambientSkyVis * (skyColorRGB * 0.12);
|
lightingAccum += ambientSkyVis * (skyColorRGB * 0.12);
|
||||||
|
|
||||||
@@ -6243,7 +6245,8 @@ static int glRaytracingLightingEnsureDenoiseResources(UINT width, UINT height)
|
|||||||
if (width == 0 || height == 0)
|
if (width == 0 || height == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (g_glRaytracingLighting.pathTraceTexture.resource &&
|
if (g_glRaytracingLighting.pathTraceTexture[0].resource &&
|
||||||
|
g_glRaytracingLighting.pathTraceTexture[1].resource &&
|
||||||
g_glRaytracingLighting.temporalTexture.resource &&
|
g_glRaytracingLighting.temporalTexture.resource &&
|
||||||
g_glRaytracingLighting.historyTexture[0].resource &&
|
g_glRaytracingLighting.historyTexture[0].resource &&
|
||||||
g_glRaytracingLighting.historyTexture[1].resource &&
|
g_glRaytracingLighting.historyTexture[1].resource &&
|
||||||
@@ -6256,7 +6259,8 @@ static int glRaytracingLightingEnsureDenoiseResources(UINT width, UINT height)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_glRaytracingLighting.pathTraceTexture.resource ||
|
if (g_glRaytracingLighting.pathTraceTexture[0].resource ||
|
||||||
|
g_glRaytracingLighting.pathTraceTexture[1].resource ||
|
||||||
g_glRaytracingLighting.temporalTexture.resource ||
|
g_glRaytracingLighting.temporalTexture.resource ||
|
||||||
g_glRaytracingLighting.historyTexture[0].resource ||
|
g_glRaytracingLighting.historyTexture[0].resource ||
|
||||||
g_glRaytracingLighting.historyTexture[1].resource ||
|
g_glRaytracingLighting.historyTexture[1].resource ||
|
||||||
@@ -6266,20 +6270,24 @@ static int glRaytracingLightingEnsureDenoiseResources(UINT width, UINT height)
|
|||||||
glRaytracingWaitIdle();
|
glRaytracingWaitIdle();
|
||||||
}
|
}
|
||||||
|
|
||||||
g_glRaytracingLighting.pathTraceTexture = glRaytracingTexture_t();
|
g_glRaytracingLighting.pathTraceTexture[0] = glRaytracingTexture_t();
|
||||||
|
g_glRaytracingLighting.pathTraceTexture[1] = glRaytracingTexture_t();
|
||||||
g_glRaytracingLighting.temporalTexture = glRaytracingTexture_t();
|
g_glRaytracingLighting.temporalTexture = glRaytracingTexture_t();
|
||||||
g_glRaytracingLighting.historyTexture[0] = glRaytracingTexture_t();
|
g_glRaytracingLighting.historyTexture[0] = glRaytracingTexture_t();
|
||||||
g_glRaytracingLighting.historyTexture[1] = glRaytracingTexture_t();
|
g_glRaytracingLighting.historyTexture[1] = glRaytracingTexture_t();
|
||||||
g_glRaytracingLighting.denoiseTemp[0] = glRaytracingTexture_t();
|
g_glRaytracingLighting.denoiseTemp[0] = glRaytracingTexture_t();
|
||||||
g_glRaytracingLighting.denoiseTemp[1] = glRaytracingTexture_t();
|
g_glRaytracingLighting.denoiseTemp[1] = glRaytracingTexture_t();
|
||||||
|
|
||||||
g_glRaytracingLighting.pathTraceTexture = glRaytracingCreateTexture2D(
|
for (int i = 0; i < 2; ++i)
|
||||||
g_glRaytracingCmd.device.Get(),
|
{
|
||||||
width,
|
g_glRaytracingLighting.pathTraceTexture[i] = glRaytracingCreateTexture2D(
|
||||||
height,
|
g_glRaytracingCmd.device.Get(),
|
||||||
GL_RAYTRACING_DENOISE_FORMAT,
|
width,
|
||||||
D3D12_RESOURCE_STATE_UNORDERED_ACCESS,
|
height,
|
||||||
D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS);
|
GL_RAYTRACING_DENOISE_FORMAT,
|
||||||
|
D3D12_RESOURCE_STATE_UNORDERED_ACCESS,
|
||||||
|
D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS);
|
||||||
|
}
|
||||||
|
|
||||||
g_glRaytracingLighting.temporalTexture = glRaytracingCreateTexture2D(
|
g_glRaytracingLighting.temporalTexture = glRaytracingCreateTexture2D(
|
||||||
g_glRaytracingCmd.device.Get(),
|
g_glRaytracingCmd.device.Get(),
|
||||||
@@ -6311,7 +6319,8 @@ static int glRaytracingLightingEnsureDenoiseResources(UINT width, UINT height)
|
|||||||
D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS);
|
D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_glRaytracingLighting.pathTraceTexture.resource ||
|
if (!g_glRaytracingLighting.pathTraceTexture[0].resource ||
|
||||||
|
!g_glRaytracingLighting.pathTraceTexture[1].resource ||
|
||||||
!g_glRaytracingLighting.temporalTexture.resource ||
|
!g_glRaytracingLighting.temporalTexture.resource ||
|
||||||
!g_glRaytracingLighting.historyTexture[0].resource ||
|
!g_glRaytracingLighting.historyTexture[0].resource ||
|
||||||
!g_glRaytracingLighting.historyTexture[1].resource ||
|
!g_glRaytracingLighting.historyTexture[1].resource ||
|
||||||
@@ -6322,6 +6331,7 @@ static int glRaytracingLightingEnsureDenoiseResources(UINT width, UINT height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_glRaytracingLighting.currentHistoryIndex = 0;
|
g_glRaytracingLighting.currentHistoryIndex = 0;
|
||||||
|
g_glRaytracingLighting.currentPathTraceIndex = 0;
|
||||||
g_glRaytracingLighting.denoiseWidth = width;
|
g_glRaytracingLighting.denoiseWidth = width;
|
||||||
g_glRaytracingLighting.denoiseHeight = height;
|
g_glRaytracingLighting.denoiseHeight = height;
|
||||||
g_glRaytracingLighting.denoiseFormat = GL_RAYTRACING_DENOISE_FORMAT;
|
g_glRaytracingLighting.denoiseFormat = GL_RAYTRACING_DENOISE_FORMAT;
|
||||||
@@ -6486,7 +6496,7 @@ static bool glRaytracingLightingExecuteInternal(
|
|||||||
!g_glRaytracingLighting.externalDenoiser;
|
!g_glRaytracingLighting.externalDenoiser;
|
||||||
|
|
||||||
ID3D12Resource* rayOutputTexture = useInternalDenoiser
|
ID3D12Resource* rayOutputTexture = useInternalDenoiser
|
||||||
? g_glRaytracingLighting.pathTraceTexture.resource.Get()
|
? g_glRaytracingLighting.pathTraceTexture[g_glRaytracingLighting.currentPathTraceIndex & 1u].resource.Get()
|
||||||
: pass->outputTexture;
|
: pass->outputTexture;
|
||||||
|
|
||||||
if (!glRaytracingBeginCmd())
|
if (!glRaytracingBeginCmd())
|
||||||
@@ -6517,12 +6527,14 @@ static bool glRaytracingLightingExecuteInternal(
|
|||||||
|
|
||||||
const uint32_t historyReadIndex = g_glRaytracingLighting.currentHistoryIndex & 1u;
|
const uint32_t historyReadIndex = g_glRaytracingLighting.currentHistoryIndex & 1u;
|
||||||
const uint32_t historyWriteIndex = (g_glRaytracingLighting.currentHistoryIndex ^ 1u) & 1u;
|
const uint32_t historyWriteIndex = (g_glRaytracingLighting.currentHistoryIndex ^ 1u) & 1u;
|
||||||
|
const uint32_t pathTraceIndex = g_glRaytracingLighting.currentPathTraceIndex & 1u;
|
||||||
|
glRaytracingTexture_t& pathTraceTexture = g_glRaytracingLighting.pathTraceTexture[pathTraceIndex];
|
||||||
|
|
||||||
glRaytracingLightingCreatePerPassDescriptors(
|
glRaytracingLightingCreatePerPassDescriptors(
|
||||||
pass,
|
pass,
|
||||||
topLevelAS,
|
topLevelAS,
|
||||||
rayOutputTexture,
|
rayOutputTexture,
|
||||||
g_glRaytracingLighting.pathTraceTexture.resource.Get(),
|
pathTraceTexture.resource.Get(),
|
||||||
g_glRaytracingLighting.denoiseTemp[0].resource.Get(),
|
g_glRaytracingLighting.denoiseTemp[0].resource.Get(),
|
||||||
g_glRaytracingLighting.denoiseTemp[1].resource.Get(),
|
g_glRaytracingLighting.denoiseTemp[1].resource.Get(),
|
||||||
g_glRaytracingLighting.historyTexture[historyReadIndex].resource.Get(),
|
g_glRaytracingLighting.historyTexture[historyReadIndex].resource.Get(),
|
||||||
@@ -6532,10 +6544,10 @@ static bool glRaytracingLightingExecuteInternal(
|
|||||||
if (useInternalDenoiser)
|
if (useInternalDenoiser)
|
||||||
{
|
{
|
||||||
glRaytracingTransition(g_glRaytracingCmd.cmdList.Get(),
|
glRaytracingTransition(g_glRaytracingCmd.cmdList.Get(),
|
||||||
g_glRaytracingLighting.pathTraceTexture.resource.Get(),
|
pathTraceTexture.resource.Get(),
|
||||||
g_glRaytracingLighting.pathTraceTexture.state,
|
pathTraceTexture.state,
|
||||||
D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||||
g_glRaytracingLighting.pathTraceTexture.state = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
pathTraceTexture.state = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -6598,10 +6610,10 @@ static bool glRaytracingLightingExecuteInternal(
|
|||||||
const UINT groupsY = (pass->height + 7u) / 8u;
|
const UINT groupsY = (pass->height + 7u) / 8u;
|
||||||
|
|
||||||
glRaytracingTransition(g_glRaytracingCmd.cmdList.Get(),
|
glRaytracingTransition(g_glRaytracingCmd.cmdList.Get(),
|
||||||
g_glRaytracingLighting.pathTraceTexture.resource.Get(),
|
pathTraceTexture.resource.Get(),
|
||||||
g_glRaytracingLighting.pathTraceTexture.state,
|
pathTraceTexture.state,
|
||||||
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
|
||||||
g_glRaytracingLighting.pathTraceTexture.state = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;
|
pathTraceTexture.state = D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE;
|
||||||
|
|
||||||
glRaytracingTransition(g_glRaytracingCmd.cmdList.Get(),
|
glRaytracingTransition(g_glRaytracingCmd.cmdList.Get(),
|
||||||
g_glRaytracingLighting.temporalTexture.resource.Get(),
|
g_glRaytracingLighting.temporalTexture.resource.Get(),
|
||||||
@@ -6737,7 +6749,10 @@ static bool glRaytracingLightingExecuteInternal(
|
|||||||
g_glRaytracingCmd.pathTracingTimestampFenceRing[g_glRaytracingCmd.cmdCurrentSlot] = g_glRaytracingCmd.cmdLastFenceValue;
|
g_glRaytracingCmd.pathTracingTimestampFenceRing[g_glRaytracingCmd.cmdCurrentSlot] = g_glRaytracingCmd.cmdLastFenceValue;
|
||||||
|
|
||||||
if (useInternalDenoiser)
|
if (useInternalDenoiser)
|
||||||
|
{
|
||||||
g_glRaytracingLighting.currentHistoryIndex = historyWriteIndex;
|
g_glRaytracingLighting.currentHistoryIndex = historyWriteIndex;
|
||||||
|
g_glRaytracingLighting.currentPathTraceIndex = (pathTraceIndex ^ 1u);
|
||||||
|
}
|
||||||
|
|
||||||
++g_glRaytracingLighting.frameCounter;
|
++g_glRaytracingLighting.frameCounter;
|
||||||
return true;
|
return true;
|
||||||
@@ -6795,6 +6810,7 @@ bool glRaytracingLightingInit(void)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
memset(&g_glRaytracingLighting.constants, 0, sizeof(g_glRaytracingLighting.constants));
|
memset(&g_glRaytracingLighting.constants, 0, sizeof(g_glRaytracingLighting.constants));
|
||||||
|
g_glRaytracingLighting.cpuLights.reserve(GL_RAYTRACING_MAX_LIGHTS);
|
||||||
glRaytracingSetIdentity4x4(g_glRaytracingLighting.constants.invViewProj);
|
glRaytracingSetIdentity4x4(g_glRaytracingLighting.constants.invViewProj);
|
||||||
glRaytracingSetIdentity4x4(g_glRaytracingLighting.constants.invViewMatrix);
|
glRaytracingSetIdentity4x4(g_glRaytracingLighting.constants.invViewMatrix);
|
||||||
glRaytracingSetIdentity4x4(g_glRaytracingLighting.constants.viewProj);
|
glRaytracingSetIdentity4x4(g_glRaytracingLighting.constants.viewProj);
|
||||||
|
|||||||
+214
-100
@@ -373,6 +373,7 @@ static void QD3D12_SubmitOpenFrameNoPresentAndWait();
|
|||||||
static void QD3D12_EnsureFrameOpen();
|
static void QD3D12_EnsureFrameOpen();
|
||||||
static void QD3D12_RunUpscalerOrBlit(QD3D12Window& w);
|
static void QD3D12_RunUpscalerOrBlit(QD3D12Window& w);
|
||||||
static void QD3D12_ExecuteMainCommandListAndWait(QD3D12Window& w);
|
static void QD3D12_ExecuteMainCommandListAndWait(QD3D12Window& w);
|
||||||
|
static void QD3D12_ExecuteMainCommandListForRaytracingHandoff(QD3D12Window& w);
|
||||||
static bool QD3D12_RunInternalTAA(QD3D12Window& w, D3D12_GPU_DESCRIPTOR_HANDLE inputSrv, D3D12_GPU_DESCRIPTOR_HANDLE& outputSrv);
|
static bool QD3D12_RunInternalTAA(QD3D12Window& w, D3D12_GPU_DESCRIPTOR_HANDLE inputSrv, D3D12_GPU_DESCRIPTOR_HANDLE& outputSrv);
|
||||||
static bool QD3D12_FinalBlitToBackBuffer(QD3D12Window& w, D3D12_GPU_DESCRIPTOR_HANDLE inputSrv, const D3D12_VIEWPORT& outputViewport, const D3D12_RECT& outputScissor, bool toneMapInput = false);
|
static bool QD3D12_FinalBlitToBackBuffer(QD3D12Window& w, D3D12_GPU_DESCRIPTOR_HANDLE inputSrv, const D3D12_VIEWPORT& outputViewport, const D3D12_RECT& outputScissor, bool toneMapInput = false);
|
||||||
static void QD3D12_RunRayAIDenoiseIfEnabled(ID3D12GraphicsCommandList* cl, QD3D12Window& w, ID3D12Resource* lightingResource);
|
static void QD3D12_RunRayAIDenoiseIfEnabled(ID3D12GraphicsCommandList* cl, QD3D12Window& w, ID3D12Resource* lightingResource);
|
||||||
@@ -1483,6 +1484,10 @@ struct GLState
|
|||||||
|
|
||||||
GLenum depthFunc = GL_LEQUAL;
|
GLenum depthFunc = GL_LEQUAL;
|
||||||
UINT64 nextFenceValue = 1;
|
UINT64 nextFenceValue = 1;
|
||||||
|
ComPtr<ID3D12CommandAllocator> raytraceContinuationAlloc[QD3D12_FrameCount];
|
||||||
|
UINT64 raytraceContinuationFence[QD3D12_FrameCount] = {};
|
||||||
|
UINT raytraceContinuationIndex = 0;
|
||||||
|
int activeRaytraceContinuationSlot = -1;
|
||||||
|
|
||||||
GLuint currentMotionObjectId = 0;
|
GLuint currentMotionObjectId = 0;
|
||||||
float currentSurfaceRoughness = 0.5f;
|
float currentSurfaceRoughness = 0.5f;
|
||||||
@@ -1500,14 +1505,14 @@ struct GLState
|
|||||||
|
|
||||||
QD3D12UpscalerBackend upscalerBackend = QD3D12_UPSCALER_DLSS;
|
QD3D12UpscalerBackend upscalerBackend = QD3D12_UPSCALER_DLSS;
|
||||||
QD3D12UpscalerQuality upscalerQuality = QD3D12_QUALITY_DLAA;
|
QD3D12UpscalerQuality upscalerQuality = QD3D12_QUALITY_DLAA;
|
||||||
bool enableInternalTAA = true;
|
bool enableInternalTAA = false;
|
||||||
bool enableRayAIDenoise = false;
|
bool enableRayAIDenoise = false;
|
||||||
bool enableDLSSRayReconstruction = true;
|
bool enableDLSSRayReconstruction = false;
|
||||||
bool enableFSRRayRegeneration = false;
|
bool enableFSRRayRegeneration = false;
|
||||||
uint32_t frameGenerationMultiplier = 2;
|
uint32_t frameGenerationMultiplier = 2;
|
||||||
uint32_t pathTracingSamplesPerPixel = 1;
|
uint32_t pathTracingSamplesPerPixel = 1;
|
||||||
uint32_t pathTracingFallbackSamplesPerPixel = 2;
|
uint32_t pathTracingFallbackSamplesPerPixel = 2;
|
||||||
uint32_t pathTracingMaxBounces = 2;
|
uint32_t pathTracingMaxBounces = 3;
|
||||||
|
|
||||||
float jitterX = 0.0f;
|
float jitterX = 0.0f;
|
||||||
float jitterY = 0.0f;
|
float jitterY = 0.0f;
|
||||||
@@ -2250,9 +2255,17 @@ void QD3D12_SetCurrentWindow(struct QD3D12Window* window) {
|
|||||||
g_qd3d12CurrentDC = window->hdc;
|
g_qd3d12CurrentDC = window->hdc;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLuint g_lightingTextureId = 0;
|
static constexpr UINT QD3D12_LightingTextureCount = 2;
|
||||||
static TextureResource* g_lightingTexture = nullptr;
|
static GLuint g_lightingTextureId[QD3D12_LightingTextureCount] = {};
|
||||||
static D3D12_RESOURCE_STATES g_lightingTextureState = D3D12_RESOURCE_STATE_COMMON;
|
static TextureResource* g_lightingTexture[QD3D12_LightingTextureCount] = {};
|
||||||
|
static D3D12_RESOURCE_STATES g_lightingTextureState[QD3D12_LightingTextureCount] =
|
||||||
|
{
|
||||||
|
D3D12_RESOURCE_STATE_COMMON,
|
||||||
|
D3D12_RESOURCE_STATE_COMMON
|
||||||
|
};
|
||||||
|
static bool g_lightingTextureValid[QD3D12_LightingTextureCount] = {};
|
||||||
|
static UINT g_lightingReadIndex = 0;
|
||||||
|
static UINT g_lightingWriteIndex = 0;
|
||||||
|
|
||||||
static ComPtr<ID3D12Resource> g_qd3d12NeuralPOMZeroBuffer;
|
static ComPtr<ID3D12Resource> g_qd3d12NeuralPOMZeroBuffer;
|
||||||
static UINT g_qd3d12NeuralPOMZeroSrvIndex = UINT_MAX;
|
static UINT g_qd3d12NeuralPOMZeroSrvIndex = UINT_MAX;
|
||||||
@@ -6751,7 +6764,12 @@ struct QD3D12StreamlineState
|
|||||||
uint32_t lastDlssGEligibilityMaskLogged = 0xffffffffu;
|
uint32_t lastDlssGEligibilityMaskLogged = 0xffffffffu;
|
||||||
uint32_t lastDlssGFramesToGenerateLogged = 0xffffffffu;
|
uint32_t lastDlssGFramesToGenerateLogged = 0xffffffffu;
|
||||||
uint32_t lastDlssGPresentedFramesLogged = 0xffffffffu;
|
uint32_t lastDlssGPresentedFramesLogged = 0xffffffffu;
|
||||||
sl::ViewportHandle viewport = { 1 };
|
uint32_t dlssGConfiguredFramesToGenerate = 0xffffffffu;
|
||||||
|
uint32_t dlssGConfiguredRenderWidth = 0xffffffffu;
|
||||||
|
uint32_t dlssGConfiguredRenderHeight = 0xffffffffu;
|
||||||
|
uint32_t dlssGConfiguredColorWidth = 0xffffffffu;
|
||||||
|
uint32_t dlssGConfiguredColorHeight = 0xffffffffu;
|
||||||
|
sl::ViewportHandle viewport = { 0 };
|
||||||
};
|
};
|
||||||
static QD3D12StreamlineState g_qd3d12Sl;
|
static QD3D12StreamlineState g_qd3d12Sl;
|
||||||
|
|
||||||
@@ -7051,10 +7069,7 @@ static void QD3D12_StreamlineOnDeviceCreated()
|
|||||||
|
|
||||||
static bool QD3D12_WantsDLSSRayReconstruction()
|
static bool QD3D12_WantsDLSSRayReconstruction()
|
||||||
{
|
{
|
||||||
return g_gl.enableDLSSRayReconstruction &&
|
return false;
|
||||||
g_gl.upscalerBackend == QD3D12_UPSCALER_DLSS &&
|
|
||||||
g_gl.upscalerQuality != QD3D12_QUALITY_NATIVE &&
|
|
||||||
g_qd3d12Sl.deviceBound;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool QD3D12_CanUseDLSSRayReconstructionForLighting(const QD3D12Window& w)
|
static bool QD3D12_CanUseDLSSRayReconstructionForLighting(const QD3D12Window& w)
|
||||||
@@ -7068,8 +7083,8 @@ static bool QD3D12_UseLightingTextureAsUpscaleInput(const QD3D12Window& w)
|
|||||||
{
|
{
|
||||||
return QD3D12_CanUseDLSSRayReconstructionForLighting(w) &&
|
return QD3D12_CanUseDLSSRayReconstructionForLighting(w) &&
|
||||||
g_gl.raytracedLightingReadyThisFrame &&
|
g_gl.raytracedLightingReadyThisFrame &&
|
||||||
g_lightingTexture &&
|
g_lightingTexture[g_lightingReadIndex] &&
|
||||||
g_lightingTexture->texture;
|
g_lightingTexture[g_lightingReadIndex]->texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
static sl::Result QD3D12_SetStreamlineCommonConstants(sl::FrameToken& frameToken)
|
static sl::Result QD3D12_SetStreamlineCommonConstants(sl::FrameToken& frameToken)
|
||||||
@@ -7127,6 +7142,21 @@ static sl::Result QD3D12_GetStreamlineFrameToken(sl::FrameToken*& frameToken)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static sl::Result QD3D12_EnableReflexForFrame(sl::FrameToken& frameToken)
|
||||||
|
{
|
||||||
|
sl::ReflexOptions reflexOptions{};
|
||||||
|
reflexOptions.mode = sl::ReflexMode::eLowLatencyWithBoost;
|
||||||
|
sl::Result result = slReflexSetOptions(reflexOptions);
|
||||||
|
if (result != sl::Result::eOk)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
result = slReflexSleep(frameToken);
|
||||||
|
if (result != sl::Result::eOk)
|
||||||
|
QD3D12_Log("slReflexSleep failed (%d), continuing with frame generation setup.", int(result));
|
||||||
|
|
||||||
|
return sl::Result::eOk;
|
||||||
|
}
|
||||||
|
|
||||||
static bool QD3D12_WantsDLSSFrameGeneration(const QD3D12Window& w)
|
static bool QD3D12_WantsDLSSFrameGeneration(const QD3D12Window& w)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
@@ -7207,6 +7237,11 @@ static void QD3D12_SetDLSSFrameGenerationOff()
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_qd3d12Sl.dlssGActive = false;
|
g_qd3d12Sl.dlssGActive = false;
|
||||||
|
g_qd3d12Sl.dlssGConfiguredFramesToGenerate = 0xffffffffu;
|
||||||
|
g_qd3d12Sl.dlssGConfiguredRenderWidth = 0xffffffffu;
|
||||||
|
g_qd3d12Sl.dlssGConfiguredRenderHeight = 0xffffffffu;
|
||||||
|
g_qd3d12Sl.dlssGConfiguredColorWidth = 0xffffffffu;
|
||||||
|
g_qd3d12Sl.dlssGConfiguredColorHeight = 0xffffffffu;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void QD3D12_SetDLSSGFeatureLoaded(bool loaded)
|
static void QD3D12_SetDLSSGFeatureLoaded(bool loaded)
|
||||||
@@ -7273,6 +7308,14 @@ static void QD3D12_ConfigureDLSSFrameGeneration(QD3D12Window& w, sl::FrameToken*
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const sl::Result reflexResult = QD3D12_EnableReflexForFrame(*frameToken);
|
||||||
|
if (reflexResult != sl::Result::eOk)
|
||||||
|
{
|
||||||
|
QD3D12_Log("slReflexSetOptions failed (%d), disabling frame generation for this frame.", int(reflexResult));
|
||||||
|
QD3D12_SetDLSSFrameGenerationOff();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const sl::Result constResult = QD3D12_SetStreamlineCommonConstants(*frameToken);
|
const sl::Result constResult = QD3D12_SetStreamlineCommonConstants(*frameToken);
|
||||||
if (constResult != sl::Result::eOk)
|
if (constResult != sl::Result::eOk)
|
||||||
{
|
{
|
||||||
@@ -7281,22 +7324,6 @@ static void QD3D12_ConfigureDLSSFrameGeneration(QD3D12Window& w, sl::FrameToken*
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
sl::ReflexOptions reflexOptions{};
|
|
||||||
reflexOptions.mode = sl::ReflexMode::eLowLatencyWithBoost;
|
|
||||||
const sl::Result reflexOptionsResult = slReflexSetOptions(reflexOptions);
|
|
||||||
if (reflexOptionsResult != sl::Result::eOk)
|
|
||||||
{
|
|
||||||
QD3D12_Log("slReflexSetOptions failed (%d), disabling frame generation for this frame.", int(reflexOptionsResult));
|
|
||||||
QD3D12_SetDLSSFrameGenerationOff();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const sl::Result reflexSleepResult = slReflexSleep(*frameToken);
|
|
||||||
if (reflexSleepResult != sl::Result::eOk)
|
|
||||||
{
|
|
||||||
QD3D12_Log("slReflexSleep failed (%d), continuing with frame generation setup.", int(reflexSleepResult));
|
|
||||||
}
|
|
||||||
|
|
||||||
sl::Extent renderExtent{};
|
sl::Extent renderExtent{};
|
||||||
renderExtent.left = 0;
|
renderExtent.left = 0;
|
||||||
renderExtent.top = 0;
|
renderExtent.top = 0;
|
||||||
@@ -7324,8 +7351,16 @@ static void QD3D12_ConfigureDLSSFrameGeneration(QD3D12Window& w, sl::FrameToken*
|
|||||||
options.hudLessBufferFormat = uint32_t(DXGI_FORMAT_R8G8B8A8_UNORM);
|
options.hudLessBufferFormat = uint32_t(DXGI_FORMAT_R8G8B8A8_UNORM);
|
||||||
options.uiBufferFormat = uint32_t(DXGI_FORMAT_R8G8B8A8_UNORM);
|
options.uiBufferFormat = uint32_t(DXGI_FORMAT_R8G8B8A8_UNORM);
|
||||||
|
|
||||||
|
const bool configMayNeedUpdate =
|
||||||
|
!g_qd3d12Sl.dlssGActive ||
|
||||||
|
g_qd3d12Sl.dlssGConfiguredFramesToGenerate != options.numFramesToGenerate ||
|
||||||
|
g_qd3d12Sl.dlssGConfiguredRenderWidth != w.renderWidth ||
|
||||||
|
g_qd3d12Sl.dlssGConfiguredRenderHeight != w.renderHeight ||
|
||||||
|
g_qd3d12Sl.dlssGConfiguredColorWidth != w.width ||
|
||||||
|
g_qd3d12Sl.dlssGConfiguredColorHeight != w.height;
|
||||||
|
|
||||||
sl::DLSSGState state{};
|
sl::DLSSGState state{};
|
||||||
const sl::Result stateResult = slDLSSGGetState(g_qd3d12Sl.viewport, state, &options);
|
const sl::Result stateResult = slDLSSGGetState(g_qd3d12Sl.viewport, state, configMayNeedUpdate ? &options : nullptr);
|
||||||
if (stateResult == sl::Result::eOk)
|
if (stateResult == sl::Result::eOk)
|
||||||
{
|
{
|
||||||
if (state.numFramesToGenerateMax > 0)
|
if (state.numFramesToGenerateMax > 0)
|
||||||
@@ -7351,12 +7386,29 @@ static void QD3D12_ConfigureDLSSFrameGeneration(QD3D12Window& w, sl::FrameToken*
|
|||||||
|
|
||||||
QD3D12_TagDLSSFrameGenerationInputs(w, *frameToken, renderExtent, outputExtent);
|
QD3D12_TagDLSSFrameGenerationInputs(w, *frameToken, renderExtent, outputExtent);
|
||||||
|
|
||||||
const sl::Result setResult = slDLSSGSetOptions(g_qd3d12Sl.viewport, options);
|
const bool needsSetOptions =
|
||||||
if (setResult != sl::Result::eOk)
|
!g_qd3d12Sl.dlssGActive ||
|
||||||
|
g_qd3d12Sl.dlssGConfiguredFramesToGenerate != options.numFramesToGenerate ||
|
||||||
|
g_qd3d12Sl.dlssGConfiguredRenderWidth != w.renderWidth ||
|
||||||
|
g_qd3d12Sl.dlssGConfiguredRenderHeight != w.renderHeight ||
|
||||||
|
g_qd3d12Sl.dlssGConfiguredColorWidth != w.width ||
|
||||||
|
g_qd3d12Sl.dlssGConfiguredColorHeight != w.height;
|
||||||
|
|
||||||
|
if (needsSetOptions)
|
||||||
{
|
{
|
||||||
QD3D12_Log("slDLSSGSetOptions(on) failed (%d).", int(setResult));
|
const sl::Result setResult = slDLSSGSetOptions(g_qd3d12Sl.viewport, options);
|
||||||
QD3D12_SetDLSSFrameGenerationOff();
|
if (setResult != sl::Result::eOk)
|
||||||
return;
|
{
|
||||||
|
QD3D12_Log("slDLSSGSetOptions(on) failed (%d).", int(setResult));
|
||||||
|
QD3D12_SetDLSSFrameGenerationOff();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_qd3d12Sl.dlssGConfiguredFramesToGenerate = options.numFramesToGenerate;
|
||||||
|
g_qd3d12Sl.dlssGConfiguredRenderWidth = w.renderWidth;
|
||||||
|
g_qd3d12Sl.dlssGConfiguredRenderHeight = w.renderHeight;
|
||||||
|
g_qd3d12Sl.dlssGConfiguredColorWidth = w.width;
|
||||||
|
g_qd3d12Sl.dlssGConfiguredColorHeight = w.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_qd3d12Sl.dlssGActive || g_qd3d12Sl.lastDlssGFramesToGenerateLogged != options.numFramesToGenerate)
|
if (!g_qd3d12Sl.dlssGActive || g_qd3d12Sl.lastDlssGFramesToGenerateLogged != options.numFramesToGenerate)
|
||||||
@@ -7847,11 +7899,8 @@ static bool QD3D12_ExternalTemporalUpscalerActive(const QD3D12Window& w)
|
|||||||
|
|
||||||
static bool QD3D12_ShouldRunInternalTAA(const QD3D12Window& w)
|
static bool QD3D12_ShouldRunInternalTAA(const QD3D12Window& w)
|
||||||
{
|
{
|
||||||
// DLSS/DLSS-RR/FSR are already temporal. The internal TAA pass replaces MSAA
|
(void)w;
|
||||||
// for the native/no-upscaler path and runs after lighting but before 2D.
|
return false;
|
||||||
return g_gl.enableInternalTAA &&
|
|
||||||
!w.isPbuffer &&
|
|
||||||
!QD3D12_ExternalTemporalUpscalerActive(w);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool QD3D12_FinalBlitToBackBuffer(
|
static bool QD3D12_FinalBlitToBackBuffer(
|
||||||
@@ -7985,6 +8034,40 @@ static void QD3D12_ExecuteMainCommandListAndWait(QD3D12Window& w)
|
|||||||
g_gl.frameOwner = &w;
|
g_gl.frameOwner = &w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void QD3D12_ExecuteMainCommandListForRaytracingHandoff(QD3D12Window& w)
|
||||||
|
{
|
||||||
|
QD3D12_CHECK(g_gl.cmdList->Close());
|
||||||
|
|
||||||
|
ID3D12CommandList* lists[] = { g_gl.cmdList.Get() };
|
||||||
|
g_gl.queue->ExecuteCommandLists(1, lists);
|
||||||
|
|
||||||
|
const UINT64 signalValue = g_gl.nextFenceValue++;
|
||||||
|
QD3D12_CHECK(g_gl.queue->Signal(g_gl.fence.Get(), signalValue));
|
||||||
|
w.frames[w.frameIndex].fenceValue = signalValue;
|
||||||
|
|
||||||
|
const UINT slot = g_gl.raytraceContinuationIndex++ % QD3D12_FrameCount;
|
||||||
|
const UINT64 continuationFence = g_gl.raytraceContinuationFence[slot];
|
||||||
|
if (continuationFence != 0 && g_gl.fence->GetCompletedValue() < continuationFence)
|
||||||
|
{
|
||||||
|
QD3D12_CHECK(g_gl.fence->SetEventOnCompletion(continuationFence, g_gl.fenceEvent));
|
||||||
|
WaitForSingleObject(g_gl.fenceEvent, INFINITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!g_gl.raytraceContinuationAlloc[slot])
|
||||||
|
{
|
||||||
|
QD3D12_CHECK(g_gl.device->CreateCommandAllocator(
|
||||||
|
D3D12_COMMAND_LIST_TYPE_DIRECT,
|
||||||
|
IID_PPV_ARGS(&g_gl.raytraceContinuationAlloc[slot])));
|
||||||
|
}
|
||||||
|
|
||||||
|
QD3D12_CHECK(g_gl.raytraceContinuationAlloc[slot]->Reset());
|
||||||
|
QD3D12_CHECK(g_gl.cmdList->Reset(g_gl.raytraceContinuationAlloc[slot].Get(), nullptr));
|
||||||
|
|
||||||
|
g_gl.activeRaytraceContinuationSlot = (int)slot;
|
||||||
|
g_gl.frameOpen = true;
|
||||||
|
g_gl.frameOwner = &w;
|
||||||
|
}
|
||||||
|
|
||||||
static void QD3D12_RunRayAIDenoiseIfEnabled(ID3D12GraphicsCommandList* cl, QD3D12Window& w, ID3D12Resource* lightingResource)
|
static void QD3D12_RunRayAIDenoiseIfEnabled(ID3D12GraphicsCommandList* cl, QD3D12Window& w, ID3D12Resource* lightingResource)
|
||||||
{
|
{
|
||||||
(void)cl;
|
(void)cl;
|
||||||
@@ -8016,10 +8099,11 @@ static void QD3D12_RunUpscalerOrBlit(QD3D12Window& w)
|
|||||||
ID3D12Resource* upscaleInputResource = w.sceneColorBuffers[w.frameIndex].Get();
|
ID3D12Resource* upscaleInputResource = w.sceneColorBuffers[w.frameIndex].Get();
|
||||||
D3D12_GPU_DESCRIPTOR_HANDLE upscaleInputSrv = w.sceneColorSrvGpu[w.frameIndex];
|
D3D12_GPU_DESCRIPTOR_HANDLE upscaleInputSrv = w.sceneColorSrvGpu[w.frameIndex];
|
||||||
|
|
||||||
if (useLightingUpscaleInput && g_lightingTexture && g_lightingTexture->texture)
|
TextureResource* readLightingTex = g_lightingTexture[g_lightingReadIndex];
|
||||||
|
if (useLightingUpscaleInput && readLightingTex && readLightingTex->texture)
|
||||||
{
|
{
|
||||||
upscaleInputResource = g_lightingTexture->texture.Get();
|
upscaleInputResource = readLightingTex->texture.Get();
|
||||||
upscaleInputSrv = g_lightingTexture->srvGpu;
|
upscaleInputSrv = readLightingTex->srvGpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12_VIEWPORT outputViewport{};
|
D3D12_VIEWPORT outputViewport{};
|
||||||
@@ -10069,6 +10153,15 @@ void QD3D12_EndFrame()
|
|||||||
ID3D12CommandList* lists[] = { g_gl.cmdList.Get() };
|
ID3D12CommandList* lists[] = { g_gl.cmdList.Get() };
|
||||||
g_gl.queue->ExecuteCommandLists(1, lists);
|
g_gl.queue->ExecuteCommandLists(1, lists);
|
||||||
|
|
||||||
|
if (g_gl.activeRaytraceContinuationSlot >= 0)
|
||||||
|
{
|
||||||
|
const UINT slot = (UINT)g_gl.activeRaytraceContinuationSlot;
|
||||||
|
const UINT64 signalValue = g_gl.nextFenceValue++;
|
||||||
|
QD3D12_CHECK(g_gl.queue->Signal(g_gl.fence.Get(), signalValue));
|
||||||
|
g_gl.raytraceContinuationFence[slot] = signalValue;
|
||||||
|
g_gl.activeRaytraceContinuationSlot = -1;
|
||||||
|
}
|
||||||
|
|
||||||
g_gl.frameOpen = false;
|
g_gl.frameOpen = false;
|
||||||
g_gl.frameOwner = nullptr;
|
g_gl.frameOwner = nullptr;
|
||||||
if (!w.isPbuffer)
|
if (!w.isPbuffer)
|
||||||
@@ -10300,16 +10393,17 @@ static void EnsureTextureResource(TextureResource& tex)
|
|||||||
tex.gpuValid = false;
|
tex.gpuValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static TextureResource* QD3D12_EnsureLightingTexture(int width, int height)
|
static TextureResource* QD3D12_EnsureLightingTexture(int width, int height, UINT slot)
|
||||||
{
|
{
|
||||||
const DXGI_FORMAT desiredFormat = DXGI_FORMAT_R16G16B16A16_FLOAT;
|
const DXGI_FORMAT desiredFormat = DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||||
|
slot %= QD3D12_LightingTextureCount;
|
||||||
|
|
||||||
if (g_lightingTextureId == 0)
|
if (g_lightingTextureId[slot] == 0)
|
||||||
{
|
{
|
||||||
g_lightingTextureId = g_gl.nextTextureId++;
|
g_lightingTextureId[slot] = g_gl.nextTextureId++;
|
||||||
|
|
||||||
TextureResource tex{};
|
TextureResource tex{};
|
||||||
tex.glId = g_lightingTextureId;
|
tex.glId = g_lightingTextureId[slot];
|
||||||
tex.width = (int)width;
|
tex.width = (int)width;
|
||||||
tex.height = (int)height;
|
tex.height = (int)height;
|
||||||
tex.format = GL_RGBA;
|
tex.format = GL_RGBA;
|
||||||
@@ -10329,44 +10423,45 @@ static TextureResource* QD3D12_EnsureLightingTexture(int width, int height)
|
|||||||
tex.srvCpu = QD3D12_SrvCpu(tex.srvIndex);
|
tex.srvCpu = QD3D12_SrvCpu(tex.srvIndex);
|
||||||
tex.srvGpu = QD3D12_SrvGpu(tex.srvIndex);
|
tex.srvGpu = QD3D12_SrvGpu(tex.srvIndex);
|
||||||
|
|
||||||
auto it = g_gl.textures.emplace(g_lightingTextureId, std::move(tex)).first;
|
auto it = g_gl.textures.emplace(g_lightingTextureId[slot], std::move(tex)).first;
|
||||||
g_lightingTexture = &it->second;
|
g_lightingTexture[slot] = &it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_lightingTexture)
|
if (!g_lightingTexture[slot])
|
||||||
{
|
{
|
||||||
auto it = g_gl.textures.find(g_lightingTextureId);
|
auto it = g_gl.textures.find(g_lightingTextureId[slot]);
|
||||||
if (it == g_gl.textures.end())
|
if (it == g_gl.textures.end())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
g_lightingTexture = &it->second;
|
g_lightingTexture[slot] = &it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_lightingTexture->dxgiFormat = desiredFormat;
|
TextureResource* lightingTex = g_lightingTexture[slot];
|
||||||
g_lightingTexture->mipLevels = 1;
|
lightingTex->dxgiFormat = desiredFormat;
|
||||||
|
lightingTex->mipLevels = 1;
|
||||||
|
|
||||||
const bool needsCreate =
|
const bool needsCreate =
|
||||||
!g_lightingTexture->texture ||
|
!lightingTex->texture ||
|
||||||
g_lightingTexture->width != (int)width ||
|
lightingTex->width != (int)width ||
|
||||||
g_lightingTexture->height != (int)height ||
|
lightingTex->height != (int)height ||
|
||||||
g_lightingTexture->texture->GetDesc().Format != desiredFormat ||
|
lightingTex->texture->GetDesc().Format != desiredFormat ||
|
||||||
((g_lightingTexture->texture->GetDesc().Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS) == 0);
|
((lightingTex->texture->GetDesc().Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS) == 0);
|
||||||
|
|
||||||
if (!needsCreate)
|
if (!needsCreate)
|
||||||
return g_lightingTexture;
|
return lightingTex;
|
||||||
|
|
||||||
if (g_lightingTexture->texture)
|
if (lightingTex->texture)
|
||||||
{
|
{
|
||||||
QD3D12_RetireResource(g_lightingTexture->texture);
|
QD3D12_RetireResource(lightingTex->texture);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_lightingTexture->width = (int)width;
|
lightingTex->width = (int)width;
|
||||||
g_lightingTexture->height = (int)height;
|
lightingTex->height = (int)height;
|
||||||
g_lightingTexture->compressed = false;
|
lightingTex->compressed = false;
|
||||||
g_lightingTexture->compressedInternalFormat = 0;
|
lightingTex->compressedInternalFormat = 0;
|
||||||
g_lightingTexture->compressedBlockBytes = 0;
|
lightingTex->compressedBlockBytes = 0;
|
||||||
g_lightingTexture->compressedImageSize = 0;
|
lightingTex->compressedImageSize = 0;
|
||||||
g_lightingTexture->forceOpaqueAlpha = false;
|
lightingTex->forceOpaqueAlpha = false;
|
||||||
g_lightingTexture->sysmem.clear();
|
lightingTex->sysmem.clear();
|
||||||
|
|
||||||
D3D12_RESOURCE_DESC rd{};
|
D3D12_RESOURCE_DESC rd{};
|
||||||
rd.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
|
rd.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
|
||||||
@@ -10390,7 +10485,7 @@ static TextureResource* QD3D12_EnsureLightingTexture(int width, int height)
|
|||||||
&rd,
|
&rd,
|
||||||
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
|
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
|
||||||
nullptr,
|
nullptr,
|
||||||
IID_PPV_ARGS(&g_lightingTexture->texture)));
|
IID_PPV_ARGS(&lightingTex->texture)));
|
||||||
|
|
||||||
D3D12_SHADER_RESOURCE_VIEW_DESC srv{};
|
D3D12_SHADER_RESOURCE_VIEW_DESC srv{};
|
||||||
srv.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
|
srv.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
|
||||||
@@ -10399,15 +10494,16 @@ static TextureResource* QD3D12_EnsureLightingTexture(int width, int height)
|
|||||||
srv.Texture2D.MipLevels = 1;
|
srv.Texture2D.MipLevels = 1;
|
||||||
|
|
||||||
g_gl.device->CreateShaderResourceView(
|
g_gl.device->CreateShaderResourceView(
|
||||||
g_lightingTexture->texture.Get(),
|
lightingTex->texture.Get(),
|
||||||
&srv,
|
&srv,
|
||||||
g_lightingTexture->srvCpu);
|
lightingTex->srvCpu);
|
||||||
|
|
||||||
g_lightingTexture->gpuValid = true;
|
lightingTex->gpuValid = true;
|
||||||
g_lightingTexture->state = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
lightingTex->state = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
||||||
g_lightingTextureState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
g_lightingTextureState[slot] = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
||||||
|
g_lightingTextureValid[slot] = false;
|
||||||
|
|
||||||
return g_lightingTexture;
|
return lightingTex;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ConvertToRGBA8(const TextureResource& tex, std::vector<uint8_t>& outRGBA)
|
static void ConvertToRGBA8(const TextureResource& tex, std::vector<uint8_t>& outRGBA)
|
||||||
@@ -16733,9 +16829,15 @@ static void QD3D12_ResolveSceneToOutputAndEnterNativePhase(QD3D12Window& w)
|
|||||||
{
|
{
|
||||||
QD3D12_TransitionResource(cl, w.normalBuffers[w.frameIndex].Get(), w.normalBufferState[w.frameIndex], D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
QD3D12_TransitionResource(cl, w.normalBuffers[w.frameIndex].Get(), w.normalBufferState[w.frameIndex], D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
||||||
|
|
||||||
if (g_lightingTexture && g_lightingTexture->texture)
|
TextureResource* readLightingTex = g_lightingTexture[g_lightingReadIndex];
|
||||||
|
if (readLightingTex && readLightingTex->texture)
|
||||||
{
|
{
|
||||||
QD3D12_TransitionResource(cl, g_lightingTexture->texture.Get(), g_lightingTextureState, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
QD3D12_TransitionResource(
|
||||||
|
cl,
|
||||||
|
readLightingTex->texture.Get(),
|
||||||
|
g_lightingTextureState[g_lightingReadIndex],
|
||||||
|
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
||||||
|
g_lightingTextureState[g_lightingReadIndex] = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16771,8 +16873,14 @@ void glLightScene(glRaytracingSceneHandle_t sceneHandle)
|
|||||||
|
|
||||||
QD3D12_EnsureFrameOpen();
|
QD3D12_EnsureFrameOpen();
|
||||||
|
|
||||||
TextureResource* lightingTex = QD3D12_EnsureLightingTexture(width, height);
|
const UINT writeLightingIndex = g_lightingWriteIndex % QD3D12_LightingTextureCount;
|
||||||
if (!lightingTex || !lightingTex->texture)
|
const UINT previousLightingIndex = writeLightingIndex ^ 1u;
|
||||||
|
|
||||||
|
TextureResource* writeLightingTex = QD3D12_EnsureLightingTexture(width, height, writeLightingIndex);
|
||||||
|
(void)QD3D12_EnsureLightingTexture(width, height, previousLightingIndex);
|
||||||
|
const UINT readLightingIndex = writeLightingIndex;
|
||||||
|
TextureResource* readLightingTex = g_lightingTexture[readLightingIndex];
|
||||||
|
if (!writeLightingTex || !writeLightingTex->texture || !readLightingTex || !readLightingTex->texture)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Scene/TLAS ownership is now per render world. Querying the scene TLAS here
|
// Scene/TLAS ownership is now per render world. Querying the scene TLAS here
|
||||||
@@ -16835,18 +16943,18 @@ void glLightScene(glRaytracingSceneHandle_t sceneHandle)
|
|||||||
// The external DXR module records and executes its own command list. Because
|
// The external DXR module records and executes its own command list. Because
|
||||||
// of that, the scene input transitions must be submitted on the main command
|
// of that, the scene input transitions must be submitted on the main command
|
||||||
// list before we call into glRaytracingLightingExecuteForScene.
|
// list before we call into glRaytracingLightingExecuteForScene.
|
||||||
if (g_lightingTextureState != D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE)
|
if (g_lightingTextureState[writeLightingIndex] != D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE)
|
||||||
{
|
{
|
||||||
QD3D12_TransitionResource(
|
QD3D12_TransitionResource(
|
||||||
cl,
|
cl,
|
||||||
lightingTex->texture.Get(),
|
writeLightingTex->texture.Get(),
|
||||||
g_lightingTextureState,
|
g_lightingTextureState[writeLightingIndex],
|
||||||
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
||||||
|
|
||||||
g_lightingTextureState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
g_lightingTextureState[writeLightingIndex] = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
QD3D12_ExecuteMainCommandListAndWait(*window);
|
QD3D12_ExecuteMainCommandListForRaytracingHandoff(*window);
|
||||||
cl = g_gl.cmdList.Get();
|
cl = g_gl.cmdList.Get();
|
||||||
|
|
||||||
QD3D12_UpdateCameraInfoFromCurrentMatrices();
|
QD3D12_UpdateCameraInfoFromCurrentMatrices();
|
||||||
@@ -16883,8 +16991,8 @@ void glLightScene(glRaytracingSceneHandle_t sceneHandle)
|
|||||||
pass.depthTexture = sceneDepth;
|
pass.depthTexture = sceneDepth;
|
||||||
pass.depthFormat = QD3D12_DepthSrvFormat;
|
pass.depthFormat = QD3D12_DepthSrvFormat;
|
||||||
|
|
||||||
pass.outputTexture = lightingTex->texture.Get();
|
pass.outputTexture = writeLightingTex->texture.Get();
|
||||||
pass.outputFormat = lightingTex->dxgiFormat;
|
pass.outputFormat = writeLightingTex->dxgiFormat;
|
||||||
|
|
||||||
pass.width = (uint32_t)width;
|
pass.width = (uint32_t)width;
|
||||||
pass.height = (uint32_t)height;
|
pass.height = (uint32_t)height;
|
||||||
@@ -16945,21 +17053,25 @@ void glLightScene(glRaytracingSceneHandle_t sceneHandle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The scene-handle DXR path leaves outputTexture in PIXEL_SHADER_RESOURCE.
|
// The scene-handle DXR path leaves outputTexture in PIXEL_SHADER_RESOURCE.
|
||||||
g_lightingTextureState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
g_lightingTextureState[writeLightingIndex] = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
||||||
|
g_lightingTextureValid[writeLightingIndex] = true;
|
||||||
|
g_lightingReadIndex = readLightingIndex;
|
||||||
|
g_lightingWriteIndex = previousLightingIndex;
|
||||||
|
|
||||||
QD3D12_RunRayAIDenoiseIfEnabled(cl, *window, lightingTex->texture.Get());
|
QD3D12_RunRayAIDenoiseIfEnabled(cl, *window, writeLightingTex->texture.Get());
|
||||||
|
|
||||||
// If the denoiser changes the texture state and updates g_lightingTextureState,
|
// If the denoiser changes the written texture state, restore it to a
|
||||||
|
// shader-readable state before this slot becomes the next read target.
|
||||||
// restore the texture to a shader-readable state for the post/upscale pass.
|
// restore the texture to a shader-readable state for the post/upscale pass.
|
||||||
if (g_lightingTextureState != D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE)
|
if (g_lightingTextureState[writeLightingIndex] != D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE)
|
||||||
{
|
{
|
||||||
QD3D12_TransitionResource(
|
QD3D12_TransitionResource(
|
||||||
cl,
|
cl,
|
||||||
lightingTex->texture.Get(),
|
writeLightingTex->texture.Get(),
|
||||||
g_lightingTextureState,
|
g_lightingTextureState[writeLightingIndex],
|
||||||
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
|
||||||
|
|
||||||
g_lightingTextureState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
g_lightingTextureState[writeLightingIndex] = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_gl.raytracedLightingReadyThisFrame = true;
|
g_gl.raytracedLightingReadyThisFrame = true;
|
||||||
@@ -16992,7 +17104,7 @@ void glLightScene(glRaytracingSceneHandle_t sceneHandle)
|
|||||||
// in QD3D12_FinalBlitToBackBuffer().
|
// in QD3D12_FinalBlitToBackBuffer().
|
||||||
if (!QD3D12_ToneMapFullscreenPass(
|
if (!QD3D12_ToneMapFullscreenPass(
|
||||||
*window,
|
*window,
|
||||||
lightingTex->srvGpu,
|
readLightingTex->srvGpu,
|
||||||
CurrentResolvedSceneColorRTV(),
|
CurrentResolvedSceneColorRTV(),
|
||||||
viewport,
|
viewport,
|
||||||
scissor,
|
scissor,
|
||||||
@@ -17002,7 +17114,7 @@ void glLightScene(glRaytracingSceneHandle_t sceneHandle)
|
|||||||
QD3D12_PostFullscreenPass(
|
QD3D12_PostFullscreenPass(
|
||||||
cl,
|
cl,
|
||||||
g_gl.postCopyPSO.Get(),
|
g_gl.postCopyPSO.Get(),
|
||||||
lightingTex->srvGpu,
|
readLightingTex->srvGpu,
|
||||||
CurrentResolvedSceneColorRTV(),
|
CurrentResolvedSceneColorRTV(),
|
||||||
viewport,
|
viewport,
|
||||||
scissor,
|
scissor,
|
||||||
@@ -17177,7 +17289,8 @@ static void QD3D12_ResetInternalTAAHistoryForWindow(QD3D12Window* window)
|
|||||||
|
|
||||||
void QD3D12_EnableTAA(int enabled)
|
void QD3D12_EnableTAA(int enabled)
|
||||||
{
|
{
|
||||||
const bool newValue = enabled ? true : false;
|
(void)enabled;
|
||||||
|
const bool newValue = false;
|
||||||
if (g_gl.enableInternalTAA == newValue)
|
if (g_gl.enableInternalTAA == newValue)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -17193,7 +17306,7 @@ void QD3D12_EnableTAA(int enabled)
|
|||||||
|
|
||||||
int QD3D12_IsTAAEnabled(void)
|
int QD3D12_IsTAAEnabled(void)
|
||||||
{
|
{
|
||||||
return g_gl.enableInternalTAA ? 1 : 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void APIENTRY glTAAQD3D12(GLboolean enable)
|
void APIENTRY glTAAQD3D12(GLboolean enable)
|
||||||
@@ -17270,7 +17383,8 @@ void QD3D12_EnableRayAIDenoise(int enabled)
|
|||||||
|
|
||||||
void QD3D12_EnableDLSSRayReconstruction(int enabled)
|
void QD3D12_EnableDLSSRayReconstruction(int enabled)
|
||||||
{
|
{
|
||||||
const bool newValue = enabled ? true : false;
|
(void)enabled;
|
||||||
|
const bool newValue = false;
|
||||||
if (g_gl.enableDLSSRayReconstruction == newValue)
|
if (g_gl.enableDLSSRayReconstruction == newValue)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user