mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2024-11-23 04:12:42 +00:00
moved to an immediate-mode barrier API
This commit is contained in:
parent
708825ea5e
commit
c70df1f2af
17 changed files with 357 additions and 319 deletions
|
@ -176,11 +176,9 @@ void AccumDepthOfField::Begin(const drawSceneViewCommand_t& cmd)
|
||||||
{
|
{
|
||||||
CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight);
|
CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight);
|
||||||
|
|
||||||
const TextureBarrier texBarriers[] =
|
CmdBeginBarrier();
|
||||||
{
|
CmdTextureBarrier(accumTexture, ResourceStates::RenderTargetBit);
|
||||||
TextureBarrier(accumTexture, ResourceStates::RenderTargetBit)
|
CmdEndBarrier();
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers);
|
|
||||||
|
|
||||||
CmdClearColorTarget(accumTexture, vec4_zero);
|
CmdClearColorTarget(accumTexture, vec4_zero);
|
||||||
|
|
||||||
|
@ -265,12 +263,10 @@ void AccumDepthOfField::Accumulate()
|
||||||
|
|
||||||
SCOPED_RENDER_PASS("DOF Accum", 0.5f, 1.0f, 0.5f);
|
SCOPED_RENDER_PASS("DOF Accum", 0.5f, 1.0f, 0.5f);
|
||||||
|
|
||||||
const TextureBarrier texBarriers[] =
|
CmdBeginBarrier();
|
||||||
{
|
CmdTextureBarrier(crp.renderTarget, ResourceStates::PixelShaderAccessBit);
|
||||||
TextureBarrier(crp.renderTarget, ResourceStates::PixelShaderAccessBit),
|
CmdTextureBarrier(accumTexture, ResourceStates::RenderTargetBit);
|
||||||
TextureBarrier(accumTexture, ResourceStates::RenderTargetBit)
|
CmdEndBarrier();
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers);
|
|
||||||
|
|
||||||
DOFAccumRC rc = {};
|
DOFAccumRC rc = {};
|
||||||
rc.textureIndex = GetTextureIndexSRV(crp.renderTarget);
|
rc.textureIndex = GetTextureIndexSRV(crp.renderTarget);
|
||||||
|
@ -289,12 +285,10 @@ void AccumDepthOfField::Normalize()
|
||||||
{
|
{
|
||||||
SCOPED_RENDER_PASS("DOF Norm", 0.5f, 1.0f, 0.5f);
|
SCOPED_RENDER_PASS("DOF Norm", 0.5f, 1.0f, 0.5f);
|
||||||
|
|
||||||
const TextureBarrier texBarriers[] =
|
CmdBeginBarrier();
|
||||||
{
|
CmdTextureBarrier(accumTexture, ResourceStates::PixelShaderAccessBit);
|
||||||
TextureBarrier(accumTexture, ResourceStates::PixelShaderAccessBit),
|
CmdTextureBarrier(crp.renderTarget, ResourceStates::RenderTargetBit);
|
||||||
TextureBarrier(crp.renderTarget, ResourceStates::RenderTargetBit)
|
CmdEndBarrier();
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers);
|
|
||||||
|
|
||||||
DOFNormRC rc = {};
|
DOFNormRC rc = {};
|
||||||
rc.textureIndex = GetTextureIndexSRV(accumTexture);
|
rc.textureIndex = GetTextureIndexSRV(accumTexture);
|
||||||
|
@ -326,13 +320,12 @@ void AccumDepthOfField::DrawDebug()
|
||||||
SCOPED_RENDER_PASS("DOF Debug", 0.5f, 1.0f, 0.5f);
|
SCOPED_RENDER_PASS("DOF Debug", 0.5f, 1.0f, 0.5f);
|
||||||
|
|
||||||
crp.SwapRenderTargets();
|
crp.SwapRenderTargets();
|
||||||
const TextureBarrier texBarriers[] =
|
|
||||||
{
|
CmdBeginBarrier();
|
||||||
TextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit),
|
CmdTextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit);
|
||||||
TextureBarrier(crp.depthTexture, ResourceStates::PixelShaderAccessBit),
|
CmdTextureBarrier(crp.depthTexture, ResourceStates::PixelShaderAccessBit);
|
||||||
TextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit)
|
CmdTextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit);
|
||||||
};
|
CmdEndBarrier();
|
||||||
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers);
|
|
||||||
|
|
||||||
float mvp[16];
|
float mvp[16];
|
||||||
DOFDebugRC rc = {};
|
DOFDebugRC rc = {};
|
||||||
|
|
|
@ -266,13 +266,12 @@ void GatherDepthOfField::DrawDebug()
|
||||||
SCOPED_RENDER_PASS("DOF Debug", 0.125f, 0.125f, 0.25f);
|
SCOPED_RENDER_PASS("DOF Debug", 0.125f, 0.125f, 0.25f);
|
||||||
|
|
||||||
crp.SwapRenderTargets();
|
crp.SwapRenderTargets();
|
||||||
const TextureBarrier barriers[] =
|
|
||||||
{
|
CmdBeginBarrier();
|
||||||
TextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit),
|
CmdTextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit);
|
||||||
TextureBarrier(crp.depthTexture, ResourceStates::PixelShaderAccessBit),
|
CmdTextureBarrier(crp.depthTexture, ResourceStates::PixelShaderAccessBit);
|
||||||
TextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit)
|
CmdTextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit);
|
||||||
};
|
CmdEndBarrier();
|
||||||
CmdBarrier(ARRAY_LEN(barriers), barriers);
|
|
||||||
|
|
||||||
DOFDebugRC rc = {};
|
DOFDebugRC rc = {};
|
||||||
rc.colorTextureIndex = GetTextureIndexSRV(crp.GetReadRenderTarget());
|
rc.colorTextureIndex = GetTextureIndexSRV(crp.GetReadRenderTarget());
|
||||||
|
@ -295,16 +294,14 @@ void GatherDepthOfField::DrawSplit()
|
||||||
{
|
{
|
||||||
SCOPED_RENDER_PASS("DOF Split", 0.125f, 0.125f, 0.25f);
|
SCOPED_RENDER_PASS("DOF Split", 0.125f, 0.125f, 0.25f);
|
||||||
|
|
||||||
const TextureBarrier barriers[] =
|
CmdBeginBarrier();
|
||||||
{
|
CmdTextureBarrier(crp.depthTexture, ResourceStates::ComputeShaderAccessBit);
|
||||||
TextureBarrier(crp.depthTexture, ResourceStates::ComputeShaderAccessBit),
|
CmdTextureBarrier(crp.renderTarget, ResourceStates::ComputeShaderAccessBit);
|
||||||
TextureBarrier(crp.renderTarget, ResourceStates::ComputeShaderAccessBit),
|
CmdTextureBarrier(nearColorTexture, ResourceStates::UnorderedAccessBit);
|
||||||
TextureBarrier(nearColorTexture, ResourceStates::UnorderedAccessBit),
|
CmdTextureBarrier(farColorTexture, ResourceStates::UnorderedAccessBit);
|
||||||
TextureBarrier(farColorTexture, ResourceStates::UnorderedAccessBit),
|
CmdTextureBarrier(nearCocTexture, ResourceStates::UnorderedAccessBit);
|
||||||
TextureBarrier(nearCocTexture, ResourceStates::UnorderedAccessBit),
|
CmdTextureBarrier(farCocTexture, ResourceStates::UnorderedAccessBit);
|
||||||
TextureBarrier(farCocTexture, ResourceStates::UnorderedAccessBit)
|
CmdEndBarrier();
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(barriers), barriers);
|
|
||||||
|
|
||||||
DOFSplitRC rc = {};
|
DOFSplitRC rc = {};
|
||||||
rc.depthTextureIndex = GetTextureIndexSRV(crp.depthTexture);
|
rc.depthTextureIndex = GetTextureIndexSRV(crp.depthTexture);
|
||||||
|
@ -329,12 +326,10 @@ void GatherDepthOfField::DrawNearCocTileGen()
|
||||||
{
|
{
|
||||||
SCOPED_RENDER_PASS("DOF Tile Gen", 0.125f, 0.125f, 0.25f);
|
SCOPED_RENDER_PASS("DOF Tile Gen", 0.125f, 0.125f, 0.25f);
|
||||||
|
|
||||||
const TextureBarrier barriers[] =
|
CmdBeginBarrier();
|
||||||
{
|
CmdTextureBarrier(nearCocTexture, ResourceStates::ComputeShaderAccessBit);
|
||||||
TextureBarrier(nearCocTexture, ResourceStates::ComputeShaderAccessBit),
|
CmdTextureBarrier(nearCocTileTexture, ResourceStates::UnorderedAccessBit);
|
||||||
TextureBarrier(nearCocTileTexture, ResourceStates::UnorderedAccessBit)
|
CmdEndBarrier();
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(barriers), barriers);
|
|
||||||
|
|
||||||
DOFNearCocTileGenRC rc = {};
|
DOFNearCocTileGenRC rc = {};
|
||||||
rc.inputTextureIndex = GetTextureIndexSRV(nearCocTexture);
|
rc.inputTextureIndex = GetTextureIndexSRV(nearCocTexture);
|
||||||
|
@ -349,12 +344,10 @@ void GatherDepthOfField::DrawNearCocTileMax()
|
||||||
{
|
{
|
||||||
SCOPED_RENDER_PASS("DOF Tile Max", 0.125f, 0.125f, 0.25f);
|
SCOPED_RENDER_PASS("DOF Tile Max", 0.125f, 0.125f, 0.25f);
|
||||||
|
|
||||||
const TextureBarrier barriers[] =
|
CmdBeginBarrier();
|
||||||
{
|
CmdTextureBarrier(nearCocTileTexture, ResourceStates::ComputeShaderAccessBit);
|
||||||
TextureBarrier(nearCocTileTexture, ResourceStates::ComputeShaderAccessBit),
|
CmdTextureBarrier(nearCocTileTexture2, ResourceStates::UnorderedAccessBit);
|
||||||
TextureBarrier(nearCocTileTexture2, ResourceStates::UnorderedAccessBit)
|
CmdEndBarrier();
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(barriers), barriers);
|
|
||||||
|
|
||||||
DOFNearCocTileMaxRC rc = {};
|
DOFNearCocTileMaxRC rc = {};
|
||||||
rc.inputTextureIndex = GetTextureIndexSRV(nearCocTileTexture);
|
rc.inputTextureIndex = GetTextureIndexSRV(nearCocTileTexture);
|
||||||
|
@ -370,18 +363,16 @@ void GatherDepthOfField::DrawBlur()
|
||||||
{
|
{
|
||||||
SCOPED_RENDER_PASS("DOF Blur", 0.125f, 0.125f, 0.25f);
|
SCOPED_RENDER_PASS("DOF Blur", 0.125f, 0.125f, 0.25f);
|
||||||
|
|
||||||
const TextureBarrier barriers[] =
|
CmdBeginBarrier();
|
||||||
{
|
CmdTextureBarrier(crp.renderTarget, ResourceStates::ComputeShaderAccessBit);
|
||||||
TextureBarrier(crp.renderTarget, ResourceStates::ComputeShaderAccessBit),
|
CmdTextureBarrier(nearColorTexture, ResourceStates::ComputeShaderAccessBit);
|
||||||
TextureBarrier(nearColorTexture, ResourceStates::ComputeShaderAccessBit),
|
CmdTextureBarrier(farColorTexture, ResourceStates::ComputeShaderAccessBit);
|
||||||
TextureBarrier(farColorTexture, ResourceStates::ComputeShaderAccessBit),
|
CmdTextureBarrier(nearCocTexture, ResourceStates::ComputeShaderAccessBit);
|
||||||
TextureBarrier(nearCocTexture, ResourceStates::ComputeShaderAccessBit),
|
CmdTextureBarrier(nearCocTileTexture2, ResourceStates::ComputeShaderAccessBit);
|
||||||
TextureBarrier(nearCocTileTexture2, ResourceStates::ComputeShaderAccessBit),
|
CmdTextureBarrier(farCocTexture, ResourceStates::ComputeShaderAccessBit);
|
||||||
TextureBarrier(farCocTexture, ResourceStates::ComputeShaderAccessBit),
|
CmdTextureBarrier(nearBlurTexture, ResourceStates::UnorderedAccessBit);
|
||||||
TextureBarrier(nearBlurTexture, ResourceStates::UnorderedAccessBit),
|
CmdTextureBarrier(farBlurTexture, ResourceStates::UnorderedAccessBit);
|
||||||
TextureBarrier(farBlurTexture, ResourceStates::UnorderedAccessBit)
|
CmdEndBarrier();
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(barriers), barriers);
|
|
||||||
|
|
||||||
DOFBlurRC rc = {};
|
DOFBlurRC rc = {};
|
||||||
rc.colorTextureIndex = GetTextureIndexSRV(crp.renderTarget);
|
rc.colorTextureIndex = GetTextureIndexSRV(crp.renderTarget);
|
||||||
|
@ -406,14 +397,12 @@ void GatherDepthOfField::DrawFill()
|
||||||
{
|
{
|
||||||
SCOPED_RENDER_PASS("DOF Fill", 0.125f, 0.125f, 0.25f);
|
SCOPED_RENDER_PASS("DOF Fill", 0.125f, 0.125f, 0.25f);
|
||||||
|
|
||||||
const TextureBarrier barriers[] =
|
CmdBeginBarrier();
|
||||||
{
|
CmdTextureBarrier(nearBlurTexture, ResourceStates::ComputeShaderAccessBit);
|
||||||
TextureBarrier(nearBlurTexture, ResourceStates::ComputeShaderAccessBit),
|
CmdTextureBarrier(farBlurTexture, ResourceStates::ComputeShaderAccessBit);
|
||||||
TextureBarrier(farBlurTexture, ResourceStates::ComputeShaderAccessBit),
|
CmdTextureBarrier(nearColorTexture, ResourceStates::UnorderedAccessBit);
|
||||||
TextureBarrier(nearColorTexture, ResourceStates::UnorderedAccessBit),
|
CmdTextureBarrier(farColorTexture, ResourceStates::UnorderedAccessBit);
|
||||||
TextureBarrier(farColorTexture, ResourceStates::UnorderedAccessBit)
|
CmdEndBarrier();
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(barriers), barriers);
|
|
||||||
|
|
||||||
DOFFillRC rc = {};
|
DOFFillRC rc = {};
|
||||||
rc.nearInputTextureIndex = GetTextureIndexSRV(nearBlurTexture);
|
rc.nearInputTextureIndex = GetTextureIndexSRV(nearBlurTexture);
|
||||||
|
@ -431,16 +420,14 @@ void GatherDepthOfField::DrawCombine()
|
||||||
{
|
{
|
||||||
SCOPED_RENDER_PASS("DOF Combine", 0.125f, 0.125f, 0.25f);
|
SCOPED_RENDER_PASS("DOF Combine", 0.125f, 0.125f, 0.25f);
|
||||||
|
|
||||||
const TextureBarrier barriers[] =
|
CmdBeginBarrier();
|
||||||
{
|
CmdTextureBarrier(nearColorTexture, ResourceStates::PixelShaderAccessBit);
|
||||||
TextureBarrier(nearColorTexture, ResourceStates::PixelShaderAccessBit),
|
CmdTextureBarrier(farColorTexture, ResourceStates::PixelShaderAccessBit);
|
||||||
TextureBarrier(farColorTexture, ResourceStates::PixelShaderAccessBit),
|
CmdTextureBarrier(nearCocTexture, ResourceStates::PixelShaderAccessBit);
|
||||||
TextureBarrier(nearCocTexture, ResourceStates::PixelShaderAccessBit),
|
CmdTextureBarrier(farCocTexture, ResourceStates::PixelShaderAccessBit);
|
||||||
TextureBarrier(farCocTexture, ResourceStates::PixelShaderAccessBit),
|
CmdTextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit);
|
||||||
TextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit),
|
CmdTextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit);
|
||||||
TextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit)
|
CmdEndBarrier();
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(barriers), barriers);
|
|
||||||
|
|
||||||
DOFCombineRC rc = {};
|
DOFCombineRC rc = {};
|
||||||
rc.nearTextureIndex = GetTextureIndexSRV(nearColorTexture);
|
rc.nearTextureIndex = GetTextureIndexSRV(nearColorTexture);
|
||||||
|
|
|
@ -130,12 +130,10 @@ void Fog::Draw()
|
||||||
CmdBindVertexBuffers(1, &boxVertexBuffer, &stride, NULL);
|
CmdBindVertexBuffers(1, &boxVertexBuffer, &stride, NULL);
|
||||||
CmdBindIndexBuffer(boxIndexBuffer, IndexType::UInt32, 0);
|
CmdBindIndexBuffer(boxIndexBuffer, IndexType::UInt32, 0);
|
||||||
|
|
||||||
const TextureBarrier barriers[] =
|
CmdBeginBarrier();
|
||||||
{
|
CmdTextureBarrier(crp.depthTexture, ResourceStates::PixelShaderAccessBit);
|
||||||
TextureBarrier(crp.depthTexture, ResourceStates::PixelShaderAccessBit),
|
CmdTextureBarrier(crp.renderTarget, ResourceStates::RenderTargetBit);
|
||||||
TextureBarrier(crp.renderTarget, ResourceStates::RenderTargetBit)
|
CmdEndBarrier();
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(barriers), barriers);
|
|
||||||
|
|
||||||
CmdBindRenderTargets(1, &crp.renderTarget, NULL);
|
CmdBindRenderTargets(1, &crp.renderTarget, NULL);
|
||||||
|
|
||||||
|
|
|
@ -352,9 +352,11 @@ void CRP::BeginFrame()
|
||||||
ui.BeginFrame();
|
ui.BeginFrame();
|
||||||
nuklear.BeginFrame();
|
nuklear.BeginFrame();
|
||||||
|
|
||||||
|
CmdBeginBarrier();
|
||||||
|
CmdTextureBarrier(renderTarget, ResourceStates::RenderTargetBit);
|
||||||
|
CmdEndBarrier();
|
||||||
|
|
||||||
const float clearColor[4] = { 0.0f, 0.5f, 0.0f, 0.0f };
|
const float clearColor[4] = { 0.0f, 0.5f, 0.0f, 0.0f };
|
||||||
const TextureBarrier barrier(renderTarget, ResourceStates::RenderTargetBit);
|
|
||||||
CmdBarrier(1, &barrier);
|
|
||||||
CmdClearColorTarget(renderTarget, clearColor);
|
CmdClearColorTarget(renderTarget, clearColor);
|
||||||
|
|
||||||
frameSeed = (float)rand() / (float)RAND_MAX;
|
frameSeed = (float)rand() / (float)RAND_MAX;
|
||||||
|
@ -376,12 +378,10 @@ void CRP::Blit(HTexture destination, HTexture source, const char* passName, bool
|
||||||
{
|
{
|
||||||
SCOPED_RENDER_PASS(passName, 0.125f, 0.125f, 0.5f);
|
SCOPED_RENDER_PASS(passName, 0.125f, 0.125f, 0.5f);
|
||||||
|
|
||||||
const TextureBarrier barriers[2] =
|
CmdBeginBarrier();
|
||||||
{
|
CmdTextureBarrier(source, ResourceStates::PixelShaderAccessBit);
|
||||||
TextureBarrier(source, ResourceStates::PixelShaderAccessBit),
|
CmdTextureBarrier(destination, ResourceStates::RenderTargetBit);
|
||||||
TextureBarrier(destination, ResourceStates::RenderTargetBit)
|
CmdEndBarrier();
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(barriers), barriers);
|
|
||||||
|
|
||||||
#pragma pack(push, 4)
|
#pragma pack(push, 4)
|
||||||
struct BlitRC
|
struct BlitRC
|
||||||
|
@ -564,8 +564,9 @@ void CRP::DrawSceneView(const drawSceneViewCommand_t& cmd)
|
||||||
if(cmd.shouldClearColor)
|
if(cmd.shouldClearColor)
|
||||||
{
|
{
|
||||||
const Rect rect(vp.viewportX, vp.viewportY, vp.viewportWidth, vp.viewportHeight);
|
const Rect rect(vp.viewportX, vp.viewportY, vp.viewportWidth, vp.viewportHeight);
|
||||||
const TextureBarrier tb(renderTarget, ResourceStates::RenderTargetBit);
|
CmdBeginBarrier();
|
||||||
CmdBarrier(1, &tb);
|
CmdTextureBarrier(renderTarget, ResourceStates::RenderTargetBit);
|
||||||
|
CmdEndBarrier();
|
||||||
CmdClearColorTarget(renderTarget, cmd.clearColor, &rect);
|
CmdClearColorTarget(renderTarget, cmd.clearColor, &rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,8 +591,9 @@ void CRP::DrawSceneView(const drawSceneViewCommand_t& cmd)
|
||||||
srp.enableRenderPassQueries = x == 0 && y == 0;
|
srp.enableRenderPassQueries = x == 0 && y == 0;
|
||||||
drawSceneViewCommand_t newCmd;
|
drawSceneViewCommand_t newCmd;
|
||||||
accumDof.FixCommand(newCmd, cmd, x, y);
|
accumDof.FixCommand(newCmd, cmd, x, y);
|
||||||
const TextureBarrier tb(renderTarget, ResourceStates::RenderTargetBit);
|
CmdBeginBarrier();
|
||||||
CmdBarrier(1, &tb);
|
CmdTextureBarrier(renderTarget, ResourceStates::RenderTargetBit);
|
||||||
|
CmdEndBarrier();
|
||||||
CmdClearColorTarget(renderTarget, cmd.clearColor, &rect);
|
CmdClearColorTarget(renderTarget, cmd.clearColor, &rect);
|
||||||
opaque.Draw(newCmd);
|
opaque.Draw(newCmd);
|
||||||
fog.Draw();
|
fog.Draw();
|
||||||
|
|
|
@ -99,9 +99,10 @@ void WorldOpaque::Draw(const drawSceneViewCommand_t& cmd)
|
||||||
batchOldDepthHack = false;
|
batchOldDepthHack = false;
|
||||||
batchDepthHack = false;
|
batchDepthHack = false;
|
||||||
|
|
||||||
TextureBarrier tb(crp.depthTexture, ResourceStates::DepthWriteBit);
|
CmdBeginBarrier();
|
||||||
BufferBarrier bb(srp.traceRenderBuffer, ResourceStates::UnorderedAccessBit);
|
CmdTextureBarrier(crp.depthTexture, ResourceStates::DepthWriteBit);
|
||||||
CmdBarrier(1, &tb, 1, &bb);
|
CmdBufferBarrier(srp.traceRenderBuffer, ResourceStates::UnorderedAccessBit);
|
||||||
|
CmdEndBarrier();
|
||||||
|
|
||||||
CmdClearDepthStencilTarget(crp.depthTexture, true, 0.0f);
|
CmdClearDepthStencilTarget(crp.depthTexture, true, 0.0f);
|
||||||
|
|
||||||
|
|
|
@ -83,12 +83,11 @@ void ToneMap::DrawToneMap()
|
||||||
CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight);
|
CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight);
|
||||||
|
|
||||||
crp.SwapRenderTargets();
|
crp.SwapRenderTargets();
|
||||||
const TextureBarrier texBarriers[] =
|
|
||||||
{
|
CmdBeginBarrier();
|
||||||
TextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit),
|
CmdTextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit);
|
||||||
TextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit)
|
CmdTextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit);
|
||||||
};
|
CmdEndBarrier();
|
||||||
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers, 0, NULL);
|
|
||||||
|
|
||||||
ToneMapRC rc = {};
|
ToneMapRC rc = {};
|
||||||
rc.textureIndex = GetTextureIndexSRV(crp.GetReadRenderTarget());
|
rc.textureIndex = GetTextureIndexSRV(crp.GetReadRenderTarget());
|
||||||
|
@ -112,12 +111,11 @@ void ToneMap::DrawInverseToneMap()
|
||||||
CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight);
|
CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight);
|
||||||
|
|
||||||
crp.SwapRenderTargets();
|
crp.SwapRenderTargets();
|
||||||
const TextureBarrier texBarriers[] =
|
|
||||||
{
|
CmdBeginBarrier();
|
||||||
TextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit),
|
CmdTextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit);
|
||||||
TextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit)
|
CmdTextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit);
|
||||||
};
|
CmdEndBarrier();
|
||||||
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers, 0, NULL);
|
|
||||||
|
|
||||||
InverseToneMapRC rc = {};
|
InverseToneMapRC rc = {};
|
||||||
rc.textureIndex = GetTextureIndexSRV(crp.GetReadRenderTarget());
|
rc.textureIndex = GetTextureIndexSRV(crp.GetReadRenderTarget());
|
||||||
|
|
|
@ -119,17 +119,12 @@ void WorldTransp::Draw(const drawSceneViewCommand_t& cmd)
|
||||||
batchOldDepthHack = false;
|
batchOldDepthHack = false;
|
||||||
batchDepthHack = false;
|
batchDepthHack = false;
|
||||||
|
|
||||||
const TextureBarrier texBarriers[] =
|
CmdBeginBarrier();
|
||||||
{
|
CmdTextureBarrier(crp.depthTexture, ResourceStates::DepthWriteBit);
|
||||||
TextureBarrier(crp.depthTexture, ResourceStates::DepthWriteBit),
|
CmdTextureBarrier(crp.oitIndexTexture, ResourceStates::UnorderedAccessBit);
|
||||||
TextureBarrier(crp.oitIndexTexture, ResourceStates::UnorderedAccessBit)
|
CmdBufferBarrier(crp.oitFragmentBuffer, ResourceStates::UnorderedAccessBit);
|
||||||
};
|
CmdBufferBarrier(crp.oitCounterBuffer, ResourceStates::CopyDestinationBit);
|
||||||
const BufferBarrier bufBarriers[] =
|
CmdEndBarrier();
|
||||||
{
|
|
||||||
BufferBarrier(crp.oitFragmentBuffer, ResourceStates::UnorderedAccessBit),
|
|
||||||
BufferBarrier(crp.oitCounterBuffer, ResourceStates::UnorderedAccessBit)
|
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers, ARRAY_LEN(bufBarriers), bufBarriers);
|
|
||||||
|
|
||||||
GeoBuffers& db = crp.dynBuffers[GetFrameIndex()];
|
GeoBuffers& db = crp.dynBuffers[GetFrameIndex()];
|
||||||
db.BeginUpload();
|
db.BeginUpload();
|
||||||
|
@ -139,24 +134,16 @@ void WorldTransp::Draw(const drawSceneViewCommand_t& cmd)
|
||||||
CmdBindIndexBuffer(db.indexBuffer.buffer, IndexType::UInt32, 0);
|
CmdBindIndexBuffer(db.indexBuffer.buffer, IndexType::UInt32, 0);
|
||||||
|
|
||||||
// reset the fragment counter
|
// reset the fragment counter
|
||||||
{
|
CmdCopyBuffer(crp.oitCounterBuffer, crp.oitCounterStagingBuffer);
|
||||||
BufferBarrier b0(crp.oitCounterBuffer, ResourceStates::CopyDestinationBit);
|
|
||||||
CmdBarrier(0, NULL, 1, &b0);
|
|
||||||
|
|
||||||
CmdCopyBuffer(crp.oitCounterBuffer, crp.oitCounterStagingBuffer);
|
|
||||||
|
|
||||||
BufferBarrier b1(crp.oitCounterBuffer, ResourceStates::UnorderedAccessBit);
|
|
||||||
CmdBarrier(0, NULL, 1, &b1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// clear the index texture
|
// clear the index texture
|
||||||
{
|
const uint32_t zeroes[4] = {};
|
||||||
const uint32_t zeroes[4] = {};
|
CmdClearTextureUAV(crp.oitIndexTexture, 0, zeroes);
|
||||||
CmdClearTextureUAV(crp.oitIndexTexture, 0, zeroes);
|
|
||||||
}
|
|
||||||
|
|
||||||
// really should just be just for the counter buffer and the index texture
|
CmdBeginBarrier();
|
||||||
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers, ARRAY_LEN(bufBarriers), bufBarriers);
|
CmdBufferBarrier(crp.oitCounterBuffer, ResourceStates::UnorderedAccessBit);
|
||||||
|
CmdTextureBarrier(crp.oitIndexTexture, ResourceStates::UnorderedAccessBit);
|
||||||
|
CmdEndBarrier();
|
||||||
|
|
||||||
const drawSurf_t* drawSurfs = cmd.drawSurfs;
|
const drawSurf_t* drawSurfs = cmd.drawSurfs;
|
||||||
const int opaqueSurfCount = cmd.numDrawSurfs - cmd.numTranspSurfs;
|
const int opaqueSurfCount = cmd.numDrawSurfs - cmd.numTranspSurfs;
|
||||||
|
|
|
@ -72,19 +72,15 @@ void TranspResolve::Draw(const drawSceneViewCommand_t& cmd)
|
||||||
CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight);
|
CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight);
|
||||||
|
|
||||||
crp.SwapRenderTargets();
|
crp.SwapRenderTargets();
|
||||||
const TextureBarrier texBarriers[] =
|
|
||||||
{
|
CmdBeginBarrier();
|
||||||
TextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit),
|
CmdTextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit);
|
||||||
TextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit),
|
CmdTextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit);
|
||||||
TextureBarrier(crp.oitIndexTexture, ResourceStates::UnorderedAccessBit),
|
CmdTextureBarrier(crp.oitIndexTexture, ResourceStates::UnorderedAccessBit);
|
||||||
TextureBarrier(crp.depthTexture, ResourceStates::PixelShaderAccessBit)
|
CmdTextureBarrier(crp.depthTexture, ResourceStates::PixelShaderAccessBit);
|
||||||
};
|
CmdBufferBarrier(crp.oitFragmentBuffer, ResourceStates::UnorderedAccessBit);
|
||||||
const BufferBarrier bufBarriers[] =
|
CmdBufferBarrier(srp.traceRenderBuffer, ResourceStates::UnorderedAccessBit);
|
||||||
{
|
CmdEndBarrier();
|
||||||
BufferBarrier(crp.oitFragmentBuffer, ResourceStates::UnorderedAccessBit),
|
|
||||||
BufferBarrier(srp.traceRenderBuffer, ResourceStates::UnorderedAccessBit)
|
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers, ARRAY_LEN(bufBarriers), bufBarriers);
|
|
||||||
|
|
||||||
TranspResolveRC rc = {};
|
TranspResolveRC rc = {};
|
||||||
rc.fragmentBuffer = GetBufferIndexUAV(crp.oitFragmentBuffer);
|
rc.fragmentBuffer = GetBufferIndexUAV(crp.oitFragmentBuffer);
|
||||||
|
|
|
@ -238,9 +238,11 @@ void GRP::BeginFrame()
|
||||||
world.BeginFrame();
|
world.BeginFrame();
|
||||||
nuklear.BeginFrame();
|
nuklear.BeginFrame();
|
||||||
|
|
||||||
|
CmdBeginBarrier();
|
||||||
|
CmdTextureBarrier(renderTarget, ResourceStates::RenderTargetBit);
|
||||||
|
CmdEndBarrier();
|
||||||
|
|
||||||
const float clearColor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
const float clearColor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
const TextureBarrier barrier(renderTarget, ResourceStates::RenderTargetBit);
|
|
||||||
CmdBarrier(1, &barrier);
|
|
||||||
CmdClearColorTarget(renderTarget, clearColor);
|
CmdClearColorTarget(renderTarget, clearColor);
|
||||||
|
|
||||||
// nothing is bound to the command list yet!
|
// nothing is bound to the command list yet!
|
||||||
|
|
|
@ -130,12 +130,10 @@ void PostProcess::Draw(const char* renderPassName, HTexture renderTarget)
|
||||||
{
|
{
|
||||||
SCOPED_RENDER_PASS(renderPassName, 0.125f, 0.125f, 0.5f);
|
SCOPED_RENDER_PASS(renderPassName, 0.125f, 0.125f, 0.5f);
|
||||||
|
|
||||||
const TextureBarrier barriers[2] =
|
CmdBeginBarrier();
|
||||||
{
|
CmdTextureBarrier(grp.renderTarget, ResourceStates::PixelShaderAccessBit);
|
||||||
TextureBarrier(grp.renderTarget, ResourceStates::PixelShaderAccessBit),
|
CmdTextureBarrier(renderTarget, ResourceStates::RenderTargetBit);
|
||||||
TextureBarrier(renderTarget, ResourceStates::RenderTargetBit)
|
CmdEndBarrier();
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(barriers), barriers);
|
|
||||||
|
|
||||||
float vsX = 1.0f; // vertex shader scale factors
|
float vsX = 1.0f; // vertex shader scale factors
|
||||||
float vsY = 1.0f;
|
float vsY = 1.0f;
|
||||||
|
|
|
@ -332,12 +332,10 @@ void SMAA::Draw(const viewParms_t& parms)
|
||||||
SCOPED_RENDER_PASS(va("SMAA %s", presetNames[r_smaa->integer]), 0.5f, 0.25f, 0.75f);
|
SCOPED_RENDER_PASS(va("SMAA %s", presetNames[r_smaa->integer]), 0.5f, 0.25f, 0.75f);
|
||||||
|
|
||||||
// can't clear targets if they're not in render target state
|
// can't clear targets if they're not in render target state
|
||||||
const TextureBarrier clearBarriers[2] =
|
CmdBeginBarrier();
|
||||||
{
|
CmdTextureBarrier(edgeTexture, ResourceStates::RenderTargetBit);
|
||||||
TextureBarrier(edgeTexture, ResourceStates::RenderTargetBit),
|
CmdTextureBarrier(blendTexture, ResourceStates::RenderTargetBit);
|
||||||
TextureBarrier(blendTexture, ResourceStates::RenderTargetBit)
|
CmdEndBarrier();
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(clearBarriers), clearBarriers);
|
|
||||||
|
|
||||||
CmdClearColorTarget(edgeTexture, vec4_zero);
|
CmdClearColorTarget(edgeTexture, vec4_zero);
|
||||||
CmdClearColorTarget(blendTexture, vec4_zero);
|
CmdClearColorTarget(blendTexture, vec4_zero);
|
||||||
|
@ -347,18 +345,14 @@ void SMAA::Draw(const viewParms_t& parms)
|
||||||
CmdSetViewport(0, 0, glConfig.vidWidth, glConfig.vidHeight);
|
CmdSetViewport(0, 0, glConfig.vidWidth, glConfig.vidHeight);
|
||||||
CmdSetScissor(parms.viewportX, parms.viewportY, parms.viewportWidth, parms.viewportHeight);
|
CmdSetScissor(parms.viewportX, parms.viewportY, parms.viewportWidth, parms.viewportHeight);
|
||||||
|
|
||||||
// tone map for higher quality AA
|
CmdBeginBarrier();
|
||||||
{
|
CmdTextureBarrier(grp.renderTarget, ResourceStates::PixelShaderAccessBit);
|
||||||
const TextureBarrier barriers[2] =
|
CmdTextureBarrier(inputTexture, ResourceStates::RenderTargetBit);
|
||||||
{
|
CmdEndBarrier();
|
||||||
TextureBarrier(grp.renderTarget, ResourceStates::PixelShaderAccessBit),
|
|
||||||
TextureBarrier(inputTexture, ResourceStates::RenderTargetBit)
|
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(barriers), barriers);
|
|
||||||
|
|
||||||
CmdBindRenderTargets(1, &inputTexture, NULL);
|
// tone map for higher quality AA
|
||||||
grp.post.ToneMap(); // RTCF_R8G8B8A8 is assumed
|
CmdBindRenderTargets(1, &inputTexture, NULL);
|
||||||
}
|
grp.post.ToneMap(); // RTCF_R8G8B8A8 is assumed
|
||||||
|
|
||||||
CmdBindRootSignature(rootSignature);
|
CmdBindRootSignature(rootSignature);
|
||||||
CmdBindDescriptorTable(rootSignature, descriptorTable);
|
CmdBindDescriptorTable(rootSignature, descriptorTable);
|
||||||
|
@ -371,50 +365,40 @@ void SMAA::Draw(const viewParms_t& parms)
|
||||||
CmdSetRootConstants(rootSignature, ShaderStage::Vertex, &rc);
|
CmdSetRootConstants(rootSignature, ShaderStage::Vertex, &rc);
|
||||||
CmdSetRootConstants(rootSignature, ShaderStage::Pixel, &rc);
|
CmdSetRootConstants(rootSignature, ShaderStage::Pixel, &rc);
|
||||||
|
|
||||||
// run edge detection
|
CmdBeginBarrier();
|
||||||
{
|
CmdTextureBarrier(inputTexture, ResourceStates::PixelShaderAccessBit);
|
||||||
const TextureBarrier barrier(inputTexture, ResourceStates::PixelShaderAccessBit);
|
CmdEndBarrier();
|
||||||
CmdBarrier(1, &barrier);
|
|
||||||
|
|
||||||
CmdBindRenderTargets(1, &edgeTexture, &stencilTexture);
|
// run edge detection
|
||||||
CmdBindPipeline(firstPassPipeline);
|
CmdBindRenderTargets(1, &edgeTexture, &stencilTexture);
|
||||||
CmdDraw(3, 0);
|
CmdBindPipeline(firstPassPipeline);
|
||||||
}
|
CmdDraw(3, 0);
|
||||||
|
|
||||||
|
CmdBeginBarrier();
|
||||||
|
CmdTextureBarrier(edgeTexture, ResourceStates::PixelShaderAccessBit);
|
||||||
|
CmdEndBarrier();
|
||||||
|
|
||||||
// compute blend weights
|
// compute blend weights
|
||||||
{
|
CmdBindRenderTargets(1, &blendTexture, &stencilTexture);
|
||||||
const TextureBarrier barrier(edgeTexture, ResourceStates::PixelShaderAccessBit);
|
CmdBindPipeline(secondPassPipeline);
|
||||||
CmdBarrier(1, &barrier);
|
CmdDraw(3, 0);
|
||||||
|
|
||||||
CmdBindRenderTargets(1, &blendTexture, &stencilTexture);
|
CmdBeginBarrier();
|
||||||
CmdBindPipeline(secondPassPipeline);
|
CmdTextureBarrier(blendTexture, ResourceStates::PixelShaderAccessBit);
|
||||||
CmdDraw(3, 0);
|
CmdTextureBarrier(outputTexture, ResourceStates::RenderTargetBit);
|
||||||
}
|
CmdEndBarrier();
|
||||||
|
|
||||||
// blend pass
|
// blend pass
|
||||||
{
|
CmdBindRenderTargets(1, &outputTexture, NULL);
|
||||||
const TextureBarrier barriers[2] =
|
CmdBindPipeline(thirdPassPipeline);
|
||||||
{
|
CmdDraw(3, 0);
|
||||||
TextureBarrier(blendTexture, ResourceStates::PixelShaderAccessBit),
|
|
||||||
TextureBarrier(outputTexture, ResourceStates::RenderTargetBit)
|
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(barriers), barriers);
|
|
||||||
|
|
||||||
CmdBindRenderTargets(1, &outputTexture, NULL);
|
CmdBeginBarrier();
|
||||||
CmdBindPipeline(thirdPassPipeline);
|
CmdTextureBarrier(outputTexture, ResourceStates::PixelShaderAccessBit);
|
||||||
CmdDraw(3, 0);
|
CmdTextureBarrier(grp.renderTarget, ResourceStates::RenderTargetBit);
|
||||||
}
|
CmdEndBarrier();
|
||||||
|
|
||||||
// inverse tone map and write back to the main render target
|
// inverse tone map and write back to the main render target
|
||||||
{
|
CmdBindRenderTargets(1, &grp.renderTarget, NULL);
|
||||||
const TextureBarrier barriers[2] =
|
grp.post.InverseToneMap(r_rtColorFormat->integer);
|
||||||
{
|
|
||||||
TextureBarrier(outputTexture, ResourceStates::PixelShaderAccessBit),
|
|
||||||
TextureBarrier(grp.renderTarget, ResourceStates::RenderTargetBit)
|
|
||||||
};
|
|
||||||
CmdBarrier(ARRAY_LEN(barriers), barriers);
|
|
||||||
|
|
||||||
CmdBindRenderTargets(1, &grp.renderTarget, NULL);
|
|
||||||
grp.post.InverseToneMap(r_rtColorFormat->integer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -398,8 +398,9 @@ void World::Begin()
|
||||||
batchOldShadingRate = ShadingRate::SR_1x1;
|
batchOldShadingRate = ShadingRate::SR_1x1;
|
||||||
batchShadingRate = ShadingRate::SR_1x1;
|
batchShadingRate = ShadingRate::SR_1x1;
|
||||||
|
|
||||||
TextureBarrier tb(depthTexture, ResourceStates::DepthWriteBit);
|
CmdBeginBarrier();
|
||||||
CmdBarrier(1, &tb);
|
CmdTextureBarrier(depthTexture, ResourceStates::DepthWriteBit);
|
||||||
|
CmdEndBarrier();
|
||||||
}
|
}
|
||||||
|
|
||||||
void World::End()
|
void World::End()
|
||||||
|
@ -476,14 +477,16 @@ void World::BeginBatch(const shader_t* shader, bool hasStaticGeo, BatchType::Id
|
||||||
{
|
{
|
||||||
if(type == BatchType::DepthFade && batchType != BatchType::DepthFade)
|
if(type == BatchType::DepthFade && batchType != BatchType::DepthFade)
|
||||||
{
|
{
|
||||||
TextureBarrier barrier(depthTexture, ResourceStates::PixelShaderAccessBit);
|
CmdBeginBarrier();
|
||||||
CmdBarrier(1, &barrier);
|
CmdTextureBarrier(depthTexture, ResourceStates::PixelShaderAccessBit);
|
||||||
|
CmdEndBarrier();
|
||||||
CmdBindRenderTargets(1, &grp.renderTarget, NULL);
|
CmdBindRenderTargets(1, &grp.renderTarget, NULL);
|
||||||
}
|
}
|
||||||
else if(type != BatchType::DepthFade && batchType == BatchType::DepthFade)
|
else if(type != BatchType::DepthFade && batchType == BatchType::DepthFade)
|
||||||
{
|
{
|
||||||
TextureBarrier barrier(depthTexture, ResourceStates::DepthWriteBit);
|
CmdBeginBarrier();
|
||||||
CmdBarrier(1, &barrier);
|
CmdTextureBarrier(depthTexture, ResourceStates::DepthWriteBit);
|
||||||
|
CmdEndBarrier();
|
||||||
CmdBindRenderTargets(1, &grp.renderTarget, &depthTexture);
|
CmdBindRenderTargets(1, &grp.renderTarget, &depthTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -741,8 +744,9 @@ void World::DrawGUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
TextureBarrier tb(depthTexture, ResourceStates::DepthReadBit);
|
CmdBeginBarrier();
|
||||||
CmdBarrier(1, &tb);
|
CmdTextureBarrier(depthTexture, ResourceStates::DepthReadBit);
|
||||||
|
CmdEndBarrier();
|
||||||
if(ImGui::Begin("depth", NULL, ImGuiWindowFlags_AlwaysAutoResize))
|
if(ImGui::Begin("depth", NULL, ImGuiWindowFlags_AlwaysAutoResize))
|
||||||
{
|
{
|
||||||
ImGui::Image((ImTextureID)depthTextureIndex, ImVec2(640, 360));
|
ImGui::Image((ImTextureID)depthTextureIndex, ImVec2(640, 360));
|
||||||
|
@ -1038,8 +1042,9 @@ void World::DrawSceneView(const drawSceneViewCommand_t& cmd)
|
||||||
boundVertexBuffers = BufferFamily::Invalid;
|
boundVertexBuffers = BufferFamily::Invalid;
|
||||||
boundIndexBuffer = BufferFamily::Invalid;
|
boundIndexBuffer = BufferFamily::Invalid;
|
||||||
|
|
||||||
const TextureBarrier depthWriteBarrier(depthTexture, ResourceStates::DepthWriteBit);
|
CmdBeginBarrier();
|
||||||
CmdBarrier(1, &depthWriteBarrier);
|
CmdTextureBarrier(depthTexture, ResourceStates::DepthWriteBit);
|
||||||
|
CmdEndBarrier();
|
||||||
}
|
}
|
||||||
|
|
||||||
int entityNum;
|
int entityNum;
|
||||||
|
@ -1215,8 +1220,10 @@ void World::DrawFog()
|
||||||
CmdBindIndexBuffer(boxIndexBuffer, IndexType::UInt32, 0);
|
CmdBindIndexBuffer(boxIndexBuffer, IndexType::UInt32, 0);
|
||||||
|
|
||||||
CmdBindRenderTargets(1, &grp.renderTarget, NULL);
|
CmdBindRenderTargets(1, &grp.renderTarget, NULL);
|
||||||
const TextureBarrier depthReadBarrier(depthTexture, ResourceStates::PixelShaderAccessBit);
|
|
||||||
CmdBarrier(1, &depthReadBarrier);
|
CmdBeginBarrier();
|
||||||
|
CmdTextureBarrier(depthTexture, ResourceStates::PixelShaderAccessBit);
|
||||||
|
CmdEndBarrier();
|
||||||
|
|
||||||
for(int f = 1; f < tr.world->numfogs; ++f)
|
for(int f = 1; f < tr.world->numfogs; ++f)
|
||||||
{
|
{
|
||||||
|
|
|
@ -565,7 +565,7 @@ namespace RHI
|
||||||
uint32_t durationQueryCount;
|
uint32_t durationQueryCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Pix
|
struct PIX
|
||||||
{
|
{
|
||||||
typedef void(WINAPI* BeginEventOnCommandListPtr)(ID3D12GraphicsCommandList* commandList, UINT64 color, _In_ PCSTR formatString);
|
typedef void(WINAPI* BeginEventOnCommandListPtr)(ID3D12GraphicsCommandList* commandList, UINT64 color, _In_ PCSTR formatString);
|
||||||
typedef void(WINAPI* EndEventOnCommandListPtr)(ID3D12GraphicsCommandList* commandList);
|
typedef void(WINAPI* EndEventOnCommandListPtr)(ID3D12GraphicsCommandList* commandList);
|
||||||
|
@ -608,6 +608,32 @@ namespace RHI
|
||||||
DescriptorRange samplerIndex;
|
DescriptorRange samplerIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct BufferBarrier
|
||||||
|
{
|
||||||
|
BufferBarrier() = default;
|
||||||
|
BufferBarrier(HBuffer buffer_, ResourceStates::Flags newState_)
|
||||||
|
{
|
||||||
|
buffer = buffer_;
|
||||||
|
newState = newState_;
|
||||||
|
}
|
||||||
|
|
||||||
|
HBuffer buffer = RHI_MAKE_NULL_HANDLE();
|
||||||
|
ResourceStates::Flags newState = ResourceStates::Common;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TextureBarrier
|
||||||
|
{
|
||||||
|
TextureBarrier() = default;
|
||||||
|
TextureBarrier(HTexture texture_, ResourceStates::Flags newState_)
|
||||||
|
{
|
||||||
|
texture = texture_;
|
||||||
|
newState = newState_;
|
||||||
|
}
|
||||||
|
|
||||||
|
HTexture texture = RHI_MAKE_NULL_HANDLE();
|
||||||
|
ResourceStates::Flags newState = ResourceStates::Common;
|
||||||
|
};
|
||||||
|
|
||||||
struct RHIPrivate
|
struct RHIPrivate
|
||||||
{
|
{
|
||||||
bool initialized;
|
bool initialized;
|
||||||
|
@ -704,9 +730,17 @@ namespace RHI
|
||||||
StaticUnorderedArray<HBuffer, 64> buffersToTransition;
|
StaticUnorderedArray<HBuffer, 64> buffersToTransition;
|
||||||
FrameQueries frameQueries[FrameCount];
|
FrameQueries frameQueries[FrameCount];
|
||||||
ResolvedQueries resolvedQueries;
|
ResolvedQueries resolvedQueries;
|
||||||
Pix pix;
|
PIX pix;
|
||||||
int64_t beforeInputSamplingUS;
|
int64_t beforeInputSamplingUS;
|
||||||
int64_t beforeRenderingUS;
|
int64_t beforeRenderingUS;
|
||||||
|
|
||||||
|
// immediate-mode barrier API
|
||||||
|
TextureBarrier textureBarriers[64];
|
||||||
|
BufferBarrier bufferBarriers[64];
|
||||||
|
uint32_t textureBarrierCount;
|
||||||
|
uint32_t bufferBarrierCount;
|
||||||
|
ID3D12GraphicsCommandList* barrierCommandList;
|
||||||
|
bool barrierOpen;
|
||||||
};
|
};
|
||||||
|
|
||||||
static RHIPrivate rhi;
|
static RHIPrivate rhi;
|
||||||
|
@ -2626,6 +2660,38 @@ namespace RHI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void Barrier(uint32_t texCount, const TextureBarrier* textures, uint32_t buffCount, const BufferBarrier* buffers)
|
||||||
|
{
|
||||||
|
Q_assert(CanWriteCommands());
|
||||||
|
|
||||||
|
static D3D12_RESOURCE_BARRIER barriers[MAX_DRAWIMAGES * 2];
|
||||||
|
Q_assert(buffCount + texCount <= ARRAY_LEN(barriers));
|
||||||
|
|
||||||
|
UINT barrierCount = 0;
|
||||||
|
for(uint32_t i = 0; i < texCount; ++i)
|
||||||
|
{
|
||||||
|
Texture& texture = rhi.textures.Get(textures[i].texture);
|
||||||
|
if(SetBarrier(texture.currentState, barriers[barrierCount], textures[i].newState, texture.texture))
|
||||||
|
{
|
||||||
|
barrierCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
for(uint32_t i = 0; i < buffCount; ++i)
|
||||||
|
{
|
||||||
|
Buffer& buffer = rhi.buffers.Get(buffers[i].buffer);
|
||||||
|
if(SetBarrier(buffer.currentState, barriers[barrierCount], buffers[i].newState, buffer.buffer))
|
||||||
|
{
|
||||||
|
barrierCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(barrierCount > 0)
|
||||||
|
{
|
||||||
|
rhi.commandList->ResourceBarrier(barrierCount, barriers);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void DrawResourceUsage()
|
static void DrawResourceUsage()
|
||||||
{
|
{
|
||||||
if(BeginTable("Handles", 3))
|
if(BeginTable("Handles", 3))
|
||||||
|
@ -3348,9 +3414,9 @@ namespace RHI
|
||||||
rhi.pix.module = LoadLibraryA("cnq3/WinPixEventRuntime.dll");
|
rhi.pix.module = LoadLibraryA("cnq3/WinPixEventRuntime.dll");
|
||||||
if(rhi.pix.module != NULL)
|
if(rhi.pix.module != NULL)
|
||||||
{
|
{
|
||||||
rhi.pix.BeginEventOnCommandList = (Pix::BeginEventOnCommandListPtr)GetProcAddress(rhi.pix.module, "PIXBeginEventOnCommandList");
|
rhi.pix.BeginEventOnCommandList = (PIX::BeginEventOnCommandListPtr)GetProcAddress(rhi.pix.module, "PIXBeginEventOnCommandList");
|
||||||
rhi.pix.EndEventOnCommandList = (Pix::EndEventOnCommandListPtr)GetProcAddress(rhi.pix.module, "PIXEndEventOnCommandList");
|
rhi.pix.EndEventOnCommandList = (PIX::EndEventOnCommandListPtr)GetProcAddress(rhi.pix.module, "PIXEndEventOnCommandList");
|
||||||
rhi.pix.SetMarkerOnCommandList = (Pix::SetMarkerOnCommandListPtr)GetProcAddress(rhi.pix.module, "PIXSetMarkerOnCommandList");
|
rhi.pix.SetMarkerOnCommandList = (PIX::SetMarkerOnCommandListPtr)GetProcAddress(rhi.pix.module, "PIXSetMarkerOnCommandList");
|
||||||
rhi.pix.canBeginAndEnd = rhi.pix.BeginEventOnCommandList != NULL && rhi.pix.EndEventOnCommandList != NULL;
|
rhi.pix.canBeginAndEnd = rhi.pix.BeginEventOnCommandList != NULL && rhi.pix.EndEventOnCommandList != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3542,10 +3608,7 @@ namespace RHI
|
||||||
|
|
||||||
rhi.commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
rhi.commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
|
||||||
|
|
||||||
const TextureBarrier barrier(rhi.renderTargets[rhi.swapChainBufferIndex], ResourceStates::RenderTargetBit);
|
static TextureBarrier textureBarriers[MAX_DRAWIMAGES + 1];
|
||||||
CmdBarrier(1, &barrier);
|
|
||||||
|
|
||||||
static TextureBarrier textureBarriers[MAX_DRAWIMAGES];
|
|
||||||
static BufferBarrier bufferBarriers[64];
|
static BufferBarrier bufferBarriers[64];
|
||||||
for(uint32_t t = 0; t < rhi.texturesToTransition.count; ++t)
|
for(uint32_t t = 0; t < rhi.texturesToTransition.count; ++t)
|
||||||
{
|
{
|
||||||
|
@ -3553,13 +3616,14 @@ namespace RHI
|
||||||
const Texture& texture = rhi.textures.Get(handle);
|
const Texture& texture = rhi.textures.Get(handle);
|
||||||
textureBarriers[t] = TextureBarrier(handle, texture.desc.initialState);
|
textureBarriers[t] = TextureBarrier(handle, texture.desc.initialState);
|
||||||
}
|
}
|
||||||
|
textureBarriers[rhi.texturesToTransition.count] = TextureBarrier(rhi.renderTargets[rhi.swapChainBufferIndex], ResourceStates::RenderTargetBit);
|
||||||
for(uint32_t b = 0; b < rhi.buffersToTransition.count; ++b)
|
for(uint32_t b = 0; b < rhi.buffersToTransition.count; ++b)
|
||||||
{
|
{
|
||||||
const HBuffer handle = rhi.buffersToTransition[b];
|
const HBuffer handle = rhi.buffersToTransition[b];
|
||||||
const Buffer& buffer = rhi.buffers.Get(handle);
|
const Buffer& buffer = rhi.buffers.Get(handle);
|
||||||
bufferBarriers[b] = BufferBarrier(handle, buffer.desc.initialState);
|
bufferBarriers[b] = BufferBarrier(handle, buffer.desc.initialState);
|
||||||
}
|
}
|
||||||
CmdBarrier(rhi.texturesToTransition.count, textureBarriers, rhi.buffersToTransition.count, bufferBarriers);
|
Barrier(rhi.texturesToTransition.count, textureBarriers, rhi.buffersToTransition.count, bufferBarriers);
|
||||||
rhi.texturesToTransition.Clear();
|
rhi.texturesToTransition.Clear();
|
||||||
rhi.buffersToTransition.Clear();
|
rhi.buffersToTransition.Clear();
|
||||||
|
|
||||||
|
@ -3577,8 +3641,9 @@ namespace RHI
|
||||||
|
|
||||||
CmdInsertDebugLabel("RHI::EndFrame", 0.8f, 0.8f, 0.8f);
|
CmdInsertDebugLabel("RHI::EndFrame", 0.8f, 0.8f, 0.8f);
|
||||||
|
|
||||||
const TextureBarrier barrier(rhi.renderTargets[rhi.swapChainBufferIndex], ResourceStates::PresentBit);
|
CmdBeginBarrier();
|
||||||
CmdBarrier(1, &barrier);
|
CmdTextureBarrier(rhi.renderTargets[rhi.swapChainBufferIndex], ResourceStates::PresentBit);
|
||||||
|
CmdEndBarrier();
|
||||||
|
|
||||||
CmdEndDurationQuery(rhi.frameDurationQueryIndex);
|
CmdEndDurationQuery(rhi.frameDurationQueryIndex);
|
||||||
|
|
||||||
|
@ -4770,36 +4835,73 @@ namespace RHI
|
||||||
query.state = QueryState::Ended;
|
query.state = QueryState::Ended;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmdBarrier(uint32_t texCount, const TextureBarrier* textures, uint32_t buffCount, const BufferBarrier* buffers)
|
void CmdBeginBarrier()
|
||||||
{
|
{
|
||||||
Q_assert(CanWriteCommands());
|
Q_assert(CanWriteCommands());
|
||||||
|
Q_assert(rhi.textureBarrierCount == 0);
|
||||||
|
Q_assert(rhi.bufferBarrierCount == 0);
|
||||||
|
Q_assert(!rhi.barrierOpen);
|
||||||
|
Q_assert(rhi.barrierCommandList == NULL);
|
||||||
|
|
||||||
static D3D12_RESOURCE_BARRIER barriers[MAX_DRAWIMAGES * 2];
|
rhi.barrierCommandList = rhi.commandList;
|
||||||
Q_assert(buffCount + texCount <= ARRAY_LEN(barriers));
|
rhi.textureBarrierCount = 0;
|
||||||
|
rhi.bufferBarrierCount = 0;
|
||||||
|
rhi.barrierOpen = true;
|
||||||
|
}
|
||||||
|
|
||||||
UINT barrierCount = 0;
|
void CmdTextureBarrier(HTexture texture, ResourceStates::Flags newState)
|
||||||
for(uint32_t i = 0; i < texCount; ++i)
|
{
|
||||||
|
Q_assert(CanWriteCommands());
|
||||||
|
Q_assert(rhi.barrierOpen);
|
||||||
|
Q_assert(rhi.commandList == rhi.barrierCommandList);
|
||||||
|
Q_assert(rhi.textureBarrierCount < ARRAY_LEN(rhi.textureBarriers));
|
||||||
|
|
||||||
|
if(rhi.textureBarrierCount < ARRAY_LEN(rhi.textureBarriers))
|
||||||
{
|
{
|
||||||
Texture& texture = rhi.textures.Get(textures[i].texture);
|
TextureBarrier* const barrier = &rhi.textureBarriers[rhi.textureBarrierCount++];
|
||||||
if(SetBarrier(texture.currentState, barriers[barrierCount], textures[i].newState, texture.texture))
|
barrier->texture = texture;
|
||||||
{
|
barrier->newState = newState;
|
||||||
barrierCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
for(uint32_t i = 0; i < buffCount; ++i)
|
else
|
||||||
{
|
{
|
||||||
Buffer& buffer = rhi.buffers.Get(buffers[i].buffer);
|
ri.Error(ERR_FATAL, "Not enough texture barrier storage!\n");
|
||||||
if(SetBarrier(buffer.currentState, barriers[barrierCount], buffers[i].newState, buffer.buffer))
|
}
|
||||||
{
|
}
|
||||||
barrierCount++;
|
|
||||||
}
|
void CmdBufferBarrier(HBuffer buffer, ResourceStates::Flags newState)
|
||||||
|
{
|
||||||
|
Q_assert(CanWriteCommands());
|
||||||
|
Q_assert(rhi.barrierOpen);
|
||||||
|
Q_assert(rhi.commandList == rhi.barrierCommandList);
|
||||||
|
Q_assert(rhi.bufferBarrierCount < ARRAY_LEN(rhi.bufferBarriers));
|
||||||
|
|
||||||
|
if(rhi.bufferBarrierCount < ARRAY_LEN(rhi.bufferBarriers))
|
||||||
|
{
|
||||||
|
BufferBarrier* const barrier = &rhi.bufferBarriers[rhi.bufferBarrierCount++];
|
||||||
|
barrier->buffer = buffer;
|
||||||
|
barrier->newState = newState;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ri.Error(ERR_FATAL, "Not enough buffer barrier storage!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CmdEndBarrier()
|
||||||
|
{
|
||||||
|
Q_assert(CanWriteCommands());
|
||||||
|
Q_assert(rhi.barrierOpen);
|
||||||
|
Q_assert(rhi.commandList == rhi.barrierCommandList);
|
||||||
|
|
||||||
|
if(rhi.textureBarrierCount > 0 || rhi.bufferBarrierCount > 0)
|
||||||
|
{
|
||||||
|
Barrier(rhi.textureBarrierCount, rhi.textureBarriers, rhi.bufferBarrierCount, rhi.bufferBarriers);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(barrierCount > 0)
|
rhi.barrierCommandList = NULL;
|
||||||
{
|
rhi.textureBarrierCount = 0;
|
||||||
rhi.commandList->ResourceBarrier(barrierCount, barriers);
|
rhi.bufferBarrierCount = 0;
|
||||||
}
|
rhi.barrierOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CmdClearColorTarget(HTexture texture, const vec4_t clearColor, const Rect* rect)
|
void CmdClearColorTarget(HTexture texture, const vec4_t clearColor, const Rect* rect)
|
||||||
|
|
|
@ -552,32 +552,6 @@ namespace RHI
|
||||||
HRootSignature rootSignature = RHI_MAKE_NULL_HANDLE();
|
HRootSignature rootSignature = RHI_MAKE_NULL_HANDLE();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BufferBarrier
|
|
||||||
{
|
|
||||||
BufferBarrier() = default;
|
|
||||||
BufferBarrier(HBuffer buffer_, ResourceStates::Flags newState_)
|
|
||||||
{
|
|
||||||
buffer = buffer_;
|
|
||||||
newState = newState_;
|
|
||||||
}
|
|
||||||
|
|
||||||
HBuffer buffer = RHI_MAKE_NULL_HANDLE();
|
|
||||||
ResourceStates::Flags newState = ResourceStates::Common;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct TextureBarrier
|
|
||||||
{
|
|
||||||
TextureBarrier() = default;
|
|
||||||
TextureBarrier(HTexture texture_, ResourceStates::Flags newState_)
|
|
||||||
{
|
|
||||||
texture = texture_;
|
|
||||||
newState = newState_;
|
|
||||||
}
|
|
||||||
|
|
||||||
HTexture texture = RHI_MAKE_NULL_HANDLE();
|
|
||||||
ResourceStates::Flags newState = ResourceStates::Common;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct DescriptorTableUpdate
|
struct DescriptorTableUpdate
|
||||||
{
|
{
|
||||||
// note that for our texture UAVs,
|
// note that for our texture UAVs,
|
||||||
|
@ -747,7 +721,10 @@ namespace RHI
|
||||||
void CmdDispatch(uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ);
|
void CmdDispatch(uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ);
|
||||||
uint32_t CmdBeginDurationQuery();
|
uint32_t CmdBeginDurationQuery();
|
||||||
void CmdEndDurationQuery(uint32_t index);
|
void CmdEndDurationQuery(uint32_t index);
|
||||||
void CmdBarrier(uint32_t texCount, const TextureBarrier* textures, uint32_t buffCount = 0, const BufferBarrier* buffers = NULL);
|
void CmdBeginBarrier();
|
||||||
|
void CmdTextureBarrier(HTexture texture, ResourceStates::Flags newState);
|
||||||
|
void CmdBufferBarrier(HBuffer buffer, ResourceStates::Flags newState);
|
||||||
|
void CmdEndBarrier();
|
||||||
void CmdClearColorTarget(HTexture texture, const vec4_t clearColor, const Rect* rect = NULL);
|
void CmdClearColorTarget(HTexture texture, const vec4_t clearColor, const Rect* rect = NULL);
|
||||||
void CmdClearDepthStencilTarget(HTexture texture, bool clearDepth, float depth, bool clearStencil = false, uint8_t stencil = 0, const Rect* rect = NULL);
|
void CmdClearDepthStencilTarget(HTexture texture, bool clearDepth, float depth, bool clearStencil = false, uint8_t stencil = 0, const Rect* rect = NULL);
|
||||||
void CmdClearTextureUAV(HTexture texture, uint32_t mipIndex, const uint32_t* values);
|
void CmdClearTextureUAV(HTexture texture, uint32_t mipIndex, const uint32_t* values);
|
||||||
|
|
|
@ -485,16 +485,16 @@ void SRP::EndFrame()
|
||||||
tr.tracedWorldShaderIndex = -1;
|
tr.tracedWorldShaderIndex = -1;
|
||||||
if(tr.traceWorldShader && tr.world != NULL)
|
if(tr.traceWorldShader && tr.world != NULL)
|
||||||
{
|
{
|
||||||
|
CmdBeginBarrier();
|
||||||
|
CmdBufferBarrier(traceRenderBuffer, ResourceStates::CopySourceBit);
|
||||||
|
CmdEndBarrier();
|
||||||
|
|
||||||
// schedule a GPU -> CPU transfer
|
// schedule a GPU -> CPU transfer
|
||||||
{
|
|
||||||
BufferBarrier barrier(traceRenderBuffer, ResourceStates::CopySourceBit);
|
|
||||||
CmdBarrier(0, NULL, 1, &barrier);
|
|
||||||
}
|
|
||||||
CmdCopyBuffer(traceReadbackBuffer, traceRenderBuffer);
|
CmdCopyBuffer(traceReadbackBuffer, traceRenderBuffer);
|
||||||
{
|
|
||||||
BufferBarrier barrier(traceRenderBuffer, ResourceStates::UnorderedAccessBit);
|
CmdBeginBarrier();
|
||||||
CmdBarrier(0, NULL, 1, &barrier);
|
CmdBufferBarrier(traceRenderBuffer, ResourceStates::UnorderedAccessBit);
|
||||||
}
|
CmdEndBarrier();
|
||||||
|
|
||||||
// grab last frame's result
|
// grab last frame's result
|
||||||
uint32_t* shaderIndices = (uint32_t*)MapBuffer(traceReadbackBuffer);
|
uint32_t* shaderIndices = (uint32_t*)MapBuffer(traceReadbackBuffer);
|
||||||
|
|
|
@ -142,16 +142,6 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
|
||||||
|
|
||||||
BeginTempCommandList();
|
BeginTempCommandList();
|
||||||
|
|
||||||
{
|
|
||||||
TextureBarrier allBarriers[MipSlice::Count + 1];
|
|
||||||
for(int i = 0; i < MipSlice::Count; ++i)
|
|
||||||
{
|
|
||||||
allBarriers[i] = TextureBarrier(textures[i], ResourceStates::UnorderedAccessBit);
|
|
||||||
}
|
|
||||||
allBarriers[MipSlice::Count] = TextureBarrier(texture, ResourceStates::UnorderedAccessBit);
|
|
||||||
CmdBarrier(ARRAY_LEN(allBarriers), allBarriers);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!ddhi)
|
if(!ddhi)
|
||||||
{
|
{
|
||||||
// this must happen after the BeginTempCommandList call because
|
// this must happen after the BeginTempCommandList call because
|
||||||
|
@ -182,6 +172,11 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
|
||||||
StartConstants rc = {};
|
StartConstants rc = {};
|
||||||
rc.gamma = r_mipGenGamma->value;
|
rc.gamma = r_mipGenGamma->value;
|
||||||
|
|
||||||
|
CmdBeginBarrier();
|
||||||
|
CmdTextureBarrier(textures[MipSlice::Float16_0], ResourceStates::UnorderedAccessBit);
|
||||||
|
CmdTextureBarrier(texture, ResourceStates::UnorderedAccessBit);
|
||||||
|
CmdEndBarrier();
|
||||||
|
|
||||||
if(!ddhi)
|
if(!ddhi)
|
||||||
{
|
{
|
||||||
CmdBindRootSignature(stage.rootSignature);
|
CmdBindRootSignature(stage.rootSignature);
|
||||||
|
@ -201,12 +196,6 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
|
||||||
Dispatch(w, h);
|
Dispatch(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureBarrier tempBarriers[MipSlice::Count];
|
|
||||||
for(int i = 0; i < MipSlice::Count; ++i)
|
|
||||||
{
|
|
||||||
tempBarriers[i] = TextureBarrier(textures[i], ResourceStates::UnorderedAccessBit);
|
|
||||||
}
|
|
||||||
|
|
||||||
// overwrite mip 0 to apply r_intensity if needed
|
// overwrite mip 0 to apply r_intensity if needed
|
||||||
if((image->flags & IMG_NOIMANIP) == 0 &&
|
if((image->flags & IMG_NOIMANIP) == 0 &&
|
||||||
r_intensity->value != 1.0f)
|
r_intensity->value != 1.0f)
|
||||||
|
@ -221,6 +210,11 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
|
||||||
rc.srcMip = MipSlice::Float16_0;
|
rc.srcMip = MipSlice::Float16_0;
|
||||||
rc.dstMip = MipSlice::Count + destMip;
|
rc.dstMip = MipSlice::Count + destMip;
|
||||||
|
|
||||||
|
CmdBeginBarrier();
|
||||||
|
CmdTextureBarrier(textures[MipSlice::Float16_0], ResourceStates::UnorderedAccessBit);
|
||||||
|
CmdTextureBarrier(texture, ResourceStates::UnorderedAccessBit);
|
||||||
|
CmdEndBarrier();
|
||||||
|
|
||||||
if(!ddhi)
|
if(!ddhi)
|
||||||
{
|
{
|
||||||
CmdBindRootSignature(stage.rootSignature);
|
CmdBindRootSignature(stage.rootSignature);
|
||||||
|
@ -237,7 +231,6 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
|
||||||
CmdBindDescriptorTable(stage.rootSignature, stage.descriptorTable);
|
CmdBindDescriptorTable(stage.rootSignature, stage.descriptorTable);
|
||||||
CmdSetRootConstants(stage.rootSignature, ShaderStage::Compute, &rc);
|
CmdSetRootConstants(stage.rootSignature, ShaderStage::Compute, &rc);
|
||||||
}
|
}
|
||||||
CmdBarrier(ARRAY_LEN(tempBarriers), tempBarriers);
|
|
||||||
Dispatch(w, h);
|
Dispatch(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,6 +258,11 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
|
||||||
CmdBindDescriptorTable(stage.rootSignature, stage.descriptorTable);
|
CmdBindDescriptorTable(stage.rootSignature, stage.descriptorTable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CmdBeginBarrier();
|
||||||
|
CmdTextureBarrier(textures[MipSlice::Float16_0], ResourceStates::UnorderedAccessBit);
|
||||||
|
CmdTextureBarrier(textures[MipSlice::Float16_1], ResourceStates::UnorderedAccessBit);
|
||||||
|
CmdEndBarrier();
|
||||||
|
|
||||||
// down-sample on the X-axis
|
// down-sample on the X-axis
|
||||||
rc.srcMip = MipSlice::Float16_0;
|
rc.srcMip = MipSlice::Float16_0;
|
||||||
rc.dstMip = MipSlice::Float16_1;
|
rc.dstMip = MipSlice::Float16_1;
|
||||||
|
@ -284,9 +282,13 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
|
||||||
{
|
{
|
||||||
CmdSetRootConstants(stage.rootSignature, ShaderStage::Compute, &rc);
|
CmdSetRootConstants(stage.rootSignature, ShaderStage::Compute, &rc);
|
||||||
}
|
}
|
||||||
CmdBarrier(ARRAY_LEN(tempBarriers), tempBarriers);
|
|
||||||
Dispatch(w, hs);
|
Dispatch(w, hs);
|
||||||
|
|
||||||
|
CmdBeginBarrier();
|
||||||
|
CmdTextureBarrier(textures[MipSlice::Float16_0], ResourceStates::UnorderedAccessBit);
|
||||||
|
CmdTextureBarrier(textures[MipSlice::Float16_1], ResourceStates::UnorderedAccessBit);
|
||||||
|
CmdEndBarrier();
|
||||||
|
|
||||||
// down-sample on the Y-axis
|
// down-sample on the Y-axis
|
||||||
rc.srcMip = MipSlice::Float16_1;
|
rc.srcMip = MipSlice::Float16_1;
|
||||||
rc.dstMip = MipSlice::Float16_0;
|
rc.dstMip = MipSlice::Float16_0;
|
||||||
|
@ -306,7 +308,6 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
|
||||||
{
|
{
|
||||||
CmdSetRootConstants(stage.rootSignature, ShaderStage::Compute, &rc);
|
CmdSetRootConstants(stage.rootSignature, ShaderStage::Compute, &rc);
|
||||||
}
|
}
|
||||||
CmdBarrier(ARRAY_LEN(tempBarriers), tempBarriers);
|
|
||||||
Dispatch(w, h);
|
Dispatch(w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -322,6 +323,11 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
|
||||||
rc.srcMip = MipSlice::Float16_0;
|
rc.srcMip = MipSlice::Float16_0;
|
||||||
rc.dstMip = MipSlice::Count + destMip;
|
rc.dstMip = MipSlice::Count + destMip;
|
||||||
|
|
||||||
|
CmdBeginBarrier();
|
||||||
|
CmdTextureBarrier(textures[MipSlice::Float16_0], ResourceStates::UnorderedAccessBit);
|
||||||
|
CmdTextureBarrier(texture, ResourceStates::UnorderedAccessBit);
|
||||||
|
CmdEndBarrier();
|
||||||
|
|
||||||
if(!ddhi)
|
if(!ddhi)
|
||||||
{
|
{
|
||||||
CmdBindRootSignature(stage.rootSignature);
|
CmdBindRootSignature(stage.rootSignature);
|
||||||
|
@ -338,7 +344,6 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
|
||||||
CmdBindDescriptorTable(stage.rootSignature, stage.descriptorTable);
|
CmdBindDescriptorTable(stage.rootSignature, stage.descriptorTable);
|
||||||
CmdSetRootConstants(stage.rootSignature, ShaderStage::Compute, &rc);
|
CmdSetRootConstants(stage.rootSignature, ShaderStage::Compute, &rc);
|
||||||
}
|
}
|
||||||
CmdBarrier(ARRAY_LEN(tempBarriers), tempBarriers);
|
|
||||||
Dispatch(w, h);
|
Dispatch(w, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,8 +109,9 @@ void UI::Begin(HTexture renderTarget)
|
||||||
|
|
||||||
renderPassIndex = srp.BeginRenderPass("UI", 0.0f, 0.85f, 1.0f);
|
renderPassIndex = srp.BeginRenderPass("UI", 0.0f, 0.85f, 1.0f);
|
||||||
|
|
||||||
const TextureBarrier tb(renderTarget, ResourceStates::RenderTargetBit);
|
CmdBeginBarrier();
|
||||||
CmdBarrier(1, &tb);
|
CmdTextureBarrier(renderTarget, ResourceStates::RenderTargetBit);
|
||||||
|
CmdEndBarrier();
|
||||||
|
|
||||||
CmdBindRenderTargets(1, &renderTarget, NULL);
|
CmdBindRenderTargets(1, &renderTarget, NULL);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue