moved to an immediate-mode barrier API

This commit is contained in:
myT 2024-01-15 17:10:36 +01:00
parent 708825ea5e
commit c70df1f2af
17 changed files with 357 additions and 319 deletions

View file

@ -176,11 +176,9 @@ void AccumDepthOfField::Begin(const drawSceneViewCommand_t& cmd)
{
CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight);
const TextureBarrier texBarriers[] =
{
TextureBarrier(accumTexture, ResourceStates::RenderTargetBit)
};
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers);
CmdBeginBarrier();
CmdTextureBarrier(accumTexture, ResourceStates::RenderTargetBit);
CmdEndBarrier();
CmdClearColorTarget(accumTexture, vec4_zero);
@ -265,12 +263,10 @@ void AccumDepthOfField::Accumulate()
SCOPED_RENDER_PASS("DOF Accum", 0.5f, 1.0f, 0.5f);
const TextureBarrier texBarriers[] =
{
TextureBarrier(crp.renderTarget, ResourceStates::PixelShaderAccessBit),
TextureBarrier(accumTexture, ResourceStates::RenderTargetBit)
};
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers);
CmdBeginBarrier();
CmdTextureBarrier(crp.renderTarget, ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(accumTexture, ResourceStates::RenderTargetBit);
CmdEndBarrier();
DOFAccumRC rc = {};
rc.textureIndex = GetTextureIndexSRV(crp.renderTarget);
@ -289,12 +285,10 @@ void AccumDepthOfField::Normalize()
{
SCOPED_RENDER_PASS("DOF Norm", 0.5f, 1.0f, 0.5f);
const TextureBarrier texBarriers[] =
{
TextureBarrier(accumTexture, ResourceStates::PixelShaderAccessBit),
TextureBarrier(crp.renderTarget, ResourceStates::RenderTargetBit)
};
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers);
CmdBeginBarrier();
CmdTextureBarrier(accumTexture, ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(crp.renderTarget, ResourceStates::RenderTargetBit);
CmdEndBarrier();
DOFNormRC rc = {};
rc.textureIndex = GetTextureIndexSRV(accumTexture);
@ -326,13 +320,12 @@ void AccumDepthOfField::DrawDebug()
SCOPED_RENDER_PASS("DOF Debug", 0.5f, 1.0f, 0.5f);
crp.SwapRenderTargets();
const TextureBarrier texBarriers[] =
{
TextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit),
TextureBarrier(crp.depthTexture, ResourceStates::PixelShaderAccessBit),
TextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit)
};
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers);
CmdBeginBarrier();
CmdTextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(crp.depthTexture, ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit);
CmdEndBarrier();
float mvp[16];
DOFDebugRC rc = {};

View file

@ -266,13 +266,12 @@ void GatherDepthOfField::DrawDebug()
SCOPED_RENDER_PASS("DOF Debug", 0.125f, 0.125f, 0.25f);
crp.SwapRenderTargets();
const TextureBarrier barriers[] =
{
TextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit),
TextureBarrier(crp.depthTexture, ResourceStates::PixelShaderAccessBit),
TextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit)
};
CmdBarrier(ARRAY_LEN(barriers), barriers);
CmdBeginBarrier();
CmdTextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(crp.depthTexture, ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit);
CmdEndBarrier();
DOFDebugRC rc = {};
rc.colorTextureIndex = GetTextureIndexSRV(crp.GetReadRenderTarget());
@ -295,16 +294,14 @@ void GatherDepthOfField::DrawSplit()
{
SCOPED_RENDER_PASS("DOF Split", 0.125f, 0.125f, 0.25f);
const TextureBarrier barriers[] =
{
TextureBarrier(crp.depthTexture, ResourceStates::ComputeShaderAccessBit),
TextureBarrier(crp.renderTarget, ResourceStates::ComputeShaderAccessBit),
TextureBarrier(nearColorTexture, ResourceStates::UnorderedAccessBit),
TextureBarrier(farColorTexture, ResourceStates::UnorderedAccessBit),
TextureBarrier(nearCocTexture, ResourceStates::UnorderedAccessBit),
TextureBarrier(farCocTexture, ResourceStates::UnorderedAccessBit)
};
CmdBarrier(ARRAY_LEN(barriers), barriers);
CmdBeginBarrier();
CmdTextureBarrier(crp.depthTexture, ResourceStates::ComputeShaderAccessBit);
CmdTextureBarrier(crp.renderTarget, ResourceStates::ComputeShaderAccessBit);
CmdTextureBarrier(nearColorTexture, ResourceStates::UnorderedAccessBit);
CmdTextureBarrier(farColorTexture, ResourceStates::UnorderedAccessBit);
CmdTextureBarrier(nearCocTexture, ResourceStates::UnorderedAccessBit);
CmdTextureBarrier(farCocTexture, ResourceStates::UnorderedAccessBit);
CmdEndBarrier();
DOFSplitRC rc = {};
rc.depthTextureIndex = GetTextureIndexSRV(crp.depthTexture);
@ -329,12 +326,10 @@ void GatherDepthOfField::DrawNearCocTileGen()
{
SCOPED_RENDER_PASS("DOF Tile Gen", 0.125f, 0.125f, 0.25f);
const TextureBarrier barriers[] =
{
TextureBarrier(nearCocTexture, ResourceStates::ComputeShaderAccessBit),
TextureBarrier(nearCocTileTexture, ResourceStates::UnorderedAccessBit)
};
CmdBarrier(ARRAY_LEN(barriers), barriers);
CmdBeginBarrier();
CmdTextureBarrier(nearCocTexture, ResourceStates::ComputeShaderAccessBit);
CmdTextureBarrier(nearCocTileTexture, ResourceStates::UnorderedAccessBit);
CmdEndBarrier();
DOFNearCocTileGenRC rc = {};
rc.inputTextureIndex = GetTextureIndexSRV(nearCocTexture);
@ -349,12 +344,10 @@ void GatherDepthOfField::DrawNearCocTileMax()
{
SCOPED_RENDER_PASS("DOF Tile Max", 0.125f, 0.125f, 0.25f);
const TextureBarrier barriers[] =
{
TextureBarrier(nearCocTileTexture, ResourceStates::ComputeShaderAccessBit),
TextureBarrier(nearCocTileTexture2, ResourceStates::UnorderedAccessBit)
};
CmdBarrier(ARRAY_LEN(barriers), barriers);
CmdBeginBarrier();
CmdTextureBarrier(nearCocTileTexture, ResourceStates::ComputeShaderAccessBit);
CmdTextureBarrier(nearCocTileTexture2, ResourceStates::UnorderedAccessBit);
CmdEndBarrier();
DOFNearCocTileMaxRC rc = {};
rc.inputTextureIndex = GetTextureIndexSRV(nearCocTileTexture);
@ -370,18 +363,16 @@ void GatherDepthOfField::DrawBlur()
{
SCOPED_RENDER_PASS("DOF Blur", 0.125f, 0.125f, 0.25f);
const TextureBarrier barriers[] =
{
TextureBarrier(crp.renderTarget, ResourceStates::ComputeShaderAccessBit),
TextureBarrier(nearColorTexture, ResourceStates::ComputeShaderAccessBit),
TextureBarrier(farColorTexture, ResourceStates::ComputeShaderAccessBit),
TextureBarrier(nearCocTexture, ResourceStates::ComputeShaderAccessBit),
TextureBarrier(nearCocTileTexture2, ResourceStates::ComputeShaderAccessBit),
TextureBarrier(farCocTexture, ResourceStates::ComputeShaderAccessBit),
TextureBarrier(nearBlurTexture, ResourceStates::UnorderedAccessBit),
TextureBarrier(farBlurTexture, ResourceStates::UnorderedAccessBit)
};
CmdBarrier(ARRAY_LEN(barriers), barriers);
CmdBeginBarrier();
CmdTextureBarrier(crp.renderTarget, ResourceStates::ComputeShaderAccessBit);
CmdTextureBarrier(nearColorTexture, ResourceStates::ComputeShaderAccessBit);
CmdTextureBarrier(farColorTexture, ResourceStates::ComputeShaderAccessBit);
CmdTextureBarrier(nearCocTexture, ResourceStates::ComputeShaderAccessBit);
CmdTextureBarrier(nearCocTileTexture2, ResourceStates::ComputeShaderAccessBit);
CmdTextureBarrier(farCocTexture, ResourceStates::ComputeShaderAccessBit);
CmdTextureBarrier(nearBlurTexture, ResourceStates::UnorderedAccessBit);
CmdTextureBarrier(farBlurTexture, ResourceStates::UnorderedAccessBit);
CmdEndBarrier();
DOFBlurRC rc = {};
rc.colorTextureIndex = GetTextureIndexSRV(crp.renderTarget);
@ -406,14 +397,12 @@ void GatherDepthOfField::DrawFill()
{
SCOPED_RENDER_PASS("DOF Fill", 0.125f, 0.125f, 0.25f);
const TextureBarrier barriers[] =
{
TextureBarrier(nearBlurTexture, ResourceStates::ComputeShaderAccessBit),
TextureBarrier(farBlurTexture, ResourceStates::ComputeShaderAccessBit),
TextureBarrier(nearColorTexture, ResourceStates::UnorderedAccessBit),
TextureBarrier(farColorTexture, ResourceStates::UnorderedAccessBit)
};
CmdBarrier(ARRAY_LEN(barriers), barriers);
CmdBeginBarrier();
CmdTextureBarrier(nearBlurTexture, ResourceStates::ComputeShaderAccessBit);
CmdTextureBarrier(farBlurTexture, ResourceStates::ComputeShaderAccessBit);
CmdTextureBarrier(nearColorTexture, ResourceStates::UnorderedAccessBit);
CmdTextureBarrier(farColorTexture, ResourceStates::UnorderedAccessBit);
CmdEndBarrier();
DOFFillRC rc = {};
rc.nearInputTextureIndex = GetTextureIndexSRV(nearBlurTexture);
@ -431,16 +420,14 @@ void GatherDepthOfField::DrawCombine()
{
SCOPED_RENDER_PASS("DOF Combine", 0.125f, 0.125f, 0.25f);
const TextureBarrier barriers[] =
{
TextureBarrier(nearColorTexture, ResourceStates::PixelShaderAccessBit),
TextureBarrier(farColorTexture, ResourceStates::PixelShaderAccessBit),
TextureBarrier(nearCocTexture, ResourceStates::PixelShaderAccessBit),
TextureBarrier(farCocTexture, ResourceStates::PixelShaderAccessBit),
TextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit),
TextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit)
};
CmdBarrier(ARRAY_LEN(barriers), barriers);
CmdBeginBarrier();
CmdTextureBarrier(nearColorTexture, ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(farColorTexture, ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(nearCocTexture, ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(farCocTexture, ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit);
CmdEndBarrier();
DOFCombineRC rc = {};
rc.nearTextureIndex = GetTextureIndexSRV(nearColorTexture);

View file

@ -130,12 +130,10 @@ void Fog::Draw()
CmdBindVertexBuffers(1, &boxVertexBuffer, &stride, NULL);
CmdBindIndexBuffer(boxIndexBuffer, IndexType::UInt32, 0);
const TextureBarrier barriers[] =
{
TextureBarrier(crp.depthTexture, ResourceStates::PixelShaderAccessBit),
TextureBarrier(crp.renderTarget, ResourceStates::RenderTargetBit)
};
CmdBarrier(ARRAY_LEN(barriers), barriers);
CmdBeginBarrier();
CmdTextureBarrier(crp.depthTexture, ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(crp.renderTarget, ResourceStates::RenderTargetBit);
CmdEndBarrier();
CmdBindRenderTargets(1, &crp.renderTarget, NULL);

View file

@ -352,9 +352,11 @@ void CRP::BeginFrame()
ui.BeginFrame();
nuklear.BeginFrame();
CmdBeginBarrier();
CmdTextureBarrier(renderTarget, ResourceStates::RenderTargetBit);
CmdEndBarrier();
const float clearColor[4] = { 0.0f, 0.5f, 0.0f, 0.0f };
const TextureBarrier barrier(renderTarget, ResourceStates::RenderTargetBit);
CmdBarrier(1, &barrier);
CmdClearColorTarget(renderTarget, clearColor);
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);
const TextureBarrier barriers[2] =
{
TextureBarrier(source, ResourceStates::PixelShaderAccessBit),
TextureBarrier(destination, ResourceStates::RenderTargetBit)
};
CmdBarrier(ARRAY_LEN(barriers), barriers);
CmdBeginBarrier();
CmdTextureBarrier(source, ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(destination, ResourceStates::RenderTargetBit);
CmdEndBarrier();
#pragma pack(push, 4)
struct BlitRC
@ -564,8 +564,9 @@ void CRP::DrawSceneView(const drawSceneViewCommand_t& cmd)
if(cmd.shouldClearColor)
{
const Rect rect(vp.viewportX, vp.viewportY, vp.viewportWidth, vp.viewportHeight);
const TextureBarrier tb(renderTarget, ResourceStates::RenderTargetBit);
CmdBarrier(1, &tb);
CmdBeginBarrier();
CmdTextureBarrier(renderTarget, ResourceStates::RenderTargetBit);
CmdEndBarrier();
CmdClearColorTarget(renderTarget, cmd.clearColor, &rect);
}
@ -590,8 +591,9 @@ void CRP::DrawSceneView(const drawSceneViewCommand_t& cmd)
srp.enableRenderPassQueries = x == 0 && y == 0;
drawSceneViewCommand_t newCmd;
accumDof.FixCommand(newCmd, cmd, x, y);
const TextureBarrier tb(renderTarget, ResourceStates::RenderTargetBit);
CmdBarrier(1, &tb);
CmdBeginBarrier();
CmdTextureBarrier(renderTarget, ResourceStates::RenderTargetBit);
CmdEndBarrier();
CmdClearColorTarget(renderTarget, cmd.clearColor, &rect);
opaque.Draw(newCmd);
fog.Draw();

View file

@ -99,9 +99,10 @@ void WorldOpaque::Draw(const drawSceneViewCommand_t& cmd)
batchOldDepthHack = false;
batchDepthHack = false;
TextureBarrier tb(crp.depthTexture, ResourceStates::DepthWriteBit);
BufferBarrier bb(srp.traceRenderBuffer, ResourceStates::UnorderedAccessBit);
CmdBarrier(1, &tb, 1, &bb);
CmdBeginBarrier();
CmdTextureBarrier(crp.depthTexture, ResourceStates::DepthWriteBit);
CmdBufferBarrier(srp.traceRenderBuffer, ResourceStates::UnorderedAccessBit);
CmdEndBarrier();
CmdClearDepthStencilTarget(crp.depthTexture, true, 0.0f);

View file

@ -83,12 +83,11 @@ void ToneMap::DrawToneMap()
CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight);
crp.SwapRenderTargets();
const TextureBarrier texBarriers[] =
{
TextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit),
TextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit)
};
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers, 0, NULL);
CmdBeginBarrier();
CmdTextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit);
CmdEndBarrier();
ToneMapRC rc = {};
rc.textureIndex = GetTextureIndexSRV(crp.GetReadRenderTarget());
@ -112,12 +111,11 @@ void ToneMap::DrawInverseToneMap()
CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight);
crp.SwapRenderTargets();
const TextureBarrier texBarriers[] =
{
TextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit),
TextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit)
};
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers, 0, NULL);
CmdBeginBarrier();
CmdTextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit);
CmdEndBarrier();
InverseToneMapRC rc = {};
rc.textureIndex = GetTextureIndexSRV(crp.GetReadRenderTarget());

View file

@ -119,17 +119,12 @@ void WorldTransp::Draw(const drawSceneViewCommand_t& cmd)
batchOldDepthHack = false;
batchDepthHack = false;
const TextureBarrier texBarriers[] =
{
TextureBarrier(crp.depthTexture, ResourceStates::DepthWriteBit),
TextureBarrier(crp.oitIndexTexture, ResourceStates::UnorderedAccessBit)
};
const BufferBarrier bufBarriers[] =
{
BufferBarrier(crp.oitFragmentBuffer, ResourceStates::UnorderedAccessBit),
BufferBarrier(crp.oitCounterBuffer, ResourceStates::UnorderedAccessBit)
};
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers, ARRAY_LEN(bufBarriers), bufBarriers);
CmdBeginBarrier();
CmdTextureBarrier(crp.depthTexture, ResourceStates::DepthWriteBit);
CmdTextureBarrier(crp.oitIndexTexture, ResourceStates::UnorderedAccessBit);
CmdBufferBarrier(crp.oitFragmentBuffer, ResourceStates::UnorderedAccessBit);
CmdBufferBarrier(crp.oitCounterBuffer, ResourceStates::CopyDestinationBit);
CmdEndBarrier();
GeoBuffers& db = crp.dynBuffers[GetFrameIndex()];
db.BeginUpload();
@ -139,24 +134,16 @@ void WorldTransp::Draw(const drawSceneViewCommand_t& cmd)
CmdBindIndexBuffer(db.indexBuffer.buffer, IndexType::UInt32, 0);
// reset the fragment counter
{
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);
}
CmdCopyBuffer(crp.oitCounterBuffer, crp.oitCounterStagingBuffer);
// clear the index texture
{
const uint32_t zeroes[4] = {};
CmdClearTextureUAV(crp.oitIndexTexture, 0, zeroes);
}
const uint32_t zeroes[4] = {};
CmdClearTextureUAV(crp.oitIndexTexture, 0, zeroes);
// really should just be just for the counter buffer and the index texture
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers, ARRAY_LEN(bufBarriers), bufBarriers);
CmdBeginBarrier();
CmdBufferBarrier(crp.oitCounterBuffer, ResourceStates::UnorderedAccessBit);
CmdTextureBarrier(crp.oitIndexTexture, ResourceStates::UnorderedAccessBit);
CmdEndBarrier();
const drawSurf_t* drawSurfs = cmd.drawSurfs;
const int opaqueSurfCount = cmd.numDrawSurfs - cmd.numTranspSurfs;

View file

@ -72,19 +72,15 @@ void TranspResolve::Draw(const drawSceneViewCommand_t& cmd)
CmdSetViewportAndScissor(0, 0, glConfig.vidWidth, glConfig.vidHeight);
crp.SwapRenderTargets();
const TextureBarrier texBarriers[] =
{
TextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit),
TextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit),
TextureBarrier(crp.oitIndexTexture, ResourceStates::UnorderedAccessBit),
TextureBarrier(crp.depthTexture, ResourceStates::PixelShaderAccessBit)
};
const BufferBarrier bufBarriers[] =
{
BufferBarrier(crp.oitFragmentBuffer, ResourceStates::UnorderedAccessBit),
BufferBarrier(srp.traceRenderBuffer, ResourceStates::UnorderedAccessBit)
};
CmdBarrier(ARRAY_LEN(texBarriers), texBarriers, ARRAY_LEN(bufBarriers), bufBarriers);
CmdBeginBarrier();
CmdTextureBarrier(crp.GetReadRenderTarget(), ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(crp.GetWriteRenderTarget(), ResourceStates::RenderTargetBit);
CmdTextureBarrier(crp.oitIndexTexture, ResourceStates::UnorderedAccessBit);
CmdTextureBarrier(crp.depthTexture, ResourceStates::PixelShaderAccessBit);
CmdBufferBarrier(crp.oitFragmentBuffer, ResourceStates::UnorderedAccessBit);
CmdBufferBarrier(srp.traceRenderBuffer, ResourceStates::UnorderedAccessBit);
CmdEndBarrier();
TranspResolveRC rc = {};
rc.fragmentBuffer = GetBufferIndexUAV(crp.oitFragmentBuffer);

View file

@ -238,9 +238,11 @@ void GRP::BeginFrame()
world.BeginFrame();
nuklear.BeginFrame();
CmdBeginBarrier();
CmdTextureBarrier(renderTarget, ResourceStates::RenderTargetBit);
CmdEndBarrier();
const float clearColor[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
const TextureBarrier barrier(renderTarget, ResourceStates::RenderTargetBit);
CmdBarrier(1, &barrier);
CmdClearColorTarget(renderTarget, clearColor);
// nothing is bound to the command list yet!

View file

@ -130,12 +130,10 @@ void PostProcess::Draw(const char* renderPassName, HTexture renderTarget)
{
SCOPED_RENDER_PASS(renderPassName, 0.125f, 0.125f, 0.5f);
const TextureBarrier barriers[2] =
{
TextureBarrier(grp.renderTarget, ResourceStates::PixelShaderAccessBit),
TextureBarrier(renderTarget, ResourceStates::RenderTargetBit)
};
CmdBarrier(ARRAY_LEN(barriers), barriers);
CmdBeginBarrier();
CmdTextureBarrier(grp.renderTarget, ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(renderTarget, ResourceStates::RenderTargetBit);
CmdEndBarrier();
float vsX = 1.0f; // vertex shader scale factors
float vsY = 1.0f;

View file

@ -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);
// can't clear targets if they're not in render target state
const TextureBarrier clearBarriers[2] =
{
TextureBarrier(edgeTexture, ResourceStates::RenderTargetBit),
TextureBarrier(blendTexture, ResourceStates::RenderTargetBit)
};
CmdBarrier(ARRAY_LEN(clearBarriers), clearBarriers);
CmdBeginBarrier();
CmdTextureBarrier(edgeTexture, ResourceStates::RenderTargetBit);
CmdTextureBarrier(blendTexture, ResourceStates::RenderTargetBit);
CmdEndBarrier();
CmdClearColorTarget(edgeTexture, vec4_zero);
CmdClearColorTarget(blendTexture, vec4_zero);
@ -347,18 +345,14 @@ void SMAA::Draw(const viewParms_t& parms)
CmdSetViewport(0, 0, glConfig.vidWidth, glConfig.vidHeight);
CmdSetScissor(parms.viewportX, parms.viewportY, parms.viewportWidth, parms.viewportHeight);
// tone map for higher quality AA
{
const TextureBarrier barriers[2] =
{
TextureBarrier(grp.renderTarget, ResourceStates::PixelShaderAccessBit),
TextureBarrier(inputTexture, ResourceStates::RenderTargetBit)
};
CmdBarrier(ARRAY_LEN(barriers), barriers);
CmdBeginBarrier();
CmdTextureBarrier(grp.renderTarget, ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(inputTexture, ResourceStates::RenderTargetBit);
CmdEndBarrier();
CmdBindRenderTargets(1, &inputTexture, NULL);
grp.post.ToneMap(); // RTCF_R8G8B8A8 is assumed
}
// tone map for higher quality AA
CmdBindRenderTargets(1, &inputTexture, NULL);
grp.post.ToneMap(); // RTCF_R8G8B8A8 is assumed
CmdBindRootSignature(rootSignature);
CmdBindDescriptorTable(rootSignature, descriptorTable);
@ -371,50 +365,40 @@ void SMAA::Draw(const viewParms_t& parms)
CmdSetRootConstants(rootSignature, ShaderStage::Vertex, &rc);
CmdSetRootConstants(rootSignature, ShaderStage::Pixel, &rc);
// run edge detection
{
const TextureBarrier barrier(inputTexture, ResourceStates::PixelShaderAccessBit);
CmdBarrier(1, &barrier);
CmdBeginBarrier();
CmdTextureBarrier(inputTexture, ResourceStates::PixelShaderAccessBit);
CmdEndBarrier();
CmdBindRenderTargets(1, &edgeTexture, &stencilTexture);
CmdBindPipeline(firstPassPipeline);
CmdDraw(3, 0);
}
// run edge detection
CmdBindRenderTargets(1, &edgeTexture, &stencilTexture);
CmdBindPipeline(firstPassPipeline);
CmdDraw(3, 0);
CmdBeginBarrier();
CmdTextureBarrier(edgeTexture, ResourceStates::PixelShaderAccessBit);
CmdEndBarrier();
// compute blend weights
{
const TextureBarrier barrier(edgeTexture, ResourceStates::PixelShaderAccessBit);
CmdBarrier(1, &barrier);
CmdBindRenderTargets(1, &blendTexture, &stencilTexture);
CmdBindPipeline(secondPassPipeline);
CmdDraw(3, 0);
CmdBindRenderTargets(1, &blendTexture, &stencilTexture);
CmdBindPipeline(secondPassPipeline);
CmdDraw(3, 0);
}
CmdBeginBarrier();
CmdTextureBarrier(blendTexture, ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(outputTexture, ResourceStates::RenderTargetBit);
CmdEndBarrier();
// blend pass
{
const TextureBarrier barriers[2] =
{
TextureBarrier(blendTexture, ResourceStates::PixelShaderAccessBit),
TextureBarrier(outputTexture, ResourceStates::RenderTargetBit)
};
CmdBarrier(ARRAY_LEN(barriers), barriers);
CmdBindRenderTargets(1, &outputTexture, NULL);
CmdBindPipeline(thirdPassPipeline);
CmdDraw(3, 0);
CmdBindRenderTargets(1, &outputTexture, NULL);
CmdBindPipeline(thirdPassPipeline);
CmdDraw(3, 0);
}
CmdBeginBarrier();
CmdTextureBarrier(outputTexture, ResourceStates::PixelShaderAccessBit);
CmdTextureBarrier(grp.renderTarget, ResourceStates::RenderTargetBit);
CmdEndBarrier();
// inverse tone map and write back to the main render target
{
const TextureBarrier barriers[2] =
{
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);
}
CmdBindRenderTargets(1, &grp.renderTarget, NULL);
grp.post.InverseToneMap(r_rtColorFormat->integer);
}

View file

@ -398,8 +398,9 @@ void World::Begin()
batchOldShadingRate = ShadingRate::SR_1x1;
batchShadingRate = ShadingRate::SR_1x1;
TextureBarrier tb(depthTexture, ResourceStates::DepthWriteBit);
CmdBarrier(1, &tb);
CmdBeginBarrier();
CmdTextureBarrier(depthTexture, ResourceStates::DepthWriteBit);
CmdEndBarrier();
}
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)
{
TextureBarrier barrier(depthTexture, ResourceStates::PixelShaderAccessBit);
CmdBarrier(1, &barrier);
CmdBeginBarrier();
CmdTextureBarrier(depthTexture, ResourceStates::PixelShaderAccessBit);
CmdEndBarrier();
CmdBindRenderTargets(1, &grp.renderTarget, NULL);
}
else if(type != BatchType::DepthFade && batchType == BatchType::DepthFade)
{
TextureBarrier barrier(depthTexture, ResourceStates::DepthWriteBit);
CmdBarrier(1, &barrier);
CmdBeginBarrier();
CmdTextureBarrier(depthTexture, ResourceStates::DepthWriteBit);
CmdEndBarrier();
CmdBindRenderTargets(1, &grp.renderTarget, &depthTexture);
}
@ -741,8 +744,9 @@ void World::DrawGUI()
}
#if 0
TextureBarrier tb(depthTexture, ResourceStates::DepthReadBit);
CmdBarrier(1, &tb);
CmdBeginBarrier();
CmdTextureBarrier(depthTexture, ResourceStates::DepthReadBit);
CmdEndBarrier();
if(ImGui::Begin("depth", NULL, ImGuiWindowFlags_AlwaysAutoResize))
{
ImGui::Image((ImTextureID)depthTextureIndex, ImVec2(640, 360));
@ -1038,8 +1042,9 @@ void World::DrawSceneView(const drawSceneViewCommand_t& cmd)
boundVertexBuffers = BufferFamily::Invalid;
boundIndexBuffer = BufferFamily::Invalid;
const TextureBarrier depthWriteBarrier(depthTexture, ResourceStates::DepthWriteBit);
CmdBarrier(1, &depthWriteBarrier);
CmdBeginBarrier();
CmdTextureBarrier(depthTexture, ResourceStates::DepthWriteBit);
CmdEndBarrier();
}
int entityNum;
@ -1215,8 +1220,10 @@ void World::DrawFog()
CmdBindIndexBuffer(boxIndexBuffer, IndexType::UInt32, 0);
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)
{

View file

@ -565,7 +565,7 @@ namespace RHI
uint32_t durationQueryCount;
};
struct Pix
struct PIX
{
typedef void(WINAPI* BeginEventOnCommandListPtr)(ID3D12GraphicsCommandList* commandList, UINT64 color, _In_ PCSTR formatString);
typedef void(WINAPI* EndEventOnCommandListPtr)(ID3D12GraphicsCommandList* commandList);
@ -608,6 +608,32 @@ namespace RHI
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
{
bool initialized;
@ -704,9 +730,17 @@ namespace RHI
StaticUnorderedArray<HBuffer, 64> buffersToTransition;
FrameQueries frameQueries[FrameCount];
ResolvedQueries resolvedQueries;
Pix pix;
PIX pix;
int64_t beforeInputSamplingUS;
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;
@ -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()
{
if(BeginTable("Handles", 3))
@ -3348,9 +3414,9 @@ namespace RHI
rhi.pix.module = LoadLibraryA("cnq3/WinPixEventRuntime.dll");
if(rhi.pix.module != NULL)
{
rhi.pix.BeginEventOnCommandList = (Pix::BeginEventOnCommandListPtr)GetProcAddress(rhi.pix.module, "PIXBeginEventOnCommandList");
rhi.pix.EndEventOnCommandList = (Pix::EndEventOnCommandListPtr)GetProcAddress(rhi.pix.module, "PIXEndEventOnCommandList");
rhi.pix.SetMarkerOnCommandList = (Pix::SetMarkerOnCommandListPtr)GetProcAddress(rhi.pix.module, "PIXSetMarkerOnCommandList");
rhi.pix.BeginEventOnCommandList = (PIX::BeginEventOnCommandListPtr)GetProcAddress(rhi.pix.module, "PIXBeginEventOnCommandList");
rhi.pix.EndEventOnCommandList = (PIX::EndEventOnCommandListPtr)GetProcAddress(rhi.pix.module, "PIXEndEventOnCommandList");
rhi.pix.SetMarkerOnCommandList = (PIX::SetMarkerOnCommandListPtr)GetProcAddress(rhi.pix.module, "PIXSetMarkerOnCommandList");
rhi.pix.canBeginAndEnd = rhi.pix.BeginEventOnCommandList != NULL && rhi.pix.EndEventOnCommandList != NULL;
}
@ -3542,10 +3608,7 @@ namespace RHI
rhi.commandList->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
const TextureBarrier barrier(rhi.renderTargets[rhi.swapChainBufferIndex], ResourceStates::RenderTargetBit);
CmdBarrier(1, &barrier);
static TextureBarrier textureBarriers[MAX_DRAWIMAGES];
static TextureBarrier textureBarriers[MAX_DRAWIMAGES + 1];
static BufferBarrier bufferBarriers[64];
for(uint32_t t = 0; t < rhi.texturesToTransition.count; ++t)
{
@ -3553,13 +3616,14 @@ namespace RHI
const Texture& texture = rhi.textures.Get(handle);
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)
{
const HBuffer handle = rhi.buffersToTransition[b];
const Buffer& buffer = rhi.buffers.Get(handle);
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.buffersToTransition.Clear();
@ -3577,8 +3641,9 @@ namespace RHI
CmdInsertDebugLabel("RHI::EndFrame", 0.8f, 0.8f, 0.8f);
const TextureBarrier barrier(rhi.renderTargets[rhi.swapChainBufferIndex], ResourceStates::PresentBit);
CmdBarrier(1, &barrier);
CmdBeginBarrier();
CmdTextureBarrier(rhi.renderTargets[rhi.swapChainBufferIndex], ResourceStates::PresentBit);
CmdEndBarrier();
CmdEndDurationQuery(rhi.frameDurationQueryIndex);
@ -4770,36 +4835,73 @@ namespace RHI
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(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];
Q_assert(buffCount + texCount <= ARRAY_LEN(barriers));
rhi.barrierCommandList = rhi.commandList;
rhi.textureBarrierCount = 0;
rhi.bufferBarrierCount = 0;
rhi.barrierOpen = true;
}
UINT barrierCount = 0;
for(uint32_t i = 0; i < texCount; ++i)
void CmdTextureBarrier(HTexture texture, ResourceStates::Flags newState)
{
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);
if(SetBarrier(texture.currentState, barriers[barrierCount], textures[i].newState, texture.texture))
{
barrierCount++;
}
TextureBarrier* const barrier = &rhi.textureBarriers[rhi.textureBarrierCount++];
barrier->texture = texture;
barrier->newState = newState;
}
for(uint32_t i = 0; i < buffCount; ++i)
else
{
Buffer& buffer = rhi.buffers.Get(buffers[i].buffer);
if(SetBarrier(buffer.currentState, barriers[barrierCount], buffers[i].newState, buffer.buffer))
{
barrierCount++;
}
ri.Error(ERR_FATAL, "Not enough texture barrier storage!\n");
}
}
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.commandList->ResourceBarrier(barrierCount, barriers);
}
rhi.barrierCommandList = NULL;
rhi.textureBarrierCount = 0;
rhi.bufferBarrierCount = 0;
rhi.barrierOpen = false;
}
void CmdClearColorTarget(HTexture texture, const vec4_t clearColor, const Rect* rect)

View file

@ -552,32 +552,6 @@ namespace RHI
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
{
// note that for our texture UAVs,
@ -747,7 +721,10 @@ namespace RHI
void CmdDispatch(uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ);
uint32_t CmdBeginDurationQuery();
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 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);

View file

@ -485,16 +485,16 @@ void SRP::EndFrame()
tr.tracedWorldShaderIndex = -1;
if(tr.traceWorldShader && tr.world != NULL)
{
CmdBeginBarrier();
CmdBufferBarrier(traceRenderBuffer, ResourceStates::CopySourceBit);
CmdEndBarrier();
// schedule a GPU -> CPU transfer
{
BufferBarrier barrier(traceRenderBuffer, ResourceStates::CopySourceBit);
CmdBarrier(0, NULL, 1, &barrier);
}
CmdCopyBuffer(traceReadbackBuffer, traceRenderBuffer);
{
BufferBarrier barrier(traceRenderBuffer, ResourceStates::UnorderedAccessBit);
CmdBarrier(0, NULL, 1, &barrier);
}
CmdBeginBarrier();
CmdBufferBarrier(traceRenderBuffer, ResourceStates::UnorderedAccessBit);
CmdEndBarrier();
// grab last frame's result
uint32_t* shaderIndices = (uint32_t*)MapBuffer(traceReadbackBuffer);

View file

@ -142,16 +142,6 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
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)
{
// this must happen after the BeginTempCommandList call because
@ -182,6 +172,11 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
StartConstants rc = {};
rc.gamma = r_mipGenGamma->value;
CmdBeginBarrier();
CmdTextureBarrier(textures[MipSlice::Float16_0], ResourceStates::UnorderedAccessBit);
CmdTextureBarrier(texture, ResourceStates::UnorderedAccessBit);
CmdEndBarrier();
if(!ddhi)
{
CmdBindRootSignature(stage.rootSignature);
@ -201,12 +196,6 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
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
if((image->flags & IMG_NOIMANIP) == 0 &&
r_intensity->value != 1.0f)
@ -221,6 +210,11 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
rc.srcMip = MipSlice::Float16_0;
rc.dstMip = MipSlice::Count + destMip;
CmdBeginBarrier();
CmdTextureBarrier(textures[MipSlice::Float16_0], ResourceStates::UnorderedAccessBit);
CmdTextureBarrier(texture, ResourceStates::UnorderedAccessBit);
CmdEndBarrier();
if(!ddhi)
{
CmdBindRootSignature(stage.rootSignature);
@ -237,7 +231,6 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
CmdBindDescriptorTable(stage.rootSignature, stage.descriptorTable);
CmdSetRootConstants(stage.rootSignature, ShaderStage::Compute, &rc);
}
CmdBarrier(ARRAY_LEN(tempBarriers), tempBarriers);
Dispatch(w, h);
}
@ -265,6 +258,11 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
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
rc.srcMip = MipSlice::Float16_0;
rc.dstMip = MipSlice::Float16_1;
@ -284,9 +282,13 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
{
CmdSetRootConstants(stage.rootSignature, ShaderStage::Compute, &rc);
}
CmdBarrier(ARRAY_LEN(tempBarriers), tempBarriers);
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
rc.srcMip = MipSlice::Float16_1;
rc.dstMip = MipSlice::Float16_0;
@ -306,7 +308,6 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
{
CmdSetRootConstants(stage.rootSignature, ShaderStage::Compute, &rc);
}
CmdBarrier(ARRAY_LEN(tempBarriers), tempBarriers);
Dispatch(w, h);
}
@ -322,6 +323,11 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
rc.srcMip = MipSlice::Float16_0;
rc.dstMip = MipSlice::Count + destMip;
CmdBeginBarrier();
CmdTextureBarrier(textures[MipSlice::Float16_0], ResourceStates::UnorderedAccessBit);
CmdTextureBarrier(texture, ResourceStates::UnorderedAccessBit);
CmdEndBarrier();
if(!ddhi)
{
CmdBindRootSignature(stage.rootSignature);
@ -338,7 +344,6 @@ void MipMapGenerator::GenerateMipMaps(HTexture texture)
CmdBindDescriptorTable(stage.rootSignature, stage.descriptorTable);
CmdSetRootConstants(stage.rootSignature, ShaderStage::Compute, &rc);
}
CmdBarrier(ARRAY_LEN(tempBarriers), tempBarriers);
Dispatch(w, h);
}
}

View file

@ -109,8 +109,9 @@ void UI::Begin(HTexture renderTarget)
renderPassIndex = srp.BeginRenderPass("UI", 0.0f, 0.85f, 1.0f);
const TextureBarrier tb(renderTarget, ResourceStates::RenderTargetBit);
CmdBarrier(1, &tb);
CmdBeginBarrier();
CmdTextureBarrier(renderTarget, ResourceStates::RenderTargetBit);
CmdEndBarrier();
CmdBindRenderTargets(1, &renderTarget, NULL);