Framegen now works and increase light bounce to 3.

This commit is contained in:
Justin Marshall
2026-05-21 17:43:28 -07:00
parent 28a1d31c28
commit 1f5f0733fe
5 changed files with 277 additions and 126 deletions
+214 -100
View File
@@ -373,6 +373,7 @@ static void QD3D12_SubmitOpenFrameNoPresentAndWait();
static void QD3D12_EnsureFrameOpen();
static void QD3D12_RunUpscalerOrBlit(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_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);
@@ -1483,6 +1484,10 @@ struct GLState
GLenum depthFunc = GL_LEQUAL;
UINT64 nextFenceValue = 1;
ComPtr<ID3D12CommandAllocator> raytraceContinuationAlloc[QD3D12_FrameCount];
UINT64 raytraceContinuationFence[QD3D12_FrameCount] = {};
UINT raytraceContinuationIndex = 0;
int activeRaytraceContinuationSlot = -1;
GLuint currentMotionObjectId = 0;
float currentSurfaceRoughness = 0.5f;
@@ -1500,14 +1505,14 @@ struct GLState
QD3D12UpscalerBackend upscalerBackend = QD3D12_UPSCALER_DLSS;
QD3D12UpscalerQuality upscalerQuality = QD3D12_QUALITY_DLAA;
bool enableInternalTAA = true;
bool enableInternalTAA = false;
bool enableRayAIDenoise = false;
bool enableDLSSRayReconstruction = true;
bool enableDLSSRayReconstruction = false;
bool enableFSRRayRegeneration = false;
uint32_t frameGenerationMultiplier = 2;
uint32_t pathTracingSamplesPerPixel = 1;
uint32_t pathTracingFallbackSamplesPerPixel = 2;
uint32_t pathTracingMaxBounces = 2;
uint32_t pathTracingMaxBounces = 3;
float jitterX = 0.0f;
float jitterY = 0.0f;
@@ -2250,9 +2255,17 @@ void QD3D12_SetCurrentWindow(struct QD3D12Window* window) {
g_qd3d12CurrentDC = window->hdc;
}
static GLuint g_lightingTextureId = 0;
static TextureResource* g_lightingTexture = nullptr;
static D3D12_RESOURCE_STATES g_lightingTextureState = D3D12_RESOURCE_STATE_COMMON;
static constexpr UINT QD3D12_LightingTextureCount = 2;
static GLuint g_lightingTextureId[QD3D12_LightingTextureCount] = {};
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 UINT g_qd3d12NeuralPOMZeroSrvIndex = UINT_MAX;
@@ -6751,7 +6764,12 @@ struct QD3D12StreamlineState
uint32_t lastDlssGEligibilityMaskLogged = 0xffffffffu;
uint32_t lastDlssGFramesToGenerateLogged = 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;
@@ -7051,10 +7069,7 @@ static void QD3D12_StreamlineOnDeviceCreated()
static bool QD3D12_WantsDLSSRayReconstruction()
{
return g_gl.enableDLSSRayReconstruction &&
g_gl.upscalerBackend == QD3D12_UPSCALER_DLSS &&
g_gl.upscalerQuality != QD3D12_QUALITY_NATIVE &&
g_qd3d12Sl.deviceBound;
return false;
}
static bool QD3D12_CanUseDLSSRayReconstructionForLighting(const QD3D12Window& w)
@@ -7068,8 +7083,8 @@ static bool QD3D12_UseLightingTextureAsUpscaleInput(const QD3D12Window& w)
{
return QD3D12_CanUseDLSSRayReconstructionForLighting(w) &&
g_gl.raytracedLightingReadyThisFrame &&
g_lightingTexture &&
g_lightingTexture->texture;
g_lightingTexture[g_lightingReadIndex] &&
g_lightingTexture[g_lightingReadIndex]->texture;
}
static sl::Result QD3D12_SetStreamlineCommonConstants(sl::FrameToken& frameToken)
@@ -7127,6 +7142,21 @@ static sl::Result QD3D12_GetStreamlineFrameToken(sl::FrameToken*& frameToken)
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)
{
return
@@ -7207,6 +7237,11 @@ static void QD3D12_SetDLSSFrameGenerationOff()
}
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)
@@ -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);
if (constResult != sl::Result::eOk)
{
@@ -7281,22 +7324,6 @@ static void QD3D12_ConfigureDLSSFrameGeneration(QD3D12Window& w, sl::FrameToken*
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{};
renderExtent.left = 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.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{};
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 (state.numFramesToGenerateMax > 0)
@@ -7351,12 +7386,29 @@ static void QD3D12_ConfigureDLSSFrameGeneration(QD3D12Window& w, sl::FrameToken*
QD3D12_TagDLSSFrameGenerationInputs(w, *frameToken, renderExtent, outputExtent);
const sl::Result setResult = slDLSSGSetOptions(g_qd3d12Sl.viewport, options);
if (setResult != sl::Result::eOk)
const bool needsSetOptions =
!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));
QD3D12_SetDLSSFrameGenerationOff();
return;
const sl::Result setResult = slDLSSGSetOptions(g_qd3d12Sl.viewport, options);
if (setResult != sl::Result::eOk)
{
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)
@@ -7847,11 +7899,8 @@ static bool QD3D12_ExternalTemporalUpscalerActive(const QD3D12Window& w)
static bool QD3D12_ShouldRunInternalTAA(const QD3D12Window& w)
{
// DLSS/DLSS-RR/FSR are already temporal. The internal TAA pass replaces MSAA
// for the native/no-upscaler path and runs after lighting but before 2D.
return g_gl.enableInternalTAA &&
!w.isPbuffer &&
!QD3D12_ExternalTemporalUpscalerActive(w);
(void)w;
return false;
}
static bool QD3D12_FinalBlitToBackBuffer(
@@ -7985,6 +8034,40 @@ static void QD3D12_ExecuteMainCommandListAndWait(QD3D12Window& 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)
{
(void)cl;
@@ -8016,10 +8099,11 @@ static void QD3D12_RunUpscalerOrBlit(QD3D12Window& w)
ID3D12Resource* upscaleInputResource = w.sceneColorBuffers[w.frameIndex].Get();
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();
upscaleInputSrv = g_lightingTexture->srvGpu;
upscaleInputResource = readLightingTex->texture.Get();
upscaleInputSrv = readLightingTex->srvGpu;
}
D3D12_VIEWPORT outputViewport{};
@@ -10069,6 +10153,15 @@ void QD3D12_EndFrame()
ID3D12CommandList* lists[] = { g_gl.cmdList.Get() };
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.frameOwner = nullptr;
if (!w.isPbuffer)
@@ -10300,16 +10393,17 @@ static void EnsureTextureResource(TextureResource& tex)
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;
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{};
tex.glId = g_lightingTextureId;
tex.glId = g_lightingTextureId[slot];
tex.width = (int)width;
tex.height = (int)height;
tex.format = GL_RGBA;
@@ -10329,44 +10423,45 @@ static TextureResource* QD3D12_EnsureLightingTexture(int width, int height)
tex.srvCpu = QD3D12_SrvCpu(tex.srvIndex);
tex.srvGpu = QD3D12_SrvGpu(tex.srvIndex);
auto it = g_gl.textures.emplace(g_lightingTextureId, std::move(tex)).first;
g_lightingTexture = &it->second;
auto it = g_gl.textures.emplace(g_lightingTextureId[slot], std::move(tex)).first;
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())
return nullptr;
g_lightingTexture = &it->second;
g_lightingTexture[slot] = &it->second;
}
g_lightingTexture->dxgiFormat = desiredFormat;
g_lightingTexture->mipLevels = 1;
TextureResource* lightingTex = g_lightingTexture[slot];
lightingTex->dxgiFormat = desiredFormat;
lightingTex->mipLevels = 1;
const bool needsCreate =
!g_lightingTexture->texture ||
g_lightingTexture->width != (int)width ||
g_lightingTexture->height != (int)height ||
g_lightingTexture->texture->GetDesc().Format != desiredFormat ||
((g_lightingTexture->texture->GetDesc().Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS) == 0);
!lightingTex->texture ||
lightingTex->width != (int)width ||
lightingTex->height != (int)height ||
lightingTex->texture->GetDesc().Format != desiredFormat ||
((lightingTex->texture->GetDesc().Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS) == 0);
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;
g_lightingTexture->height = (int)height;
g_lightingTexture->compressed = false;
g_lightingTexture->compressedInternalFormat = 0;
g_lightingTexture->compressedBlockBytes = 0;
g_lightingTexture->compressedImageSize = 0;
g_lightingTexture->forceOpaqueAlpha = false;
g_lightingTexture->sysmem.clear();
lightingTex->width = (int)width;
lightingTex->height = (int)height;
lightingTex->compressed = false;
lightingTex->compressedInternalFormat = 0;
lightingTex->compressedBlockBytes = 0;
lightingTex->compressedImageSize = 0;
lightingTex->forceOpaqueAlpha = false;
lightingTex->sysmem.clear();
D3D12_RESOURCE_DESC rd{};
rd.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
@@ -10390,7 +10485,7 @@ static TextureResource* QD3D12_EnsureLightingTexture(int width, int height)
&rd,
D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE,
nullptr,
IID_PPV_ARGS(&g_lightingTexture->texture)));
IID_PPV_ARGS(&lightingTex->texture)));
D3D12_SHADER_RESOURCE_VIEW_DESC srv{};
srv.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
@@ -10399,15 +10494,16 @@ static TextureResource* QD3D12_EnsureLightingTexture(int width, int height)
srv.Texture2D.MipLevels = 1;
g_gl.device->CreateShaderResourceView(
g_lightingTexture->texture.Get(),
lightingTex->texture.Get(),
&srv,
g_lightingTexture->srvCpu);
lightingTex->srvCpu);
g_lightingTexture->gpuValid = true;
g_lightingTexture->state = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
g_lightingTextureState = D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE;
lightingTex->gpuValid = true;
lightingTex->state = 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)
@@ -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);
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();
TextureResource* lightingTex = QD3D12_EnsureLightingTexture(width, height);
if (!lightingTex || !lightingTex->texture)
const UINT writeLightingIndex = g_lightingWriteIndex % QD3D12_LightingTextureCount;
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;
// 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
// of that, the scene input transitions must be submitted on the main command
// 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(
cl,
lightingTex->texture.Get(),
g_lightingTextureState,
writeLightingTex->texture.Get(),
g_lightingTextureState[writeLightingIndex],
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();
QD3D12_UpdateCameraInfoFromCurrentMatrices();
@@ -16883,8 +16991,8 @@ void glLightScene(glRaytracingSceneHandle_t sceneHandle)
pass.depthTexture = sceneDepth;
pass.depthFormat = QD3D12_DepthSrvFormat;
pass.outputTexture = lightingTex->texture.Get();
pass.outputFormat = lightingTex->dxgiFormat;
pass.outputTexture = writeLightingTex->texture.Get();
pass.outputFormat = writeLightingTex->dxgiFormat;
pass.width = (uint32_t)width;
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.
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.
if (g_lightingTextureState != D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE)
if (g_lightingTextureState[writeLightingIndex] != D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE)
{
QD3D12_TransitionResource(
cl,
lightingTex->texture.Get(),
g_lightingTextureState,
writeLightingTex->texture.Get(),
g_lightingTextureState[writeLightingIndex],
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;
@@ -16992,7 +17104,7 @@ void glLightScene(glRaytracingSceneHandle_t sceneHandle)
// in QD3D12_FinalBlitToBackBuffer().
if (!QD3D12_ToneMapFullscreenPass(
*window,
lightingTex->srvGpu,
readLightingTex->srvGpu,
CurrentResolvedSceneColorRTV(),
viewport,
scissor,
@@ -17002,7 +17114,7 @@ void glLightScene(glRaytracingSceneHandle_t sceneHandle)
QD3D12_PostFullscreenPass(
cl,
g_gl.postCopyPSO.Get(),
lightingTex->srvGpu,
readLightingTex->srvGpu,
CurrentResolvedSceneColorRTV(),
viewport,
scissor,
@@ -17177,7 +17289,8 @@ static void QD3D12_ResetInternalTAAHistoryForWindow(QD3D12Window* window)
void QD3D12_EnableTAA(int enabled)
{
const bool newValue = enabled ? true : false;
(void)enabled;
const bool newValue = false;
if (g_gl.enableInternalTAA == newValue)
return;
@@ -17193,7 +17306,7 @@ void QD3D12_EnableTAA(int enabled)
int QD3D12_IsTAAEnabled(void)
{
return g_gl.enableInternalTAA ? 1 : 0;
return 0;
}
void APIENTRY glTAAQD3D12(GLboolean enable)
@@ -17270,7 +17383,8 @@ void QD3D12_EnableRayAIDenoise(int enabled)
void QD3D12_EnableDLSSRayReconstruction(int enabled)
{
const bool newValue = enabled ? true : false;
(void)enabled;
const bool newValue = false;
if (g_gl.enableDLSSRayReconstruction == newValue)
return;