mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 09:00:44 +00:00
Implement texture remapping to RGBA16/RGBA32 for D3D11/D3D12
This commit is contained in:
@@ -1775,10 +1775,20 @@ void D3D11Replay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip
|
||||
|
||||
if(params.remap != RemapTexture::NoRemap)
|
||||
{
|
||||
RDCASSERT(params.remap == RemapTexture::RGBA8);
|
||||
if(params.remap == RemapTexture::RGBA8)
|
||||
{
|
||||
desc.Format = IsSRGBFormat(desc.Format) ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
|
||||
: DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
}
|
||||
else if(params.remap == RemapTexture::RGBA16)
|
||||
{
|
||||
desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||
}
|
||||
else if(params.remap == RemapTexture::RGBA32)
|
||||
{
|
||||
desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||
}
|
||||
|
||||
desc.Format =
|
||||
IsSRGBFormat(desc.Format) ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB : DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
desc.ArraySize = 1;
|
||||
}
|
||||
|
||||
@@ -1798,8 +1808,6 @@ void D3D11Replay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip
|
||||
|
||||
if(params.remap != RemapTexture::NoRemap)
|
||||
{
|
||||
RDCASSERT(params.remap == RemapTexture::RGBA8);
|
||||
|
||||
subresource = mip;
|
||||
|
||||
desc.CPUAccessFlags = 0;
|
||||
@@ -1911,11 +1919,21 @@ void D3D11Replay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip
|
||||
|
||||
if(params.remap != RemapTexture::NoRemap)
|
||||
{
|
||||
RDCASSERT(params.remap == RemapTexture::RGBA8);
|
||||
if(params.remap == RemapTexture::RGBA8)
|
||||
{
|
||||
desc.Format = (IsSRGBFormat(desc.Format) || wrapTex->m_RealDescriptor)
|
||||
? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
|
||||
: DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
}
|
||||
else if(params.remap == RemapTexture::RGBA16)
|
||||
{
|
||||
desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||
}
|
||||
else if(params.remap == RemapTexture::RGBA32)
|
||||
{
|
||||
desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||
}
|
||||
|
||||
desc.Format = (IsSRGBFormat(desc.Format) || wrapTex->m_RealDescriptor)
|
||||
? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
|
||||
: DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
desc.ArraySize = 1;
|
||||
}
|
||||
|
||||
@@ -1935,8 +1953,6 @@ void D3D11Replay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip
|
||||
|
||||
if(params.remap != RemapTexture::NoRemap)
|
||||
{
|
||||
RDCASSERT(params.remap == RemapTexture::RGBA8);
|
||||
|
||||
subresource = mip;
|
||||
|
||||
desc.CPUAccessFlags = 0;
|
||||
@@ -2063,10 +2079,19 @@ void D3D11Replay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip
|
||||
|
||||
if(params.remap != RemapTexture::NoRemap)
|
||||
{
|
||||
RDCASSERT(params.remap == RemapTexture::RGBA8);
|
||||
|
||||
desc.Format =
|
||||
IsSRGBFormat(desc.Format) ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB : DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
if(params.remap == RemapTexture::RGBA8)
|
||||
{
|
||||
desc.Format = IsSRGBFormat(desc.Format) ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
|
||||
: DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
}
|
||||
else if(params.remap == RemapTexture::RGBA16)
|
||||
{
|
||||
desc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||
}
|
||||
else if(params.remap == RemapTexture::RGBA32)
|
||||
{
|
||||
desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||
}
|
||||
}
|
||||
|
||||
subresource = mip;
|
||||
@@ -2085,8 +2110,6 @@ void D3D11Replay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip
|
||||
|
||||
if(params.remap != RemapTexture::NoRemap)
|
||||
{
|
||||
RDCASSERT(params.remap == RemapTexture::RGBA8);
|
||||
|
||||
subresource = mip;
|
||||
|
||||
desc.CPUAccessFlags = 0;
|
||||
|
||||
@@ -1367,6 +1367,16 @@ void D3D12Replay::TextureRendering::Init(WrappedID3D12Device *device, D3D12Debug
|
||||
RDCERR("Couldn't create m_TexDisplayF32Pipe! HRESULT: %s", ToStr(hr).c_str());
|
||||
}
|
||||
|
||||
pipeDesc.RTVFormats[0] = DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||
|
||||
hr = device->CreateGraphicsPipelineState(&pipeDesc, __uuidof(ID3D12PipelineState),
|
||||
(void **)&F16Pipe);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
RDCERR("Couldn't create m_TexDisplayF16Pipe! HRESULT: %s", ToStr(hr).c_str());
|
||||
}
|
||||
|
||||
SAFE_RELEASE(TexDisplayPS);
|
||||
}
|
||||
|
||||
@@ -1378,6 +1388,7 @@ void D3D12Replay::TextureRendering::Release()
|
||||
SAFE_RELEASE(BlendPipe);
|
||||
SAFE_RELEASE(SRGBPipe);
|
||||
SAFE_RELEASE(LinearPipe);
|
||||
SAFE_RELEASE(F16Pipe);
|
||||
SAFE_RELEASE(F32Pipe);
|
||||
SAFE_RELEASE(RootSig);
|
||||
SAFE_RELEASE(VS);
|
||||
|
||||
@@ -617,6 +617,8 @@ bool D3D12Replay::RenderTextureInternal(D3D12_CPU_DESCRIPTOR_HANDLE rtv, Texture
|
||||
{
|
||||
if(flags & eTexDisplay_F32Render)
|
||||
list->SetPipelineState(m_TexRender.F32Pipe);
|
||||
else if(flags & eTexDisplay_F16Render)
|
||||
list->SetPipelineState(m_TexRender.F16Pipe);
|
||||
else if(flags & eTexDisplay_LinearRender)
|
||||
list->SetPipelineState(m_TexRender.LinearPipe);
|
||||
else
|
||||
|
||||
@@ -2935,11 +2935,20 @@ void D3D12Replay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip
|
||||
|
||||
if(params.remap != RemapTexture::NoRemap)
|
||||
{
|
||||
RDCASSERT(params.remap == RemapTexture::RGBA8);
|
||||
if(params.remap == RemapTexture::RGBA8)
|
||||
{
|
||||
copyDesc.Format = IsSRGBFormat(copyDesc.Format) ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
|
||||
: DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
}
|
||||
else if(params.remap == RemapTexture::RGBA16)
|
||||
{
|
||||
copyDesc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||
}
|
||||
else if(params.remap == RemapTexture::RGBA32)
|
||||
{
|
||||
copyDesc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||
}
|
||||
|
||||
// force readback texture to RGBA8 unorm
|
||||
copyDesc.Format = IsSRGBFormat(copyDesc.Format) ? DXGI_FORMAT_R8G8B8A8_UNORM_SRGB
|
||||
: DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
// force to 1 array slice, 1 mip
|
||||
copyDesc.DepthOrArraySize = 1;
|
||||
copyDesc.MipLevels = 1;
|
||||
@@ -2961,6 +2970,11 @@ void D3D12Replay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip
|
||||
TexDisplayFlags flags =
|
||||
IsSRGBFormat(copyDesc.Format) ? eTexDisplay_None : eTexDisplay_LinearRender;
|
||||
|
||||
if(copyDesc.Format == DXGI_FORMAT_R16G16B16A16_FLOAT)
|
||||
flags = eTexDisplay_F16Render;
|
||||
else if(copyDesc.Format == DXGI_FORMAT_R32G32B32A32_FLOAT)
|
||||
flags = eTexDisplay_F32Render;
|
||||
|
||||
m_pDevice->CreateRenderTargetView(remapTexture, NULL,
|
||||
GetDebugManager()->GetCPUHandle(GET_TEX_RTV));
|
||||
|
||||
|
||||
@@ -43,8 +43,9 @@ enum TexDisplayFlags
|
||||
{
|
||||
eTexDisplay_None = 0,
|
||||
eTexDisplay_LinearRender = 0x1,
|
||||
eTexDisplay_F32Render = 0x2,
|
||||
eTexDisplay_BlendAlpha = 0x4,
|
||||
eTexDisplay_F16Render = 0x2,
|
||||
eTexDisplay_F32Render = 0x4,
|
||||
eTexDisplay_BlendAlpha = 0x8,
|
||||
};
|
||||
|
||||
class D3D12Replay : public IReplayDriver
|
||||
@@ -334,6 +335,7 @@ private:
|
||||
ID3D12RootSignature *RootSig = NULL;
|
||||
ID3D12PipelineState *SRGBPipe = NULL;
|
||||
ID3D12PipelineState *LinearPipe = NULL;
|
||||
ID3D12PipelineState *F16Pipe = NULL;
|
||||
ID3D12PipelineState *F32Pipe = NULL;
|
||||
ID3D12PipelineState *BlendPipe = NULL;
|
||||
} m_TexRender;
|
||||
|
||||
Reference in New Issue
Block a user