29 #include "DeviceContextD3D11.h" 30 #include "DeviceContextBase.h" 31 #include "ShaderD3D11Impl.h" 34 # define VERIFY_CONTEXT_BINDINGS 47 virtual void QueryInterface(
const Diligent::INTERFACE_ID &IID, IObject **ppInterface )
override final;
57 virtual void SetBlendFactors(
const float* pBlendFactors =
nullptr)
override final;
59 virtual void SetVertexBuffers( Uint32 StartSlot, Uint32 NumBuffersSet,
IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags )
override final;
65 virtual void SetViewports( Uint32 NumViewports,
const Viewport *pViewports, Uint32 RTWidth, Uint32 RTHeight )
override final;
67 virtual void SetScissorRects( Uint32 NumRects,
const Rect *pRects, Uint32 RTWidth, Uint32 RTHeight )
override final;
79 virtual void Flush()
override final;
87 void CommitRenderTargets();
103 void CommitD3D11IndexBuffer(
VALUE_TYPE IndexType);
109 template<
typename TD3D11ResourceViewType,
110 typename TSetD3D11View,
112 void UnbindResourceView(TD3D11ResourceViewType CommittedD3D11ViewsArr[][NumSlots],
113 ID3D11Resource* CommittedD3D11ResourcesArr[][NumSlots],
114 Uint8 NumCommittedResourcesArr[],
116 ID3D11Resource *pd3d11ResToUndind,
117 TSetD3D11View SetD3D11ViewMethods[]);
122 void UnbindTextureFromInput(
TextureBaseD3D11 *pTexture, ID3D11Resource *pd3d11Resource);
128 void UnbindBufferFromInput(
BufferD3D11Impl *pBuffer, ID3D11Resource *pd3d11Buffer);
133 void UnbindResourceFromUAV(
IDeviceObject *pResource, ID3D11Resource *pd3d11Resource);
141 template<
bool TransitionResources,
142 bool CommitResources>
145 void ClearStateCache();
147 CComPtr<ID3D11DeviceContext> m_pd3d11DeviceContext;
152 ID3D11Buffer* m_CommittedD3D11CBs [
NumShaderTypes][D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT];
157 ID3D11ShaderResourceView* m_CommittedD3D11SRVs [
NumShaderTypes][D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
162 ID3D11SamplerState* m_CommittedD3D11Samplers[
NumShaderTypes][D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT];
167 ID3D11UnorderedAccessView* m_CommittedD3D11UAVs [
NumShaderTypes][D3D11_PS_CS_UAV_REGISTER_COUNT];
172 ID3D11Resource* m_CommittedD3D11SRVResources [
NumShaderTypes][D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
177 ID3D11Resource* m_CommittedD3D11UAVResources [
NumShaderTypes][D3D11_PS_CS_UAV_REGISTER_COUNT];
194 UINT m_NumCommittedD3D11VBs;
196 bool m_bCommittedD3D11VBsUpToDate =
false;
201 ID3D11InputLayout *m_CommittedD3D11InputLayout =
nullptr;
205 CComPtr<ID3D11Buffer> m_CommittedD3D11IndexBuffer;
209 Uint32 m_CommittedD3D11IndexDataStartOffset;
211 bool m_bCommittedD3D11IBUpToDate =
false;
213 D3D11_PRIMITIVE_TOPOLOGY m_CommittedD3D11PrimTopology = D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED;
221 FixedBlockMemoryAllocator m_CmdListAllocator;
223 #ifdef VERIFY_CONTEXT_BINDINGS 224 void dbgVerifyRenderTargetFormats();
228 template<UINT MaxResources,
typename TD3D11ResourceType,
typename TGetD3D11ResourcesType>
229 void dbgVerifyCommittedResources(TD3D11ResourceType CommittedD3D11ResourcesArr[][MaxResources],
230 Uint8 NumCommittedResourcesArr[],
231 TGetD3D11ResourcesType GetD3D11ResMethods[],
232 const Char *ResourceName,
236 template<UINT MaxResources,
typename TD3D11ViewType>
237 void dbgVerifyViewConsistency(TD3D11ViewType CommittedD3D11ViewArr[][MaxResources],
238 ID3D11Resource* CommittedD3D11ResourcesArr[][MaxResources],
239 Uint8 NumCommittedResourcesArr[],
240 const Char *ResourceName,
262 void dbgVerifyCommittedIndexBuffer();
267 void dbgVerifyCommittedVertexBuffers();
272 void dbgVerifyCommittedShaders();
275 #define dbgVerifyRenderTargetFormats(...) 276 #define dbgVerifyCommittedSRVs(...) 277 #define dbgVerifyCommittedUAVs(...) 278 #define dbgVerifyCommittedSamplers(...) 279 #define dbgVerifyCommittedCBs(...) 280 #define dbgVerifyCommittedIndexBuffer(...) 281 #define dbgVerifyCommittedVertexBuffers(...) 282 #define dbgVerifyCommittedShaders(...) static constexpr int NumShaderTypes
Number of different shader types (Vertex, Pixel, Geometry, Domain, Hull, Compute) ...
Definition: DeviceContextD3D11Impl.h:98
static constexpr Uint32 MaxBufferSlots
Maximum number of input buffer slots. D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT == 32...
Definition: Constants.h:33
Render device interface.
Definition: RenderDevice.h:55
Base interface for all objects created by the render device Diligent::IRenderDevice.
Definition: DeviceObject.h:40
PRIMITIVE_TOPOLOGY
Input primitive topology.
Definition: DeviceContext.h:56
Base implementation of the Diligent::ITextureD3D11 interface.
Definition: TextureBaseD3D11.h:50
virtual void SetViewports(Uint32 NumViewports, const Viewport *pViewports, Uint32 RTWidth, Uint32 RTHeight) override final
Sets an array of viewports.
Definition: DeviceContextD3D11Impl.cpp:864
virtual void Flush() override final
Flushes the command buffer.
Definition: DeviceContextD3D11Impl.cpp:847
virtual void SetVertexBuffers(Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pStrides, Uint32 *pOffsets, Uint32 Flags) override final
Base implementation of IDeviceContext::SetVertexBuffers(); validates parameters and caches references...
Definition: DeviceContextD3D11Impl.cpp:852
ID3D11DeviceContext * GetD3D11DeviceContext()
Returns a pointer to the ID3D11DeviceContext interface of the internal Direct3D11 object...
Definition: DeviceContextD3D11Impl.h:85
virtual void ClearDepthStencil(ITextureView *pView, Uint32 ClearFlags, float fDepth, Uint8 Stencil) override final
Clears a depth-stencil view.
Definition: DeviceContextD3D11Impl.cpp:779
SHADER_TYPE
Describes the shader type.
Definition: Shader.h:46
virtual void Draw(DrawAttribs &DrawAttribs) override final
Executes a draw command.
Definition: DeviceContextD3D11Impl.cpp:660
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34
Base implementation of the device context.
Definition: DeviceContextBase.h:68
Describes the viewport.
Definition: DeviceContext.h:376
virtual void SetBlendFactors(const float *pBlendFactors=nullptr) override final
Definition: DeviceContextD3D11Impl.cpp:548
Shader resource binding interface.
Definition: ShaderResourceBinding.h:40
void FinishCommandList(class ICommandList **ppCommandList) override final
Finishes recording commands and generates a command list.
Definition: DeviceContextD3D11Impl.cpp:1243
Undefined topology.
Definition: DeviceContext.h:59
virtual void DispatchCompute(const DispatchComputeAttribs &DispatchAttrs) override final
Executes a dispatch compute command.
Definition: DeviceContextD3D11Impl.cpp:746
Describes dispatch command arguments.
Definition: DeviceContext.h:312
virtual void SetIndexBuffer(IBuffer *pIndexBuffer, Uint32 ByteOffset) override final
Base implementation of IDeviceContext::SetIndexBuffer(); caches the strong reference to the index buf...
Definition: DeviceContextD3D11Impl.cpp:858
virtual void SetScissorRects(Uint32 NumRects, const Rect *pRects, Uint32 RTWidth, Uint32 RTHeight) override final
Sets active scissor rects.
Definition: DeviceContextD3D11Impl.cpp:888
Buffer interface.
Definition: Buffer.h:200
Implementation of the Diligent::IPipelineStateD3D11 interface.
Definition: PipelineStateD3D11Impl.h:40
virtual void SetRenderTargets(Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil) override final
Binds one or more render targets and the depth-stencil buffer to the pipeline. It also sets the viewp...
Definition: DeviceContextD3D11Impl.cpp:1158
virtual void ExecuteCommandList(class ICommandList *pCommandList) override final
Executes recorded commands in a command list.
Definition: DeviceContextD3D11Impl.cpp:1275
Texture view interface.
Definition: TextureView.h:163
VALUE_TYPE
Value type.
Definition: GraphicsTypes.h:39
Command list interface.
Definition: CommandList.h:42
Unknown shader type.
Definition: Shader.h:48
void ReleaseCommittedShaderResources()
Clears the committed shader resource cache. This function is called once per frame (before present) t...
Definition: DeviceContextD3D11Impl.cpp:1214
Definition: PipelineState.h:209
Defines the draw command attributes.
Definition: DeviceContext.h:212
virtual void SetStencilRef(Uint32 StencilRef) override final
Sets the stencil reference value.
Definition: DeviceContextD3D11Impl.cpp:538
Describes the rectangle.
Definition: DeviceContext.h:420
virtual void InvalidateState() override final
Invalidates the cached context state.
Definition: DeviceContextD3D11Impl.cpp:1351
virtual void ClearRenderTarget(ITextureView *pView, const float *RGBA) override final
Clears a render target view.
Definition: DeviceContextD3D11Impl.cpp:812
Implementation of the Diligent::IBufferD3D11 interface.
Definition: BufferD3D11Impl.h:51
virtual void CommitShaderResources(IShaderResourceBinding *pShaderResourceBinding, Uint32 Flags) override final
Commits shader resources to the device context.
Definition: DeviceContextD3D11Impl.cpp:527
virtual void QueryInterface(const Diligent::INTERFACE_ID &IID, IObject **ppInterface) override final
Queries the specific interface, see IObject::QueryInterface() for details.
virtual void TransitionShaderResources(IPipelineState *pPipelineState, IShaderResourceBinding *pShaderResourceBinding) override final
Transitions shader resources to the require states.
Definition: DeviceContextD3D11Impl.cpp:522
Implementation of the Diligent::IDeviceContextD3D11 interface.
Definition: DeviceContextD3D11Impl.h:41
Attributes of the Direct3D11-based engine implementation.
Definition: EngineD3D11Attribs.h:51
virtual void SetPipelineState(IPipelineState *pPipelineState) override final
Base implementation of IDeviceContext::SetPipelineState(); caches references to the pipeline state ob...
Definition: DeviceContextD3D11Impl.cpp:73