From dc7da6aa213f93e28944e5c815a9892dbff4986c Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Mon, 4 Apr 2016 16:25:55 -1000 Subject: [PATCH] D3D depth range --- lib/graphicsdev/D3D11.cpp | 5 +++-- lib/graphicsdev/D3D12.cpp | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/graphicsdev/D3D11.cpp b/lib/graphicsdev/D3D11.cpp index 87c4cd7..91ffd52 100644 --- a/lib/graphicsdev/D3D11.cpp +++ b/lib/graphicsdev/D3D11.cpp @@ -923,9 +923,10 @@ struct D3D11CommandQueue : IGraphicsCommandQueue m_boundTarget = ctarget; } - void setViewport(const SWindowRect& rect) + void setViewport(const SWindowRect& rect, float znear, float zfar) { - D3D11_VIEWPORT vp = {FLOAT(rect.location[0]), FLOAT(rect.location[1]), FLOAT(rect.size[0]), FLOAT(rect.size[1]), 0.0, 1.0}; + D3D11_VIEWPORT vp = {FLOAT(rect.location[0]), FLOAT(m_boundTarget->m_height - rect.location[1] - rect.size[1]), + FLOAT(rect.size[0]), FLOAT(rect.size[1]), znear, zfar}; m_deferredCtx->RSSetViewports(1, &vp); } diff --git a/lib/graphicsdev/D3D12.cpp b/lib/graphicsdev/D3D12.cpp index 4cd3475..91a3dcb 100644 --- a/lib/graphicsdev/D3D12.cpp +++ b/lib/graphicsdev/D3D12.cpp @@ -1149,10 +1149,10 @@ struct D3D12CommandQueue : IGraphicsCommandQueue m_boundTarget = ctarget; } - void setViewport(const SWindowRect& rect) + void setViewport(const SWindowRect& rect, float znear, float zfar) { - D3D12_VIEWPORT vp = {FLOAT(rect.location[0]), FLOAT(rect.location[1]), - FLOAT(rect.size[0]), FLOAT(rect.size[1]), 0.0f, 1.0f}; + D3D12_VIEWPORT vp = {FLOAT(rect.location[0]), FLOAT(m_boundTarget->m_height - rect.location[1] - rect.size[1]), + FLOAT(rect.size[0]), FLOAT(rect.size[1]), znear, zfar}; m_cmdList->RSSetViewports(1, &vp); }