Skip to content

Commit 4a20552

Browse files
Add DRAW_FLAG_INLINE_CONSTANTS_INTACT flag (#672)
1 parent d729b38 commit 4a20552

File tree

6 files changed

+26
-6
lines changed

6 files changed

+26
-6
lines changed

Graphics/GraphicsEngine/interface/DeviceContext.h

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,27 @@ DILIGENT_TYPED_ENUM(DRAW_FLAGS, Uint8)
213213
/// (see RootSignature::CommitRootViews). When `DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT` is set, root views are only bound
214214
/// by the first draw command that uses the PSO + SRB pair. The flag avoids setting the same GPU virtual addresses when
215215
/// they stay unchanged.
216-
DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT = 1u << 2u
216+
///
217+
/// \see DRAW_FLAG_INLINE_CONSTANTS_INTACT, DRAW_FLAG_DYNAMIC_BUFFERS_AND_INLINE_CONSTANTS_INTACT
218+
DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT = 1u << 2u,
219+
220+
/// Indicates that none of the inline constants used by the draw command
221+
/// have been modified by the CPU since the last command.
222+
///
223+
/// This flag should be used to improve performance when an application issues a
224+
/// series of draw commands that use the same pipeline state and shader resources and
225+
/// no inline constants are updated between the commands.
226+
///
227+
/// \see DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT, DRAW_FLAG_DYNAMIC_BUFFERS_AND_INLINE_CONSTANTS_INTACT
228+
DRAW_FLAG_INLINE_CONSTANTS_INTACT = 1u << 3u,
229+
230+
/// Indicates that neither the dynamic resource buffers nor the inline constants used by
231+
/// the draw command have been modified by the CPU since the previous command.
232+
///
233+
/// \see DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT, DRAW_FLAG_INLINE_CONSTANTS_INTACT
234+
DRAW_FLAG_DYNAMIC_BUFFERS_AND_INLINE_CONSTANTS_INTACT =
235+
DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT |
236+
DRAW_FLAG_INLINE_CONSTANTS_INTACT
217237
};
218238
DEFINE_FLAG_ENUM_OPERATORS(DRAW_FLAGS)
219239

Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ void DeviceContextD3D11Impl::PrepareForDraw(DRAW_FLAGS Flags)
672672
CommitD3D11VertexBuffers(m_pPipelineState);
673673
}
674674

675-
if (Uint32 BindSRBMask = m_BindInfo.GetCommitMask(Flags & DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT))
675+
if (Uint32 BindSRBMask = m_BindInfo.GetCommitMask(Flags & DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT, Flags & DRAW_FLAG_INLINE_CONSTANTS_INTACT))
676676
{
677677
BindShaderResources(BindSRBMask);
678678
}

Graphics/GraphicsEngineD3D12/src/DeviceContextD3D12Impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ void DeviceContextD3D12Impl::PrepareForDraw(GraphicsContext& GraphCtx, DRAW_FLAG
629629
#ifdef DILIGENT_DEVELOPMENT
630630
DvpValidateCommittedShaderResources(RootInfo);
631631
#endif
632-
if (Uint32 CommitSRBMask = RootInfo.GetCommitMask(Flags & DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT))
632+
if (Uint32 CommitSRBMask = RootInfo.GetCommitMask(Flags & DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT, Flags & DRAW_FLAG_INLINE_CONSTANTS_INTACT))
633633
{
634634
CommitRootTablesAndViews<false>(RootInfo, CommitSRBMask, GraphCtx);
635635
}

Graphics/GraphicsEngineOpenGL/src/DeviceContextGLImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ void DeviceContextGLImpl::PrepareForDraw(DRAW_FLAGS Flags, bool IsIndexed, GLenu
800800
// The program might have changed since the last SetPipelineState call if a shader was
801801
// created after the call (ShaderResourcesGL needs to bind a program to load uniforms).
802802
m_pPipelineState->CommitProgram(m_ContextState);
803-
if (Uint32 BindSRBMask = m_BindInfo.GetCommitMask(Flags & DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT))
803+
if (Uint32 BindSRBMask = m_BindInfo.GetCommitMask(Flags & DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT, Flags & DRAW_FLAG_INLINE_CONSTANTS_INTACT))
804804
{
805805
BindProgramResources(BindSRBMask);
806806
}

Graphics/GraphicsEngineVulkan/src/DeviceContextVkImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ void DeviceContextVkImpl::PrepareForDraw(DRAW_FLAGS Flags)
761761
// First time we must always bind descriptor sets with dynamic offsets as SRBs are stale.
762762
// If there are no dynamic buffers bound in the resource cache, for all subsequent
763763
// calls we do not need to bind the sets again.
764-
if (Uint32 CommitMask = BindInfo.GetCommitMask(Flags & DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT))
764+
if (Uint32 CommitMask = BindInfo.GetCommitMask(Flags & DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT, Flags & DRAW_FLAG_INLINE_CONSTANTS_INTACT))
765765
{
766766
CommitDescriptorSets(BindInfo, CommitMask);
767767
}

Graphics/GraphicsEngineWebGPU/src/DeviceContextWebGPUImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,7 @@ WGPURenderPassEncoder DeviceContextWebGPUImpl::PrepareForDraw(DRAW_FLAGS Flags)
20972097
m_EncoderState.SetUpToDate(WebGPUEncoderState::CMD_ENCODER_STATE_STENCIL_REF);
20982098
}
20992099

2100-
if (CommittedShaderResources::SRBMaskType CommitSRBMask = m_BindInfo.GetCommitMask(Flags & DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT))
2100+
if (CommittedShaderResources::SRBMaskType CommitSRBMask = m_BindInfo.GetCommitMask(Flags & DRAW_FLAG_DYNAMIC_RESOURCE_BUFFERS_INTACT, Flags & DRAW_FLAG_INLINE_CONSTANTS_INTACT))
21012101
CommitBindGroups(wgpuRenderCmdEncoder, CommitSRBMask);
21022102

21032103
return wgpuRenderCmdEncoder;

0 commit comments

Comments
 (0)