From 1303ae5da64c35a56768edecdf60d57f7a2fe628 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Fri, 30 Nov 2018 20:20:46 -0800 Subject: Added explicit state transition flags to SetRenderTargets method --- .../GraphicsEngine/include/DeviceContextBase.h | 5 ++-- Graphics/GraphicsEngine/interface/DeviceContext.h | 28 +++++++++++++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) (limited to 'Graphics/GraphicsEngine') diff --git a/Graphics/GraphicsEngine/include/DeviceContextBase.h b/Graphics/GraphicsEngine/include/DeviceContextBase.h index 293e438c..0bbdd843 100644 --- a/Graphics/GraphicsEngine/include/DeviceContextBase.h +++ b/Graphics/GraphicsEngine/include/DeviceContextBase.h @@ -107,7 +107,7 @@ public: /// Caches the render target and depth stencil views. Returns true if any view is different /// from the cached value and false otherwise. - inline bool SetRenderTargets( Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil, Uint32 Dummy = 0 ); + inline bool SetRenderTargets( Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil); /// Base implementation of IDeviceContext::UpdateBuffer(); validates input parameters. virtual void UpdateBuffer(IBuffer* pBuffer, Uint32 Offset, Uint32 Size, const PVoid pData)override = 0; @@ -462,7 +462,8 @@ inline void DeviceContextBase -inline bool DeviceContextBase :: SetRenderTargets( Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil, Uint32 Dummy ) +inline bool DeviceContextBase :: + SetRenderTargets( Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil ) { bool bBindRenderTargets = false; m_FramebufferWidth = 0; diff --git a/Graphics/GraphicsEngine/interface/DeviceContext.h b/Graphics/GraphicsEngine/interface/DeviceContext.h index 70088d2a..236d5e51 100644 --- a/Graphics/GraphicsEngine/interface/DeviceContext.h +++ b/Graphics/GraphicsEngine/interface/DeviceContext.h @@ -269,6 +269,31 @@ enum COMMIT_SHADER_RESOURCES_FLAGS : Uint8 }; DEFINE_FLAG_ENUM_OPERATORS(COMMIT_SHADER_RESOURCES_FLAGS) +/// Additional flags for IDeviceContext::SetRenderTargets() command that define +/// which resources need to be transitioned by the command. +enum SET_RENDER_TARGETS_FLAGS +{ + /// Perform no state transitions + SET_RENDER_TARGETS_FLAG_NONE = 0x00, + + /// Transition color targets to Diligent::RESOURCE_STATE_RENDER_TARGET state (see Diligent::RESOURCE_STATE). + /// Textures in unknown state will not be transitioned. + SET_RENDER_TARGETS_FLAG_TRANSITION_COLOR = 0x01, + + /// Transition depth buffer to Diligent::RESOURCE_STATE_DEPTH_WRITE state (see Diligent::RESOURCE_STATE). + /// If the texture is in unknown state, the flag will have no effect. + SET_RENDER_TARGETS_FLAG_TRANSITION_DEPTH = 0x02, + + /// Transition all color targets and depth buffer + SET_RENDER_TARGETS_FLAG_TRANSITION_ALL = (SET_RENDER_TARGETS_FLAG_TRANSITION_COLOR | SET_RENDER_TARGETS_FLAG_TRANSITION_DEPTH), + + /// Verify the state of color/depth targets not being transitioned. This flag + /// only has effect in debug and development builds. No validation is performed + /// in release build and the flag is ignored. + SET_RENDER_TARGETS_FLAG_VERIFY_STATES = 0x04 +}; +DEFINE_FLAG_ENUM_OPERATORS(SET_RENDER_TARGETS_FLAGS) + /// Describes the viewport. @@ -516,6 +541,7 @@ public: /// \param [in] pDepthStencil - Pointer to the ITextureView that represents the depth stencil to /// bind to the device. The view type must be /// Diligent::TEXTURE_VIEW_DEPTH_STENCIL. + /// \param [in] Flags - Flags defining required resource transitions. /// \remarks /// The device context will keep strong references to all bound render target /// and depth-stencil views. Thus these views (and consequently referenced textures) @@ -525,7 +551,7 @@ public: /// following call: /// /// pContext->SetRenderTargets(0, nullptr, nullptr); - virtual void SetRenderTargets(Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil) = 0; + virtual void SetRenderTargets(Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil, SET_RENDER_TARGETS_FLAGS Flags) = 0; /// Executes a draw command -- cgit v1.2.3