Gamma correction for Vulkan, D3D, OpenGL

This commit is contained in:
Jack Andersen
2018-01-21 12:01:52 -10:00
parent 2df85e8f8b
commit 93c787dcd4
11 changed files with 940 additions and 394 deletions

View File

@@ -111,11 +111,9 @@ public:
m_3dCtx.m_ctx11.m_sampleCount = samples;
m_3dCtx.m_ctx11.m_anisotropy = anisotropy;
m_3dCtx.m_ctx11.m_fbFormat = deepColor ? DXGI_FORMAT_R16G16B16A16_FLOAT : DXGI_FORMAT_R8G8B8A8_UNORM;
//m_3dCtx.m_ctx11.m_fbFormat = DXGI_FORMAT_R8G8B8A8_UNORM;
m_3dCtx.m_ctx12.m_sampleCount = samples;
m_3dCtx.m_ctx12.m_anisotropy = anisotropy;
m_3dCtx.m_ctx12.RGBATex2DFBViewDesc.Format = deepColor ? DXGI_FORMAT_R16G16B16A16_FLOAT : DXGI_FORMAT_R8G8B8A8_UNORM;
//m_3dCtx.m_ctx12.RGBATex2DFBViewDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
m_3dCtx.m_ctxOgl.m_glCtx.m_sampleCount = samples;
m_3dCtx.m_ctxOgl.m_glCtx.m_anisotropy = anisotropy;
m_3dCtx.m_ctxOgl.m_glCtx.m_deepColor = deepColor;

View File

@@ -39,6 +39,7 @@ struct D3D12Context
struct Window
{
ComPtr<IDXGISwapChain3> m_swapChain;
std::unordered_map<ID3D12Resource*, ComPtr<ID3D12DescriptorHeap>> m_rtvHeaps;
UINT m_backBuf = 0;
bool m_needsResize = false;
size_t width, height;
@@ -69,12 +70,32 @@ struct D3D11Context
struct Window
{
ComPtr<IDXGISwapChain1> m_swapChain;
ComPtr<ID3D11Texture2D> m_swapChainTex;
ComPtr<ID3D11RenderTargetView> m_swapChainRTV;
bool m_needsResize = false;
size_t width, height;
bool m_needsFSTransition = false;
bool m_fs = false;
DXGI_MODE_DESC m_fsdesc = {};
void clearRTV()
{
m_swapChainTex.Reset();
m_swapChainRTV.Reset();
}
void setupRTV(ComPtr<IDXGISwapChain1>& sc, ID3D11Device* dev)
{
m_swapChain = sc;
m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), &m_swapChainTex);
D3D11_TEXTURE2D_DESC resDesc;
m_swapChainTex->GetDesc(&resDesc);
width = resDesc.Width;
height = resDesc.Height;
CD3D11_RENDER_TARGET_VIEW_DESC rtvDesc(D3D11_RTV_DIMENSION_TEXTURE2D, resDesc.Format);
dev->CreateRenderTargetView(m_swapChainTex.Get(), &rtvDesc, &m_swapChainRTV);
}
};
std::unordered_map<const boo::IWindow*, Window> m_windows;

View File

@@ -98,6 +98,7 @@ public:
ID3D12CommandQueue* cmdQueue;
m_dataFactory = _NewD3D12DataFactory(&b3dCtx.m_ctx12, this);
m_commandQueue = _NewD3D12CommandQueue(&b3dCtx.m_ctx12, &w, this, &cmdQueue);
m_commandQueue->startRenderer();
scDesc.Format = b3dCtx.m_ctx12.RGBATex2DFBViewDesc.Format;
scDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD;
@@ -129,16 +130,11 @@ public:
auto insIt = b3dCtx.m_ctx11.m_windows.emplace(std::make_pair(parentWindow, D3D11Context::Window()));
D3D11Context::Window& w = insIt.first->second;
w.setupRTV(m_swapChain, b3dCtx.m_ctx11.m_dev.Get());
m_swapChain.As<IDXGISwapChain1>(&w.m_swapChain);
ComPtr<ID3D11Texture2D> fbRes;
m_swapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), &fbRes);
D3D11_TEXTURE2D_DESC resDesc;
fbRes->GetDesc(&resDesc);
w.width = resDesc.Width;
w.height = resDesc.Height;
m_dataFactory = _NewD3D11DataFactory(&b3dCtx.m_ctx11, this);
m_commandQueue = _NewD3D11CommandQueue(&b3dCtx.m_ctx11, &insIt.first->second, this);
m_commandQueue->startRenderer();
if (FAILED(m_swapChain->GetContainingOutput(&m_output)))
Log.report(logvisor::Fatal, "unable to get DXGI output");
@@ -651,6 +647,7 @@ public:
m_dataFactory = _NewVulkanDataFactory(this, m_ctx);
m_commandQueue = _NewVulkanCommandQueue(m_ctx, m_ctx->m_windows[m_parentWindow].get(), this);
m_commandQueue->startRenderer();
return true;
}