mirror of
https://github.com/jmarshall23/DoomRTX.git
synced 2026-08-17 19:23:51 +02:00
Framegen now works and increase light bounce to 3.
This commit is contained in:
@@ -2434,11 +2434,12 @@ struct glRaytracingLightingState_t
|
||||
|
||||
ComPtr<ID3D12PipelineState> denoisePSO;
|
||||
ComPtr<ID3D12PipelineState> temporalPSO;
|
||||
glRaytracingTexture_t pathTraceTexture;
|
||||
glRaytracingTexture_t pathTraceTexture[2];
|
||||
glRaytracingTexture_t temporalTexture;
|
||||
glRaytracingTexture_t historyTexture[2];
|
||||
glRaytracingTexture_t denoiseTemp[2];
|
||||
uint32_t currentHistoryIndex;
|
||||
uint32_t currentPathTraceIndex;
|
||||
glRaytracingBuffer_t denoiseConstantBuffer[3];
|
||||
glRaytracingBuffer_t denoiseConstantBufferRing[GL_RAYTRACING_CMD_RING_SIZE][3];
|
||||
void* denoiseConstantBufferMapped[3];
|
||||
@@ -2474,6 +2475,7 @@ struct glRaytracingLightingState_t
|
||||
denoiseHeight = 0;
|
||||
denoiseFormat = DXGI_FORMAT_UNKNOWN;
|
||||
currentHistoryIndex = 0;
|
||||
currentPathTraceIndex = 0;
|
||||
frameCounter = 0;
|
||||
externalDenoiser = false;
|
||||
emissiveTexture = nullptr;
|
||||
@@ -4707,7 +4709,7 @@ float3 PathTraceDeterministicLighting(
|
||||
float3 skyColorRGB = float3(0.98, 0.55, 0.35);
|
||||
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 += ambientSkyVis * (skyColorRGB * 0.12);
|
||||
|
||||
@@ -6243,7 +6245,8 @@ static int glRaytracingLightingEnsureDenoiseResources(UINT width, UINT height)
|
||||
if (width == 0 || height == 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.historyTexture[0].resource &&
|
||||
g_glRaytracingLighting.historyTexture[1].resource &&
|
||||
@@ -6256,7 +6259,8 @@ static int glRaytracingLightingEnsureDenoiseResources(UINT width, UINT height)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (g_glRaytracingLighting.pathTraceTexture.resource ||
|
||||
if (g_glRaytracingLighting.pathTraceTexture[0].resource ||
|
||||
g_glRaytracingLighting.pathTraceTexture[1].resource ||
|
||||
g_glRaytracingLighting.temporalTexture.resource ||
|
||||
g_glRaytracingLighting.historyTexture[0].resource ||
|
||||
g_glRaytracingLighting.historyTexture[1].resource ||
|
||||
@@ -6266,20 +6270,24 @@ static int glRaytracingLightingEnsureDenoiseResources(UINT width, UINT height)
|
||||
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.historyTexture[0] = glRaytracingTexture_t();
|
||||
g_glRaytracingLighting.historyTexture[1] = glRaytracingTexture_t();
|
||||
g_glRaytracingLighting.denoiseTemp[0] = glRaytracingTexture_t();
|
||||
g_glRaytracingLighting.denoiseTemp[1] = glRaytracingTexture_t();
|
||||
|
||||
g_glRaytracingLighting.pathTraceTexture = glRaytracingCreateTexture2D(
|
||||
g_glRaytracingCmd.device.Get(),
|
||||
width,
|
||||
height,
|
||||
GL_RAYTRACING_DENOISE_FORMAT,
|
||||
D3D12_RESOURCE_STATE_UNORDERED_ACCESS,
|
||||
D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS);
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
g_glRaytracingLighting.pathTraceTexture[i] = glRaytracingCreateTexture2D(
|
||||
g_glRaytracingCmd.device.Get(),
|
||||
width,
|
||||
height,
|
||||
GL_RAYTRACING_DENOISE_FORMAT,
|
||||
D3D12_RESOURCE_STATE_UNORDERED_ACCESS,
|
||||
D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS);
|
||||
}
|
||||
|
||||
g_glRaytracingLighting.temporalTexture = glRaytracingCreateTexture2D(
|
||||
g_glRaytracingCmd.device.Get(),
|
||||
@@ -6311,7 +6319,8 @@ static int glRaytracingLightingEnsureDenoiseResources(UINT width, UINT height)
|
||||
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.historyTexture[0].resource ||
|
||||
!g_glRaytracingLighting.historyTexture[1].resource ||
|
||||
@@ -6322,6 +6331,7 @@ static int glRaytracingLightingEnsureDenoiseResources(UINT width, UINT height)
|
||||
}
|
||||
|
||||
g_glRaytracingLighting.currentHistoryIndex = 0;
|
||||
g_glRaytracingLighting.currentPathTraceIndex = 0;
|
||||
g_glRaytracingLighting.denoiseWidth = width;
|
||||
g_glRaytracingLighting.denoiseHeight = height;
|
||||
g_glRaytracingLighting.denoiseFormat = GL_RAYTRACING_DENOISE_FORMAT;
|
||||
@@ -6486,7 +6496,7 @@ static bool glRaytracingLightingExecuteInternal(
|
||||
!g_glRaytracingLighting.externalDenoiser;
|
||||
|
||||
ID3D12Resource* rayOutputTexture = useInternalDenoiser
|
||||
? g_glRaytracingLighting.pathTraceTexture.resource.Get()
|
||||
? g_glRaytracingLighting.pathTraceTexture[g_glRaytracingLighting.currentPathTraceIndex & 1u].resource.Get()
|
||||
: pass->outputTexture;
|
||||
|
||||
if (!glRaytracingBeginCmd())
|
||||
@@ -6517,12 +6527,14 @@ static bool glRaytracingLightingExecuteInternal(
|
||||
|
||||
const uint32_t historyReadIndex = g_glRaytracingLighting.currentHistoryIndex & 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(
|
||||
pass,
|
||||
topLevelAS,
|
||||
rayOutputTexture,
|
||||
g_glRaytracingLighting.pathTraceTexture.resource.Get(),
|
||||
pathTraceTexture.resource.Get(),
|
||||
g_glRaytracingLighting.denoiseTemp[0].resource.Get(),
|
||||
g_glRaytracingLighting.denoiseTemp[1].resource.Get(),
|
||||
g_glRaytracingLighting.historyTexture[historyReadIndex].resource.Get(),
|
||||
@@ -6532,10 +6544,10 @@ static bool glRaytracingLightingExecuteInternal(
|
||||
if (useInternalDenoiser)
|
||||
{
|
||||
glRaytracingTransition(g_glRaytracingCmd.cmdList.Get(),
|
||||
g_glRaytracingLighting.pathTraceTexture.resource.Get(),
|
||||
g_glRaytracingLighting.pathTraceTexture.state,
|
||||
pathTraceTexture.resource.Get(),
|
||||
pathTraceTexture.state,
|
||||
D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
g_glRaytracingLighting.pathTraceTexture.state = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||
pathTraceTexture.state = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -6598,10 +6610,10 @@ static bool glRaytracingLightingExecuteInternal(
|
||||
const UINT groupsY = (pass->height + 7u) / 8u;
|
||||
|
||||
glRaytracingTransition(g_glRaytracingCmd.cmdList.Get(),
|
||||
g_glRaytracingLighting.pathTraceTexture.resource.Get(),
|
||||
g_glRaytracingLighting.pathTraceTexture.state,
|
||||
pathTraceTexture.resource.Get(),
|
||||
pathTraceTexture.state,
|
||||
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(),
|
||||
g_glRaytracingLighting.temporalTexture.resource.Get(),
|
||||
@@ -6737,7 +6749,10 @@ static bool glRaytracingLightingExecuteInternal(
|
||||
g_glRaytracingCmd.pathTracingTimestampFenceRing[g_glRaytracingCmd.cmdCurrentSlot] = g_glRaytracingCmd.cmdLastFenceValue;
|
||||
|
||||
if (useInternalDenoiser)
|
||||
{
|
||||
g_glRaytracingLighting.currentHistoryIndex = historyWriteIndex;
|
||||
g_glRaytracingLighting.currentPathTraceIndex = (pathTraceIndex ^ 1u);
|
||||
}
|
||||
|
||||
++g_glRaytracingLighting.frameCounter;
|
||||
return true;
|
||||
@@ -6795,6 +6810,7 @@ bool glRaytracingLightingInit(void)
|
||||
return false;
|
||||
|
||||
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.invViewMatrix);
|
||||
glRaytracingSetIdentity4x4(g_glRaytracingLighting.constants.viewProj);
|
||||
|
||||
Reference in New Issue
Block a user