Diligent Engine  v.2.4.g
DeviceContextBase.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2021 Diligent Graphics LLC
3  * Copyright 2015-2019 Egor Yusov
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * In no event and under no legal theory, whether in tort (including negligence),
18  * contract, or otherwise, unless required by applicable law (such as deliberate
19  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
20  * liable for any damages, including any direct, indirect, special, incidental,
21  * or consequential damages of any character arising as a result of this License or
22  * out of the use or inability to use the software (including but not limited to damages
23  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
24  * all other commercial damages or losses), even if such Contributor has been advised
25  * of the possibility of such damages.
26  */
27 
28 #pragma once
29 
32 
33 #include <unordered_map>
34 #include <array>
35 #include <functional>
36 
37 #include "DeviceContext.h"
38 #include "DeviceObjectBase.hpp"
39 #include "ResourceMapping.h"
40 #include "Sampler.h"
41 #include "ObjectBase.hpp"
42 #include "DebugUtilities.hpp"
43 #include "ValidatedCast.hpp"
44 #include "GraphicsAccessories.hpp"
45 #include "TextureBase.hpp"
46 
47 namespace Diligent
48 {
49 
50 // clang-format off
51 bool VerifyDrawAttribs (const DrawAttribs& Attribs);
52 bool VerifyDrawIndexedAttribs (const DrawIndexedAttribs& Attribs);
53 bool VerifyDrawIndirectAttribs (const DrawIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer);
54 bool VerifyDrawIndexedIndirectAttribs(const DrawIndexedIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer);
55 
57 bool VerifyDispatchComputeIndirectAttribs(const DispatchComputeIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer);
58 // clang-format on
59 
60 bool VerifyDrawMeshAttribs(Uint32 MaxDrawMeshTasksCount, const DrawMeshAttribs& Attribs);
61 bool VerifyDrawMeshIndirectAttribs(const DrawMeshIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer);
62 bool VerifyDrawMeshIndirectCountAttribs(const DrawMeshIndirectCountAttribs& Attribs, const IBuffer* pAttribsBuffer, const IBuffer* pCountBuff, Uint32 IndirectCmdStride);
63 
65  const TextureDesc& SrcTexDesc,
66  const TextureDesc& DstTexDesc);
67 
69 bool VerifyStateTransitionDesc(const IRenderDevice* pDevice, const StateTransitionDesc& Barrier);
70 
71 bool VerifyBuildBLASAttribs(const BuildBLASAttribs& Attribs);
72 bool VerifyBuildTLASAttribs(const BuildTLASAttribs& Attribs);
73 bool VerifyCopyBLASAttribs(const IRenderDevice* pDevice, const CopyBLASAttribs& Attribs);
74 bool VerifyCopyTLASAttribs(const CopyTLASAttribs& Attribs);
75 bool VerifyWriteBLASCompactedSizeAttribs(const IRenderDevice* pDevice, const WriteBLASCompactedSizeAttribs& Attribs);
76 bool VerifyWriteTLASCompactedSizeAttribs(const IRenderDevice* pDevice, const WriteTLASCompactedSizeAttribs& Attribs);
77 bool VerifyTraceRaysAttribs(const TraceRaysAttribs& Attribs);
78 bool VerifyTraceRaysIndirectAttribs(const IRenderDevice* pDevice,
79  const TraceRaysIndirectAttribs& Attribs,
80  const IBuffer* pAttribsBuffer,
81  Uint32 SBTSize);
82 
83 
84 
86 template <typename BufferImplType>
88 {
90 
93 
96 };
97 
99 
106 template <typename EngineImplTraits>
107 class DeviceContextBase : public ObjectBase<typename EngineImplTraits::DeviceContextInterface>
108 {
109 public:
110  using BaseInterface = typename EngineImplTraits::DeviceContextInterface;
112  using DeviceImplType = typename EngineImplTraits::RenderDeviceImplType;
113  using BufferImplType = typename EngineImplTraits::BufferImplType;
114  using TextureImplType = typename EngineImplTraits::TextureImplType;
115  using PipelineStateImplType = typename EngineImplTraits::PipelineStateImplType;
116  using ShaderResourceBindingImplType = typename EngineImplTraits::ShaderResourceBindingImplType;
117  using TextureViewImplType = typename EngineImplTraits::TextureViewImplType;
118  using QueryImplType = typename EngineImplTraits::QueryImplType;
119  using FramebufferImplType = typename EngineImplTraits::FramebufferImplType;
120  using RenderPassImplType = typename EngineImplTraits::RenderPassImplType;
121  using BottomLevelASType = typename EngineImplTraits::BottomLevelASImplType;
122  using TopLevelASType = typename EngineImplTraits::TopLevelASImplType;
123  using ShaderBindingTableImplType = typename EngineImplTraits::ShaderBindingTableImplType;
124  using ShaderResourceCacheImplType = typename EngineImplTraits::ShaderResourceCacheImplType;
125  using PipelineResourceSignatureImplType = typename EngineImplTraits::PipelineResourceSignatureImplType;
126 
130  DeviceContextBase(IReferenceCounters* pRefCounters, DeviceImplType* pRenderDevice, bool bIsDeferred) :
131  // clang-format off
132  TObjectBase {pRefCounters },
133  m_pDevice {pRenderDevice},
134  m_bIsDeferred{bIsDeferred }
135  // clang-format on
136  {
137  }
138 
140  {
141  }
142 
144 
145 
146  inline virtual void DILIGENT_CALL_TYPE SetVertexBuffers(Uint32 StartSlot,
148  Uint32 NumBuffersSet,
149  IBuffer** ppBuffers,
150  Uint32* pOffsets,
151  RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
152  SET_VERTEX_BUFFERS_FLAGS Flags) override = 0;
153 
154  inline virtual void DILIGENT_CALL_TYPE InvalidateState() override = 0;
155 
157  inline void CommitShaderResources(IShaderResourceBinding* pShaderResourceBinding,
158  RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
159  int);
160 
162  inline virtual void DILIGENT_CALL_TYPE SetIndexBuffer(IBuffer* pIndexBuffer,
163  Uint32 ByteOffset,
164  RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override = 0;
165 
167  inline void SetViewports(Uint32 NumViewports, const Viewport* pViewports, Uint32& RTWidth, Uint32& RTHeight);
168 
170  inline void SetScissorRects(Uint32 NumRects, const Rect* pRects, Uint32& RTWidth, Uint32& RTHeight);
171 
172  virtual void DILIGENT_CALL_TYPE BeginRenderPass(const BeginRenderPassAttribs& Attribs) override = 0;
173 
174  virtual void DILIGENT_CALL_TYPE NextSubpass() override = 0;
175 
176  virtual void DILIGENT_CALL_TYPE EndRenderPass() override = 0;
177 
179  virtual void DILIGENT_CALL_TYPE UpdateBuffer(IBuffer* pBuffer,
180  Uint32 Offset,
181  Uint32 Size,
182  const void* pData,
183  RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override = 0;
184 
186  virtual void DILIGENT_CALL_TYPE CopyBuffer(IBuffer* pSrcBuffer,
187  Uint32 SrcOffset,
188  RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
189  IBuffer* pDstBuffer,
190  Uint32 DstOffset,
191  Uint32 Size,
192  RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode) override = 0;
193 
195  virtual void DILIGENT_CALL_TYPE MapBuffer(IBuffer* pBuffer,
196  MAP_TYPE MapType,
197  MAP_FLAGS MapFlags,
198  PVoid& pMappedData) override = 0;
199 
201  virtual void DILIGENT_CALL_TYPE UnmapBuffer(IBuffer* pBuffer, MAP_TYPE MapType) override = 0;
202 
204  virtual void DILIGENT_CALL_TYPE UpdateTexture(ITexture* pTexture,
205  Uint32 MipLevel,
206  Uint32 Slice,
207  const Box& DstBox,
208  const TextureSubResData& SubresData,
209  RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
210  RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode) override = 0;
211 
213  virtual void DILIGENT_CALL_TYPE CopyTexture(const CopyTextureAttribs& CopyAttribs) override = 0;
214 
216  virtual void DILIGENT_CALL_TYPE MapTextureSubresource(ITexture* pTexture,
217  Uint32 MipLevel,
218  Uint32 ArraySlice,
219  MAP_TYPE MapType,
220  MAP_FLAGS MapFlags,
221  const Box* pMapRegion,
222  MappedTextureSubresource& MappedData) override = 0;
223 
225  virtual void DILIGENT_CALL_TYPE UnmapTextureSubresource(ITexture* pTexture,
226  Uint32 MipLevel,
227  Uint32 ArraySlice) override = 0;
228 
229  virtual void DILIGENT_CALL_TYPE GenerateMips(ITextureView* pTexView) override = 0;
230 
231  virtual void DILIGENT_CALL_TYPE ResolveTextureSubresource(ITexture* pSrcTexture,
232  ITexture* pDstTexture,
233  const ResolveTextureSubresourceAttribs& ResolveAttribs) override = 0;
234 
235  virtual Uint64 DILIGENT_CALL_TYPE GetFrameNumber() const override final
236  {
237  return m_FrameNumber;
238  }
239 
241  inline void GetPipelineState(IPipelineState** ppPSO, float* BlendFactors, Uint32& StencilRef);
242 
244  inline void GetRenderTargets(Uint32& NumRenderTargets, ITextureView** ppRTVs, ITextureView** ppDSV);
245 
247  inline void GetViewports(Uint32& NumViewports, Viewport* pViewports);
248 
251 
252  virtual void ResetRenderTargets();
253 
254  bool IsDeferred() const { return m_bIsDeferred; }
255 
258  bool UnbindTextureFromFramebuffer(TextureImplType* pTexture, bool bShowMessage);
259 
260  bool HasActiveRenderPass() const { return m_pActiveRenderPass != nullptr; }
261 
262 protected:
265  {
266  // Pointers to shader resource caches for each signature
267  std::array<ShaderResourceCacheImplType*, MAX_RESOURCE_SIGNATURES> ResourceCaches = {};
268 
269 #ifdef DILIGENT_DEVELOPMENT
270  // SRB array for each resource signature, corresponding to ResourceCaches
271  std::array<RefCntWeakPtr<ShaderResourceBindingImplType>, MAX_RESOURCE_SIGNATURES> SRBs;
272 
273  // Indicates if the resources have been validated since they were committed
274  bool ResourcesValidated = false;
275 #endif
276 
278  static_assert(sizeof(SRBMaskType) * 8 >= MAX_RESOURCE_SIGNATURES, "Not enought space to store MAX_RESOURCE_SIGNATURES bits");
279 
280  SRBMaskType ActiveSRBMask = 0; // Indicates which SRBs are active in current PSO
281  SRBMaskType StaleSRBMask = 0; // Indicates stale SRBs that have not been committed yet
282 
284  {
285  VERIFY_EXPR(Index < MAX_RESOURCE_SIGNATURES);
286  ResourceCaches[Index] = pSRB != nullptr ? &pSRB->GetResourceCache() : nullptr;
287 
288  const auto SRBBit = static_cast<SRBMaskType>(1u << Index);
289  if (ResourceCaches[Index] != nullptr)
290  StaleSRBMask |= SRBBit;
291  else
292  StaleSRBMask &= ~SRBBit;
293 
294 #ifdef DILIGENT_DEVELOPMENT
295  SRBs[Index] = pSRB;
296  if (pSRB != nullptr)
297  ResourcesValidated = false;
298 #endif
299  }
300 
302  {
303  StaleSRBMask = 0xFFu;
304  }
305  };
306 
309  inline bool SetRenderTargets(Uint32 NumRenderTargets, ITextureView* ppRenderTargets[], ITextureView* pDepthStencil);
310 
312  inline bool SetSubpassRenderTargets();
313 
314  inline bool SetBlendFactors(const float* BlendFactors, int Dummy);
315 
316  inline bool SetStencilRef(Uint32 StencilRef, int Dummy);
317 
318  inline void SetPipelineState(PipelineStateImplType* pPipelineState, int /*Dummy*/);
319 
321  inline void ClearStateCache();
322 
325 
328 
330  void UpdateAttachmentStates(Uint32 SubpassIndex);
331 
332  void ClearDepthStencil(ITextureView* pView);
333 
334  void ClearRenderTarget(ITextureView* pView);
335 
336  void BeginQuery(IQuery* pQuery, int);
337 
338  void EndQuery(IQuery* pQuery, int);
339 
340  void EndFrame()
341  {
342  ++m_FrameNumber;
343  }
344 
345  void PrepareCommittedResources(CommittedShaderResources& Resources, Uint32& DvpCompatibleSRBCount);
346 
347 #ifdef DILIGENT_DEVELOPMENT
348  // clang-format off
349  void DvpVerifyDrawArguments (const DrawAttribs& Attribs) const;
350  void DvpVerifyDrawIndexedArguments (const DrawIndexedAttribs& Attribs) const;
351  void DvpVerifyDrawMeshArguments (const DrawMeshAttribs& Attribs) const;
352  void DvpVerifyDrawIndirectArguments (const DrawIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer) const;
353  void DvpVerifyDrawIndexedIndirectArguments (const DrawIndexedIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer) const;
354  void DvpVerifyDrawMeshIndirectArguments (const DrawMeshIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer) const;
355  void DvpVerifyDrawMeshIndirectCountArguments(const DrawMeshIndirectCountAttribs& Attribs, const IBuffer* pAttribsBuffer, const IBuffer* pCountBuff) const;
356 
357  void DvpVerifyDispatchArguments (const DispatchComputeAttribs& Attribs) const;
358  void DvpVerifyDispatchIndirectArguments(const DispatchComputeIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer) const;
359 
360  void DvpVerifyRenderTargets() const;
361  void DvpVerifyStateTransitionDesc(const StateTransitionDesc& Barrier) const;
362  void DvpVerifyTextureState(const TextureImplType& Texture, RESOURCE_STATE RequiredState, const char* OperationName) const;
363  void DvpVerifyBufferState (const BufferImplType& Buffer, RESOURCE_STATE RequiredState, const char* OperationName) const;
364  void DvpVerifyBLASState (const BottomLevelASType& BLAS, RESOURCE_STATE RequiredState, const char* OperationName) const;
365  void DvpVerifyTLASState (const TopLevelASType& TLAS, RESOURCE_STATE RequiredState, const char* OperationName) const;
366 
367  // Verifies compatibility between current PSO and SRBs
368  void DvpVerifySRBCompatibility(
369  CommittedShaderResources& Resources,
370  std::function<PipelineResourceSignatureImplType*(Uint32)> CustomGetSignature = nullptr) const;
371 #else
372  bool DvpVerifyDrawArguments (const DrawAttribs& Attribs)const {return true;}
373  bool DvpVerifyDrawIndexedArguments (const DrawIndexedAttribs& Attribs)const {return true;}
374  bool DvpVerifyDrawMeshArguments (const DrawMeshAttribs& Attribs)const {return true;}
375  bool DvpVerifyDrawIndirectArguments (const DrawIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer)const {return true;}
376  bool DvpVerifyDrawIndexedIndirectArguments (const DrawIndexedIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer)const {return true;}
377  bool DvpVerifyDrawMeshIndirectArguments (const DrawMeshIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer)const {return true;}
378  bool DvpVerifyDrawMeshIndirectCountArguments(const DrawMeshIndirectCountAttribs& Attribs, const IBuffer* pAttribsBuffer, const IBuffer* pCountBuff) const {return true;}
379 
380  bool DvpVerifyDispatchArguments (const DispatchComputeAttribs& Attribs)const {return true;}
381  bool DvpVerifyDispatchIndirectArguments(const DispatchComputeIndirectAttribs& Attribs, const IBuffer* pAttribsBuffer)const {return true;}
382 
383  bool DvpVerifyRenderTargets()const {return true;}
384  bool DvpVerifyStateTransitionDesc(const StateTransitionDesc& Barrier)const {return true;}
385  bool DvpVerifyTextureState(const TextureImplType& Texture, RESOURCE_STATE RequiredState, const char* OperationName)const {return true;}
386  bool DvpVerifyBufferState (const BufferImplType& Buffer, RESOURCE_STATE RequiredState, const char* OperationName)const {return true;}
387  bool DvpVerifyBLASState (const BottomLevelASType& BLAS, RESOURCE_STATE RequiredState, const char* OperationName)const {return true;}
388  bool DvpVerifyTLASState (const TopLevelASType& TLAS, RESOURCE_STATE RequiredState, const char* OperationName)const {return true;}
389  // clang-format on
390 #endif
391 
392  void BuildBLAS(const BuildBLASAttribs& Attribs, int) const;
393  void BuildTLAS(const BuildTLASAttribs& Attribs, int) const;
394  void CopyBLAS(const CopyBLASAttribs& Attribs, int) const;
395  void CopyTLAS(const CopyTLASAttribs& Attribs, int) const;
396  void WriteBLASCompactedSize(const WriteBLASCompactedSizeAttribs& Attribs, int) const;
397  void WriteTLASCompactedSize(const WriteTLASCompactedSizeAttribs& Attribs, int) const;
398  void TraceRays(const TraceRaysAttribs& Attribs, int) const;
399  void TraceRaysIndirect(const TraceRaysIndirectAttribs& Attribs, IBuffer* pAttribsBuffer, int) const;
400  void UpdateSBT(IShaderBindingTable* pSBT, const UpdateIndirectRTBufferAttribs* pUpdateIndirectBufferAttribs, int) const;
401 
402  static constexpr Uint32 DrawMeshIndirectCommandStride = sizeof(uint) * 3; // D3D12: 12 bytes (x, y, z dimension)
403  // Vulkan: 8 bytes (task count, first task)
404  static constexpr Uint32 TraceRaysIndirectCommandSBTSize = 88; // D3D12: 88 bytes, size of SBT offsets
405  // Vulkan: 0 bytes, SBT offsets placed directly into function call
406  static constexpr Uint32 TraceRaysIndirectCommandSize = 104; // SBT (88 bytes) + Dimension (3*4 bytes) aligned to 8 bytes
407 
410 
413 
416 
422 
426 
429 
432 
434  Float32 m_BlendFactors[4] = {-1, -1, -1, -1};
435 
437  Viewport m_Viewports[MAX_VIEWPORTS];
440 
442  Rect m_ScissorRects[MAX_VIEWPORTS];
445 
459 
463 
466 
469 
472 
475 
476  const bool m_bIsDeferred = false;
477 
479 
480 #ifdef DILIGENT_DEBUG
481  // std::unordered_map is unbelievably slow. Keeping track of mapped buffers
482  // in release builds is not feasible
483  struct DbgMappedBufferInfo
484  {
485  MAP_TYPE MapType;
486  };
487  std::unordered_map<IBuffer*, DbgMappedBufferInfo> m_DbgMappedBuffers;
488 #endif
489 };
490 
491 
492 template <typename ImplementationTraits>
494  Uint32 StartSlot,
495  Uint32 NumBuffersSet,
496  IBuffer** ppBuffers,
497  Uint32* pOffsets,
498  RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
500 {
501  DEV_CHECK_ERR(StartSlot < MAX_BUFFER_SLOTS, "Start vertex buffer slot ", StartSlot, " is out of allowed range [0, ", MAX_BUFFER_SLOTS - 1, "].");
502 
503  DEV_CHECK_ERR(StartSlot + NumBuffersSet <= MAX_BUFFER_SLOTS,
504  "The range of vertex buffer slots being set [", StartSlot, ", ", StartSlot + NumBuffersSet - 1,
505  "] is out of allowed range [0, ", MAX_BUFFER_SLOTS - 1, "].");
506 
507  DEV_CHECK_ERR(!(m_pActiveRenderPass != nullptr && StateTransitionMode == RESOURCE_STATE_TRANSITION_MODE_TRANSITION),
508  "Resource state transitons are not allowed inside a render pass and may result in an undefined behavior. "
509  "Do not use RESOURCE_STATE_TRANSITION_MODE_TRANSITION or end the render pass first.");
510 
512  {
513  // Reset only these buffer slots that are not being set.
514  // It is very important to not reset buffers that stay unchanged
515  // as AddRef()/Release() are not free
516  for (Uint32 s = 0; s < StartSlot; ++s)
517  m_VertexStreams[s] = VertexStreamInfo<BufferImplType>{};
518  for (Uint32 s = StartSlot + NumBuffersSet; s < m_NumVertexStreams; ++s)
519  m_VertexStreams[s] = VertexStreamInfo<BufferImplType>{};
520  m_NumVertexStreams = 0;
521  }
522  m_NumVertexStreams = std::max(m_NumVertexStreams, StartSlot + NumBuffersSet);
523 
524  for (Uint32 Buff = 0; Buff < NumBuffersSet; ++Buff)
525  {
526  auto& CurrStream = m_VertexStreams[StartSlot + Buff];
527  CurrStream.pBuffer = ppBuffers ? ValidatedCast<BufferImplType>(ppBuffers[Buff]) : nullptr;
528  CurrStream.Offset = pOffsets ? pOffsets[Buff] : 0;
529 #ifdef DILIGENT_DEVELOPMENT
530  if (CurrStream.pBuffer)
531  {
532  const auto& BuffDesc = CurrStream.pBuffer->GetDesc();
533  DEV_CHECK_ERR((BuffDesc.BindFlags & BIND_VERTEX_BUFFER) != 0,
534  "Buffer '", BuffDesc.Name ? BuffDesc.Name : "", "' being bound as vertex buffer to slot ", Buff,
535  " was not created with BIND_VERTEX_BUFFER flag");
536  }
537 #endif
538  }
539  // Remove null buffers from the end of the array
540  while (m_NumVertexStreams > 0 && !m_VertexStreams[m_NumVertexStreams - 1].pBuffer)
541  m_VertexStreams[m_NumVertexStreams--] = VertexStreamInfo<BufferImplType>{};
542 }
543 
544 template <typename ImplementationTraits>
546  PipelineStateImplType* pPipelineState,
547  int /*Dummy*/)
548 {
549  m_pPipelineState = pPipelineState;
550 }
551 
552 template <typename ImplementationTraits>
554  IShaderResourceBinding* pShaderResourceBinding,
555  RESOURCE_STATE_TRANSITION_MODE StateTransitionMode,
556  int)
557 {
558  DEV_CHECK_ERR(!(m_pActiveRenderPass != nullptr && StateTransitionMode == RESOURCE_STATE_TRANSITION_MODE_TRANSITION),
559  "Resource state transitons are not allowed inside a render pass and may result in an undefined behavior. "
560  "Do not use RESOURCE_STATE_TRANSITION_MODE_TRANSITION or end the render pass first.");
561 
562  DEV_CHECK_ERR(pShaderResourceBinding != nullptr, "pShaderResourceBinding must not be null");
563 }
564 
565 template <typename ImplementationTraits>
567 {
568  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "Invalidating context inside an active render pass. Call EndRenderPass() to finish the pass.");
569 
571 }
572 
573 template <typename ImplementationTraits>
575  IBuffer* pIndexBuffer,
576  Uint32 ByteOffset,
577  RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)
578 {
579  m_pIndexBuffer = ValidatedCast<BufferImplType>(pIndexBuffer);
580  m_IndexDataStartOffset = ByteOffset;
581 
582 #ifdef DILIGENT_DEVELOPMENT
583  DEV_CHECK_ERR(!(m_pActiveRenderPass != nullptr && StateTransitionMode == RESOURCE_STATE_TRANSITION_MODE_TRANSITION),
584  "Resource state transitons are not allowed inside a render pass and may result in an undefined behavior. "
585  "Do not use RESOURCE_STATE_TRANSITION_MODE_TRANSITION or end the render pass first.");
586 
587  if (m_pIndexBuffer)
588  {
589  const auto& BuffDesc = m_pIndexBuffer->GetDesc();
590  DEV_CHECK_ERR((BuffDesc.BindFlags & BIND_INDEX_BUFFER) != 0,
591  "Buffer '", BuffDesc.Name ? BuffDesc.Name : "", "' being bound as index buffer was not created with BIND_INDEX_BUFFER flag");
592  }
593 #endif
594 }
595 
596 
597 template <typename ImplementationTraits>
598 inline void DeviceContextBase<ImplementationTraits>::GetPipelineState(IPipelineState** ppPSO, float* BlendFactors, Uint32& StencilRef)
599 {
600  DEV_CHECK_ERR(ppPSO != nullptr, "Null pointer provided null");
601  DEV_CHECK_ERR(*ppPSO == nullptr, "Memory address contains a pointer to a non-null blend state");
602  if (m_pPipelineState)
603  {
604  m_pPipelineState->QueryInterface(IID_PipelineState, reinterpret_cast<IObject**>(ppPSO));
605  }
606  else
607  {
608  *ppPSO = nullptr;
609  }
610 
611  for (Uint32 f = 0; f < 4; ++f)
612  BlendFactors[f] = m_BlendFactors[f];
613  StencilRef = m_StencilRef;
614 };
615 
616 template <typename ImplementationTraits>
617 inline bool DeviceContextBase<ImplementationTraits>::SetBlendFactors(const float* BlendFactors, int)
618 {
619  bool FactorsDiffer = false;
620  for (Uint32 f = 0; f < 4; ++f)
621  {
622  if (m_BlendFactors[f] != BlendFactors[f])
623  FactorsDiffer = true;
624  m_BlendFactors[f] = BlendFactors[f];
625  }
626  return FactorsDiffer;
627 }
628 
629 template <typename ImplementationTraits>
631 {
632  if (m_StencilRef != StencilRef)
633  {
634  m_StencilRef = StencilRef;
635  return true;
636  }
637  return false;
638 }
639 
640 template <typename ImplementationTraits>
642  Uint32 NumViewports,
643  const Viewport* pViewports,
644  Uint32& RTWidth,
645  Uint32& RTHeight)
646 {
647  if (RTWidth == 0 || RTHeight == 0)
648  {
649  RTWidth = m_FramebufferWidth;
650  RTHeight = m_FramebufferHeight;
651  }
652 
653  DEV_CHECK_ERR(NumViewports < MAX_VIEWPORTS, "Number of viewports (", NumViewports, ") exceeds the limit (", MAX_VIEWPORTS, ")");
654  m_NumViewports = std::min(MAX_VIEWPORTS, NumViewports);
655 
656  Viewport DefaultVP(0, 0, static_cast<float>(RTWidth), static_cast<float>(RTHeight));
657  // If no viewports are specified, use default viewport
658  if (m_NumViewports == 1 && pViewports == nullptr)
659  {
660  pViewports = &DefaultVP;
661  }
662 
663  for (Uint32 vp = 0; vp < m_NumViewports; ++vp)
664  {
665  m_Viewports[vp] = pViewports[vp];
666  DEV_CHECK_ERR(m_Viewports[vp].Width >= 0, "Incorrect viewport width (", m_Viewports[vp].Width, ")");
667  DEV_CHECK_ERR(m_Viewports[vp].Height >= 0, "Incorrect viewport height (", m_Viewports[vp].Height, ")");
668  DEV_CHECK_ERR(m_Viewports[vp].MaxDepth >= m_Viewports[vp].MinDepth, "Incorrect viewport depth range [", m_Viewports[vp].MinDepth, ", ", m_Viewports[vp].MaxDepth, "]");
669  }
670 }
671 
672 template <typename ImplementationTraits>
674 {
675  NumViewports = m_NumViewports;
676  if (pViewports)
677  {
678  for (Uint32 vp = 0; vp < m_NumViewports; ++vp)
679  pViewports[vp] = m_Viewports[vp];
680  }
681 }
682 
683 template <typename ImplementationTraits>
685  Uint32 NumRects,
686  const Rect* pRects,
687  Uint32& RTWidth,
688  Uint32& RTHeight)
689 {
690  if (RTWidth == 0 || RTHeight == 0)
691  {
692  RTWidth = m_FramebufferWidth;
693  RTHeight = m_FramebufferHeight;
694  }
695 
696  DEV_CHECK_ERR(NumRects < MAX_VIEWPORTS, "Number of scissor rects (", NumRects, ") exceeds the limit (", MAX_VIEWPORTS, ")");
697  m_NumScissorRects = std::min(MAX_VIEWPORTS, NumRects);
698 
699  for (Uint32 sr = 0; sr < m_NumScissorRects; ++sr)
700  {
701  m_ScissorRects[sr] = pRects[sr];
702  DEV_CHECK_ERR(m_ScissorRects[sr].left <= m_ScissorRects[sr].right, "Incorrect horizontal bounds for a scissor rect [", m_ScissorRects[sr].left, ", ", m_ScissorRects[sr].right, ")");
703  DEV_CHECK_ERR(m_ScissorRects[sr].top <= m_ScissorRects[sr].bottom, "Incorrect vertical bounds for a scissor rect [", m_ScissorRects[sr].top, ", ", m_ScissorRects[sr].bottom, ")");
704  }
705 }
706 
707 template <typename ImplementationTraits>
709  Uint32 NumRenderTargets,
710  ITextureView* ppRenderTargets[],
711  ITextureView* pDepthStencil)
712 {
713  if (NumRenderTargets == 0 && pDepthStencil == nullptr)
714  {
715  ResetRenderTargets();
716  return false;
717  }
718 
719  bool bBindRenderTargets = false;
720  m_FramebufferWidth = 0;
721  m_FramebufferHeight = 0;
722  m_FramebufferSlices = 0;
723  m_FramebufferSamples = 0;
724 
725  if (NumRenderTargets != m_NumBoundRenderTargets)
726  {
727  bBindRenderTargets = true;
728  for (Uint32 rt = NumRenderTargets; rt < m_NumBoundRenderTargets; ++rt)
729  m_pBoundRenderTargets[rt].Release();
730 
731  m_NumBoundRenderTargets = NumRenderTargets;
732  }
733 
734  for (Uint32 rt = 0; rt < NumRenderTargets; ++rt)
735  {
736  auto* pRTView = ppRenderTargets[rt];
737  if (pRTView)
738  {
739  const auto& RTVDesc = pRTView->GetDesc();
740  DEV_CHECK_ERR(RTVDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET,
741  "Texture view object named '", RTVDesc.Name ? RTVDesc.Name : "", "' has incorrect view type (", GetTexViewTypeLiteralName(RTVDesc.ViewType), "). Render target view is expected");
742 
743  // Use this RTV to set the render target size
744  if (m_FramebufferWidth == 0)
745  {
746  auto* pTex = pRTView->GetTexture();
747  const auto& TexDesc = pTex->GetDesc();
748  m_FramebufferWidth = std::max(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U);
749  m_FramebufferHeight = std::max(TexDesc.Height >> RTVDesc.MostDetailedMip, 1U);
750  m_FramebufferSlices = RTVDesc.NumArraySlices;
751  m_FramebufferSamples = TexDesc.SampleCount;
752  }
753  else
754  {
755 #ifdef DILIGENT_DEVELOPMENT
756  const auto& TexDesc = pRTView->GetTexture()->GetDesc();
757  DEV_CHECK_ERR(m_FramebufferWidth == std::max(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U),
758  "Render target width (", std::max(TexDesc.Width >> RTVDesc.MostDetailedMip, 1U), ") specified by RTV '", RTVDesc.Name, "' is inconsistent with the width of previously bound render targets (", m_FramebufferWidth, ")");
759  DEV_CHECK_ERR(m_FramebufferHeight == std::max(TexDesc.Height >> RTVDesc.MostDetailedMip, 1U),
760  "Render target height (", std::max(TexDesc.Height >> RTVDesc.MostDetailedMip, 1U), ") specified by RTV '", RTVDesc.Name, "' is inconsistent with the height of previously bound render targets (", m_FramebufferHeight, ")");
761  DEV_CHECK_ERR(m_FramebufferSlices == RTVDesc.NumArraySlices,
762  "The number of slices (", RTVDesc.NumArraySlices, ") specified by RTV '", RTVDesc.Name, "' is inconsistent with the number of slices in previously bound render targets (", m_FramebufferSlices, ")");
763  DEV_CHECK_ERR(m_FramebufferSamples == TexDesc.SampleCount,
764  "Sample count (", TexDesc.SampleCount, ") of RTV '", RTVDesc.Name, "' is inconsistent with the sample count of previously bound render targets (", m_FramebufferSamples, ")");
765 #endif
766  }
767  }
768 
769  // Here both views are certainly live objects, since we store
770  // strong references to all bound render targets. So we
771  // can safely compare pointers.
772  if (m_pBoundRenderTargets[rt] != pRTView)
773  {
774  m_pBoundRenderTargets[rt] = ValidatedCast<TextureViewImplType>(pRTView);
775  bBindRenderTargets = true;
776  }
777  }
778 
779  if (pDepthStencil != nullptr)
780  {
781  const auto& DSVDesc = pDepthStencil->GetDesc();
782  DEV_CHECK_ERR(DSVDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL,
783  "Texture view object named '", DSVDesc.Name ? DSVDesc.Name : "", "' has incorrect view type (", GetTexViewTypeLiteralName(DSVDesc.ViewType), "). Depth stencil view is expected");
784 
785  // Use depth stencil size to set render target size
786  if (m_FramebufferWidth == 0)
787  {
788  auto* pTex = pDepthStencil->GetTexture();
789  const auto& TexDesc = pTex->GetDesc();
790  m_FramebufferWidth = std::max(TexDesc.Width >> DSVDesc.MostDetailedMip, 1U);
791  m_FramebufferHeight = std::max(TexDesc.Height >> DSVDesc.MostDetailedMip, 1U);
792  m_FramebufferSlices = DSVDesc.NumArraySlices;
793  m_FramebufferSamples = TexDesc.SampleCount;
794  }
795  else
796  {
797 #ifdef DILIGENT_DEVELOPMENT
798  const auto& TexDesc = pDepthStencil->GetTexture()->GetDesc();
799  DEV_CHECK_ERR(m_FramebufferWidth == std::max(TexDesc.Width >> DSVDesc.MostDetailedMip, 1U),
800  "Depth-stencil target width (", std::max(TexDesc.Width >> DSVDesc.MostDetailedMip, 1U), ") specified by DSV '", DSVDesc.Name, "' is inconsistent with the width of previously bound render targets (", m_FramebufferWidth, ")");
801  DEV_CHECK_ERR(m_FramebufferHeight == std::max(TexDesc.Height >> DSVDesc.MostDetailedMip, 1U),
802  "Depth-stencil target height (", std::max(TexDesc.Height >> DSVDesc.MostDetailedMip, 1U), ") specified by DSV '", DSVDesc.Name, "' is inconsistent with the height of previously bound render targets (", m_FramebufferHeight, ")");
803  DEV_CHECK_ERR(m_FramebufferSlices == DSVDesc.NumArraySlices,
804  "The number of slices (", DSVDesc.NumArraySlices, ") specified by DSV '", DSVDesc.Name, "' is inconsistent with the number of slices in previously bound render targets (", m_FramebufferSlices, ")");
805  DEV_CHECK_ERR(m_FramebufferSamples == TexDesc.SampleCount,
806  "Sample count (", TexDesc.SampleCount, ") of DSV '", DSVDesc.Name, "' is inconsistent with the sample count of previously bound render targets (", m_FramebufferSamples, ")");
807 #endif
808  }
809  }
810 
811  if (m_pBoundDepthStencil != pDepthStencil)
812  {
813  m_pBoundDepthStencil = ValidatedCast<TextureViewImplType>(pDepthStencil);
814  bBindRenderTargets = true;
815  }
816 
817  VERIFY_EXPR(m_FramebufferWidth > 0 && m_FramebufferHeight > 0 && m_FramebufferSlices > 0 && m_FramebufferSamples > 0);
818 
819  return bBindRenderTargets;
820 }
821 
822 template <typename ImplementationTraits>
824 {
825  VERIFY_EXPR(m_pBoundFramebuffer);
826  VERIFY_EXPR(m_pActiveRenderPass);
827 
828  const auto& RPDesc = m_pActiveRenderPass->GetDesc();
829  const auto& FBDesc = m_pBoundFramebuffer->GetDesc();
830  VERIFY_EXPR(m_SubpassIndex < RPDesc.SubpassCount);
831  const auto& Subpass = RPDesc.pSubpasses[m_SubpassIndex];
832 
833  m_FramebufferSamples = 0;
834 
835  ITextureView* ppRTVs[MAX_RENDER_TARGETS] = {};
836  ITextureView* pDSV = nullptr;
837  for (Uint32 rt = 0; rt < Subpass.RenderTargetAttachmentCount; ++rt)
838  {
839  const auto& RTAttachmentRef = Subpass.pRenderTargetAttachments[rt];
840  if (RTAttachmentRef.AttachmentIndex != ATTACHMENT_UNUSED)
841  {
842  VERIFY_EXPR(RTAttachmentRef.AttachmentIndex < RPDesc.AttachmentCount);
843  ppRTVs[rt] = FBDesc.ppAttachments[RTAttachmentRef.AttachmentIndex];
844  if (ppRTVs[rt] != nullptr)
845  {
846  if (m_FramebufferSamples == 0)
847  m_FramebufferSamples = ppRTVs[rt]->GetTexture()->GetDesc().SampleCount;
848  else
849  DEV_CHECK_ERR(m_FramebufferSamples == ppRTVs[rt]->GetTexture()->GetDesc().SampleCount, "Inconsistent sample count");
850  }
851  }
852  }
853 
854  if (Subpass.pDepthStencilAttachment != nullptr)
855  {
856  const auto& DSAttachmentRef = *Subpass.pDepthStencilAttachment;
857  if (DSAttachmentRef.AttachmentIndex != ATTACHMENT_UNUSED)
858  {
859  VERIFY_EXPR(DSAttachmentRef.AttachmentIndex < RPDesc.AttachmentCount);
860  pDSV = FBDesc.ppAttachments[DSAttachmentRef.AttachmentIndex];
861  if (pDSV != nullptr)
862  {
863  if (m_FramebufferSamples == 0)
864  m_FramebufferSamples = pDSV->GetTexture()->GetDesc().SampleCount;
865  else
866  DEV_CHECK_ERR(m_FramebufferSamples == pDSV->GetTexture()->GetDesc().SampleCount, "Inconsistent sample count");
867  }
868  }
869  }
870  bool BindRenderTargets = SetRenderTargets(Subpass.RenderTargetAttachmentCount, ppRTVs, pDSV);
871 
872  // Use framebuffer dimensions (override what was set by SetRenderTargets)
873  m_FramebufferWidth = FBDesc.Width;
874  m_FramebufferHeight = FBDesc.Height;
875  m_FramebufferSlices = FBDesc.NumArraySlices;
876  VERIFY_EXPR(m_FramebufferSamples > 0);
877 
878  return BindRenderTargets;
879 }
880 
881 
882 template <typename ImplementationTraits>
884  Uint32& NumRenderTargets,
885  ITextureView** ppRTVs,
886  ITextureView** ppDSV)
887 {
888  NumRenderTargets = m_NumBoundRenderTargets;
889 
890  if (ppRTVs)
891  {
892  for (Uint32 rt = 0; rt < NumRenderTargets; ++rt)
893  {
894  DEV_CHECK_ERR(ppRTVs[rt] == nullptr, "Non-null pointer found in RTV array element #", rt);
895  auto pBoundRTV = m_pBoundRenderTargets[rt];
896  if (pBoundRTV)
897  pBoundRTV->QueryInterface(IID_TextureView, reinterpret_cast<IObject**>(ppRTVs + rt));
898  else
899  ppRTVs[rt] = nullptr;
900  }
901  for (Uint32 rt = NumRenderTargets; rt < MAX_RENDER_TARGETS; ++rt)
902  {
903  DEV_CHECK_ERR(ppRTVs[rt] == nullptr, "Non-null pointer found in RTV array element #", rt);
904  ppRTVs[rt] = nullptr;
905  }
906  }
907 
908  if (ppDSV)
909  {
910  DEV_CHECK_ERR(*ppDSV == nullptr, "Non-null DSV pointer found");
911  if (m_pBoundDepthStencil)
912  m_pBoundDepthStencil->QueryInterface(IID_TextureView, reinterpret_cast<IObject**>(ppDSV));
913  else
914  *ppDSV = nullptr;
915  }
916 }
917 
918 template <typename ImplementationTraits>
920 {
921  for (Uint32 stream = 0; stream < m_NumVertexStreams; ++stream)
922  m_VertexStreams[stream] = VertexStreamInfo<BufferImplType>{};
923 #ifdef DILIGENT_DEBUG
924  for (Uint32 stream = m_NumVertexStreams; stream < _countof(m_VertexStreams); ++stream)
925  {
926  VERIFY(m_VertexStreams[stream].pBuffer == nullptr, "Unexpected non-null buffer");
927  VERIFY(m_VertexStreams[stream].Offset == 0, "Unexpected non-zero offset");
928  }
929 #endif
930  m_NumVertexStreams = 0;
931 
932  m_pPipelineState.Release();
933 
934  m_pIndexBuffer.Release();
935  m_IndexDataStartOffset = 0;
936 
937  m_StencilRef = 0;
938 
939  for (int i = 0; i < 4; ++i)
940  m_BlendFactors[i] = -1;
941 
942  for (Uint32 vp = 0; vp < m_NumViewports; ++vp)
943  m_Viewports[vp] = Viewport();
944  m_NumViewports = 0;
945 
946  for (Uint32 sr = 0; sr < m_NumScissorRects; ++sr)
947  m_ScissorRects[sr] = Rect();
948  m_NumScissorRects = 0;
949 
950  ResetRenderTargets();
951 
952  VERIFY(!m_pActiveRenderPass, "Clearing state cache inside an active render pass");
953  m_pActiveRenderPass = nullptr;
954  m_pBoundFramebuffer = nullptr;
955 }
956 
957 template <typename ImplementationTraits>
959 {
960  if (pTexture == nullptr)
961  return false;
962 
963  for (Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt)
964  {
965  if (m_pBoundRenderTargets[rt] && m_pBoundRenderTargets[rt]->GetTexture() == pTexture)
966  {
967  return true;
968  }
969  }
970 
971  return false;
972 }
973 
974 template <typename ImplementationTraits>
976 {
977  if (pTexture == nullptr)
978  return false;
979 
980  return m_pBoundDepthStencil && m_pBoundDepthStencil->GetTexture() == pTexture;
981 }
982 
983 template <typename ImplementationTraits>
985 {
986  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "State transitions are not allowed inside a render pass.");
987 
988  if (pTexture == nullptr)
989  return false;
990 
991  const auto& TexDesc = pTexture->GetDesc();
992 
993  bool bResetRenderTargets = false;
994  if (TexDesc.BindFlags & BIND_RENDER_TARGET)
995  {
996  if (CheckIfBoundAsRenderTarget(pTexture))
997  {
998  if (bShowMessage)
999  {
1000  LOG_INFO_MESSAGE("Texture '", TexDesc.Name,
1001  "' is currently bound as render target and will be unset along with all "
1002  "other render targets and depth-stencil buffer. "
1003  "Call SetRenderTargets() to reset the render targets.\n"
1004  "To silence this message, explicitly unbind the texture with "
1005  "SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_NONE)");
1006  }
1007 
1008  bResetRenderTargets = true;
1009  }
1010  }
1011 
1012  if (TexDesc.BindFlags & BIND_DEPTH_STENCIL)
1013  {
1014  if (CheckIfBoundAsDepthStencil(pTexture))
1015  {
1016  if (bShowMessage)
1017  {
1018  LOG_INFO_MESSAGE("Texture '", TexDesc.Name,
1019  "' is currently bound as depth buffer and will be unset along with "
1020  "all render targets. Call SetRenderTargets() to reset the render targets.\n"
1021  "To silence this message, explicitly unbind the texture with "
1022  "SetRenderTargets(0, nullptr, nullptr, RESOURCE_STATE_TRANSITION_MODE_NONE)");
1023  }
1024 
1025  bResetRenderTargets = true;
1026  }
1027  }
1028 
1029  if (bResetRenderTargets)
1030  {
1031  ResetRenderTargets();
1032  }
1033 
1034  return bResetRenderTargets;
1035 }
1036 
1037 template <typename ImplementationTraits>
1039 {
1040  for (Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt)
1041  m_pBoundRenderTargets[rt].Release();
1042 #ifdef DILIGENT_DEBUG
1043  for (Uint32 rt = m_NumBoundRenderTargets; rt < _countof(m_pBoundRenderTargets); ++rt)
1044  {
1045  VERIFY(m_pBoundRenderTargets[rt] == nullptr, "Non-null render target found");
1046  }
1047 #endif
1048  m_NumBoundRenderTargets = 0;
1049  m_FramebufferWidth = 0;
1050  m_FramebufferHeight = 0;
1051  m_FramebufferSlices = 0;
1052  m_FramebufferSamples = 0;
1053 
1054  m_pBoundDepthStencil.Release();
1055 
1056  // Do not reset framebuffer here as there may potentially
1057  // be a subpass without any render target attachments.
1058 }
1059 
1060 template <typename ImplementationTraits>
1062 {
1063  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "Attempting to begin render pass while another render pass ('", m_pActiveRenderPass->GetDesc().Name, "') is active.");
1064  DEV_CHECK_ERR(m_pBoundFramebuffer == nullptr, "Attempting to begin render pass while another framebuffer ('", m_pBoundFramebuffer->GetDesc().Name, "') is bound.");
1065 
1067 
1068  // Reset current render targets (in Vulkan backend, this may end current render pass).
1069  ResetRenderTargets();
1070 
1071  auto* pNewRenderPass = ValidatedCast<RenderPassImplType>(Attribs.pRenderPass);
1072  auto* pNewFramebuffer = ValidatedCast<FramebufferImplType>(Attribs.pFramebuffer);
1074  {
1075  const auto& RPDesc = pNewRenderPass->GetDesc();
1076  const auto& FBDesc = pNewFramebuffer->GetDesc();
1077  DEV_CHECK_ERR(RPDesc.AttachmentCount <= FBDesc.AttachmentCount,
1078  "The number of attachments (", FBDesc.AttachmentCount,
1079  ") in currently bound framebuffer is smaller than the number of attachments in the render pass (", RPDesc.AttachmentCount, ")");
1080  for (Uint32 i = 0; i < FBDesc.AttachmentCount; ++i)
1081  {
1082  auto* pView = FBDesc.ppAttachments[i];
1083  if (pView == nullptr)
1084  return;
1085 
1086  auto* pTex = ValidatedCast<TextureImplType>(pView->GetTexture());
1087  auto RequiredState = RPDesc.pAttachments[i].InitialState;
1089  {
1090  if (pTex->IsInKnownState() && !pTex->CheckState(RequiredState))
1091  {
1092  StateTransitionDesc Barrier{pTex, RESOURCE_STATE_UNKNOWN, RequiredState, true};
1093  this->TransitionResourceStates(1, &Barrier);
1094  }
1095  }
1097  {
1098  DvpVerifyTextureState(*pTex, RequiredState, "BeginRenderPass");
1099  }
1100  }
1101  }
1102 
1103  m_pActiveRenderPass = pNewRenderPass;
1104  m_pBoundFramebuffer = pNewFramebuffer;
1105  m_SubpassIndex = 0;
1106  m_RenderPassAttachmentsTransitionMode = Attribs.StateTransitionMode;
1107 
1108  UpdateAttachmentStates(m_SubpassIndex);
1109  SetSubpassRenderTargets();
1110 }
1111 
1112 template <typename ImplementationTraits>
1114 {
1115  DEV_CHECK_ERR(m_pActiveRenderPass != nullptr, "There is no active render pass");
1116  VERIFY(m_SubpassIndex + 1 < m_pActiveRenderPass->GetDesc().SubpassCount, "The render pass has reached the final subpass already");
1117  ++m_SubpassIndex;
1118  UpdateAttachmentStates(m_SubpassIndex);
1119  SetSubpassRenderTargets();
1120 }
1121 
1122 template <typename ImplementationTraits>
1124 {
1125  if (m_RenderPassAttachmentsTransitionMode != RESOURCE_STATE_TRANSITION_MODE_TRANSITION)
1126  return;
1127 
1128  DEV_CHECK_ERR(m_pActiveRenderPass != nullptr, "There is no active render pass");
1129  DEV_CHECK_ERR(m_pBoundFramebuffer != nullptr, "There is no active framebuffer");
1130 
1131  const auto& RPDesc = m_pActiveRenderPass->GetDesc();
1132  const auto& FBDesc = m_pBoundFramebuffer->GetDesc();
1133  VERIFY(FBDesc.AttachmentCount == RPDesc.AttachmentCount,
1134  "Framebuffer attachment count (", FBDesc.AttachmentCount, ") is not consistent with the render pass attachment count (", RPDesc.AttachmentCount, ")");
1135  VERIFY_EXPR(SubpassIndex <= RPDesc.SubpassCount);
1136  for (Uint32 i = 0; i < RPDesc.AttachmentCount; ++i)
1137  {
1138  if (auto* pView = FBDesc.ppAttachments[i])
1139  {
1140  auto* pTex = ValidatedCast<TextureImplType>(pView->GetTexture());
1141  if (pTex->IsInKnownState())
1142  {
1143  auto CurrState = SubpassIndex < RPDesc.SubpassCount ?
1144  m_pActiveRenderPass->GetAttachmentState(SubpassIndex, i) :
1145  RPDesc.pAttachments[i].FinalState;
1146  pTex->SetState(CurrState);
1147  }
1148  }
1149  }
1150 }
1151 
1152 template <typename ImplementationTraits>
1154 {
1155  DEV_CHECK_ERR(m_pActiveRenderPass != nullptr, "There is no active render pass");
1156  DEV_CHECK_ERR(m_pBoundFramebuffer != nullptr, "There is no active framebuffer");
1157  VERIFY(m_pActiveRenderPass->GetDesc().SubpassCount == m_SubpassIndex + 1,
1158  "Ending render pass at subpass ", m_SubpassIndex, " before reaching the final subpass");
1159 
1160  UpdateAttachmentStates(m_SubpassIndex + 1);
1161 
1162  m_pActiveRenderPass.Release();
1163  m_pBoundFramebuffer.Release();
1164  m_SubpassIndex = 0;
1165  m_RenderPassAttachmentsTransitionMode = RESOURCE_STATE_TRANSITION_MODE_NONE;
1166  ResetRenderTargets();
1167 }
1168 
1169 
1170 template <typename ImplementationTraits>
1172 {
1173  DEV_CHECK_ERR(pView != nullptr, "Depth-stencil view to clear must not be null");
1174 
1175 #ifdef DILIGENT_DEVELOPMENT
1176  {
1177  const auto& ViewDesc = pView->GetDesc();
1178  DEV_CHECK_ERR(ViewDesc.ViewType == TEXTURE_VIEW_DEPTH_STENCIL,
1179  "The type (", GetTexViewTypeLiteralName(ViewDesc.ViewType), ") of the texture view '", ViewDesc.Name,
1180  "' is invalid: ClearDepthStencil command expects depth-stencil view (TEXTURE_VIEW_DEPTH_STENCIL).");
1181 
1182  if (pView != m_pBoundDepthStencil)
1183  {
1184  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr,
1185  "Depth-stencil view '", ViewDesc.Name,
1186  "' is not bound as framebuffer attachment. ClearDepthStencil command inside a render pass "
1187  "requires depth-stencil view to be bound as a framebuffer attachment.");
1188 
1189  if (m_pDevice->GetDeviceCaps().IsGLDevice())
1190  {
1191  LOG_ERROR_MESSAGE("Depth-stencil view '", ViewDesc.Name,
1192  "' is not bound to the device context. ClearDepthStencil command requires "
1193  "depth-stencil view be bound to the device contex in OpenGL backend");
1194  }
1195  else
1196  {
1197  LOG_WARNING_MESSAGE("Depth-stencil view '", ViewDesc.Name,
1198  "' is not bound to the device context. "
1199  "ClearDepthStencil command is more efficient when depth-stencil "
1200  "view is bound to the context. In OpenGL backend this is a requirement.");
1201  }
1202  }
1203  }
1204 #endif
1205 }
1206 
1207 template <typename ImplementationTraits>
1209 {
1210  DEV_CHECK_ERR(pView != nullptr, "Render target view to clear must not be null");
1211 
1212 #ifdef DILIGENT_DEVELOPMENT
1213  {
1214  const auto& ViewDesc = pView->GetDesc();
1215  DEV_CHECK_ERR(ViewDesc.ViewType == TEXTURE_VIEW_RENDER_TARGET,
1216  "The type (", GetTexViewTypeLiteralName(ViewDesc.ViewType), ") of texture view '", pView->GetDesc().Name,
1217  "' is invalid: ClearRenderTarget command expects render target view (TEXTURE_VIEW_RENDER_TARGET).");
1218 
1219  bool RTFound = false;
1220  for (Uint32 i = 0; i < m_NumBoundRenderTargets && !RTFound; ++i)
1221  {
1222  RTFound = m_pBoundRenderTargets[i] == pView;
1223  }
1224 
1225  if (!RTFound)
1226  {
1227  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr,
1228  "Render target view '", ViewDesc.Name,
1229  "' is not bound as framebuffer attachment. ClearRenderTarget command inside a render pass "
1230  "requires render target view to be bound as a framebuffer attachment.");
1231 
1232  if (m_pDevice->GetDeviceCaps().IsGLDevice())
1233  {
1234  LOG_ERROR_MESSAGE("Render target view '", ViewDesc.Name,
1235  "' is not bound to the device context. ClearRenderTarget command "
1236  "requires render target view to be bound to the device contex in OpenGL backend");
1237  }
1238  else
1239  {
1240  LOG_WARNING_MESSAGE("Render target view '", ViewDesc.Name,
1241  "' is not bound to the device context. ClearRenderTarget command is more efficient "
1242  "if render target view is bound to the device context. In OpenGL backend this is a requirement.");
1243  }
1244  }
1245  }
1246 #endif
1247 }
1248 
1249 template <typename ImplementationTraits>
1251 {
1252  DEV_CHECK_ERR(pQuery != nullptr, "IDeviceContext::BeginQuery: pQuery must not be null");
1253 
1254  DEV_CHECK_ERR(!m_bIsDeferred, "IDeviceContext::BeginQuery: Deferred contexts do not support queries");
1255 
1257  "BeginQuery() is disabled for timestamp queries. Call EndQuery() to set the timestamp.");
1258 
1259  ValidatedCast<QueryImplType>(pQuery)->OnBeginQuery(this);
1260 }
1261 
1262 template <typename ImplementationTraits>
1264 {
1265  DEV_CHECK_ERR(pQuery != nullptr, "IDeviceContext::EndQuery: pQuery must not be null");
1266 
1267  DEV_CHECK_ERR(!m_bIsDeferred, "IDeviceContext::EndQuery: Deferred contexts do not support queries");
1268 
1269  ValidatedCast<QueryImplType>(pQuery)->OnEndQuery(this);
1270 }
1271 
1272 template <typename ImplementationTraits>
1274  IBuffer* pBuffer,
1275  Uint32 Offset,
1276  Uint32 Size,
1277  const void* pData,
1278  RESOURCE_STATE_TRANSITION_MODE StateTransitionMode)
1279 {
1280  DEV_CHECK_ERR(pBuffer != nullptr, "Buffer must not be null");
1281  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "UpdateBuffer command must be used outside of render pass.");
1282 #ifdef DILIGENT_DEVELOPMENT
1283  {
1284  const auto& BuffDesc = ValidatedCast<BufferImplType>(pBuffer)->GetDesc();
1285  DEV_CHECK_ERR(BuffDesc.Usage == USAGE_DEFAULT, "Unable to update buffer '", BuffDesc.Name, "': only USAGE_DEFAULT buffers can be updated with UpdateData()");
1286  DEV_CHECK_ERR(Offset < BuffDesc.uiSizeInBytes, "Unable to update buffer '", BuffDesc.Name, "': offset (", Offset, ") exceeds the buffer size (", BuffDesc.uiSizeInBytes, ")");
1287  DEV_CHECK_ERR(Size + Offset <= BuffDesc.uiSizeInBytes, "Unable to update buffer '", BuffDesc.Name, "': Update region [", Offset, ",", Size + Offset, ") is out of buffer bounds [0,", BuffDesc.uiSizeInBytes, ")");
1288  }
1289 #endif
1290 }
1291 
1292 template <typename ImplementationTraits>
1294  IBuffer* pSrcBuffer,
1295  Uint32 SrcOffset,
1296  RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
1297  IBuffer* pDstBuffer,
1298  Uint32 DstOffset,
1299  Uint32 Size,
1300  RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode)
1301 {
1302  DEV_CHECK_ERR(pSrcBuffer != nullptr, "Source buffer must not be null");
1303  DEV_CHECK_ERR(pDstBuffer != nullptr, "Destination buffer must not be null");
1304  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "CopyBuffer command must be used outside of render pass.");
1305 #ifdef DILIGENT_DEVELOPMENT
1306  {
1307  const auto& SrcBufferDesc = ValidatedCast<BufferImplType>(pSrcBuffer)->GetDesc();
1308  const auto& DstBufferDesc = ValidatedCast<BufferImplType>(pDstBuffer)->GetDesc();
1309  DEV_CHECK_ERR(DstOffset + Size <= DstBufferDesc.uiSizeInBytes, "Failed to copy buffer '", SrcBufferDesc.Name, "' to '", DstBufferDesc.Name, "': Destination range [", DstOffset, ",", DstOffset + Size, ") is out of buffer bounds [0,", DstBufferDesc.uiSizeInBytes, ")");
1310  DEV_CHECK_ERR(SrcOffset + Size <= SrcBufferDesc.uiSizeInBytes, "Failed to copy buffer '", SrcBufferDesc.Name, "' to '", DstBufferDesc.Name, "': Source range [", SrcOffset, ",", SrcOffset + Size, ") is out of buffer bounds [0,", SrcBufferDesc.uiSizeInBytes, ")");
1311  }
1312 #endif
1313 }
1314 
1315 template <typename ImplementationTraits>
1317  IBuffer* pBuffer,
1318  MAP_TYPE MapType,
1319  MAP_FLAGS MapFlags,
1320  PVoid& pMappedData)
1321 {
1322  DEV_CHECK_ERR(pBuffer, "pBuffer must not be null");
1323 
1324  const auto& BuffDesc = pBuffer->GetDesc();
1325 
1326 #ifdef DILIGENT_DEBUG
1327  {
1328  VERIFY(m_DbgMappedBuffers.find(pBuffer) == m_DbgMappedBuffers.end(), "Buffer '", BuffDesc.Name, "' has already been mapped");
1329  m_DbgMappedBuffers[pBuffer] = DbgMappedBufferInfo{MapType};
1330  }
1331 #endif
1332 
1333  pMappedData = nullptr;
1334  switch (MapType)
1335  {
1336  case MAP_READ:
1337  DEV_CHECK_ERR(BuffDesc.Usage == USAGE_STAGING || BuffDesc.Usage == USAGE_UNIFIED,
1338  "Only buffers with usage USAGE_STAGING or USAGE_UNIFIED can be mapped for reading");
1339  DEV_CHECK_ERR((BuffDesc.CPUAccessFlags & CPU_ACCESS_READ), "Buffer being mapped for reading was not created with CPU_ACCESS_READ flag");
1340  DEV_CHECK_ERR((MapFlags & MAP_FLAG_DISCARD) == 0, "MAP_FLAG_DISCARD is not valid when mapping buffer for reading");
1341  break;
1342 
1343  case MAP_WRITE:
1344  DEV_CHECK_ERR(BuffDesc.Usage == USAGE_DYNAMIC || BuffDesc.Usage == USAGE_STAGING || BuffDesc.Usage == USAGE_UNIFIED,
1345  "Only buffers with usage USAGE_STAGING, USAGE_DYNAMIC or USAGE_UNIFIED can be mapped for writing");
1346  DEV_CHECK_ERR((BuffDesc.CPUAccessFlags & CPU_ACCESS_WRITE), "Buffer being mapped for writing was not created with CPU_ACCESS_WRITE flag");
1347  break;
1348 
1349  case MAP_READ_WRITE:
1350  DEV_CHECK_ERR(BuffDesc.Usage == USAGE_STAGING || BuffDesc.Usage == USAGE_UNIFIED,
1351  "Only buffers with usage USAGE_STAGING or USAGE_UNIFIED can be mapped for reading and writing");
1352  DEV_CHECK_ERR((BuffDesc.CPUAccessFlags & CPU_ACCESS_WRITE), "Buffer being mapped for reading & writing was not created with CPU_ACCESS_WRITE flag");
1353  DEV_CHECK_ERR((BuffDesc.CPUAccessFlags & CPU_ACCESS_READ), "Buffer being mapped for reading & writing was not created with CPU_ACCESS_READ flag");
1354  DEV_CHECK_ERR((MapFlags & MAP_FLAG_DISCARD) == 0, "MAP_FLAG_DISCARD is not valid when mapping buffer for reading and writing");
1355  break;
1356 
1357  default: UNEXPECTED("Unknown map type");
1358  }
1359 
1360  if (BuffDesc.Usage == USAGE_DYNAMIC)
1361  {
1362  DEV_CHECK_ERR((MapFlags & (MAP_FLAG_DISCARD | MAP_FLAG_NO_OVERWRITE)) != 0 && MapType == MAP_WRITE, "Dynamic buffers can only be mapped for writing with MAP_FLAG_DISCARD or MAP_FLAG_NO_OVERWRITE flag");
1363  DEV_CHECK_ERR((MapFlags & (MAP_FLAG_DISCARD | MAP_FLAG_NO_OVERWRITE)) != (MAP_FLAG_DISCARD | MAP_FLAG_NO_OVERWRITE), "When mapping dynamic buffer, only one of MAP_FLAG_DISCARD or MAP_FLAG_NO_OVERWRITE flags must be specified");
1364  }
1365 
1366  if ((MapFlags & MAP_FLAG_DISCARD) != 0)
1367  {
1368  DEV_CHECK_ERR(BuffDesc.Usage == USAGE_DYNAMIC || BuffDesc.Usage == USAGE_STAGING, "Only dynamic and staging buffers can be mapped with discard flag");
1369  DEV_CHECK_ERR(MapType == MAP_WRITE, "MAP_FLAG_DISCARD is only valid when mapping buffer for writing");
1370  }
1371 }
1372 
1373 template <typename ImplementationTraits>
1375 {
1376  VERIFY(pBuffer, "pBuffer must not be null");
1377 #ifdef DILIGENT_DEBUG
1378  {
1379  auto MappedBufferIt = m_DbgMappedBuffers.find(pBuffer);
1380  VERIFY(MappedBufferIt != m_DbgMappedBuffers.end(), "Buffer '", pBuffer->GetDesc().Name, "' has not been mapped.");
1381  VERIFY(MappedBufferIt->second.MapType == MapType, "MapType (", MapType, ") does not match the map type that was used to map the buffer ", MappedBufferIt->second.MapType);
1382  m_DbgMappedBuffers.erase(MappedBufferIt);
1383  }
1384 #endif
1385 }
1386 
1387 
1388 template <typename ImplementationTraits>
1390  ITexture* pTexture,
1391  Uint32 MipLevel,
1392  Uint32 Slice,
1393  const Box& DstBox,
1394  const TextureSubResData& SubresData,
1395  RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode,
1396  RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode)
1397 {
1398  DEV_CHECK_ERR(pTexture != nullptr, "pTexture must not be null");
1399  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "UpdateTexture command must be used outside of render pass.");
1400 
1401  ValidateUpdateTextureParams(pTexture->GetDesc(), MipLevel, Slice, DstBox, SubresData);
1402 }
1403 
1404 template <typename ImplementationTraits>
1406 {
1407  DEV_CHECK_ERR(CopyAttribs.pSrcTexture, "Src texture must not be null");
1408  DEV_CHECK_ERR(CopyAttribs.pDstTexture, "Dst texture must not be null");
1409  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "CopyTexture command must be used outside of render pass.");
1410 
1411  ValidateCopyTextureParams(CopyAttribs);
1412 }
1413 
1414 template <typename ImplementationTraits>
1416  ITexture* pTexture,
1417  Uint32 MipLevel,
1418  Uint32 ArraySlice,
1419  MAP_TYPE MapType,
1420  MAP_FLAGS MapFlags,
1421  const Box* pMapRegion,
1422  MappedTextureSubresource& MappedData)
1423 {
1424  DEV_CHECK_ERR(pTexture, "pTexture must not be null");
1425  ValidateMapTextureParams(pTexture->GetDesc(), MipLevel, ArraySlice, MapType, MapFlags, pMapRegion);
1426 }
1427 
1428 template <typename ImplementationTraits>
1430  ITexture* pTexture,
1431  Uint32 MipLevel,
1432  Uint32 ArraySlice)
1433 {
1434  DEV_CHECK_ERR(pTexture, "pTexture must not be null");
1435  DEV_CHECK_ERR(MipLevel < pTexture->GetDesc().MipLevels, "Mip level is out of range");
1436  DEV_CHECK_ERR(ArraySlice < pTexture->GetDesc().ArraySize, "Array slice is out of range");
1437 }
1438 
1439 template <typename ImplementationTraits>
1441 {
1442  DEV_CHECK_ERR(pTexView != nullptr, "pTexView must not be null");
1443  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "GenerateMips command must be used outside of render pass.");
1444 #ifdef DILIGENT_DEVELOPMENT
1445  {
1446  const auto& ViewDesc = pTexView->GetDesc();
1447  DEV_CHECK_ERR(ViewDesc.ViewType == TEXTURE_VIEW_SHADER_RESOURCE, "Shader resource view '", ViewDesc.Name,
1448  "' can't be used to generate mipmaps because its type is ", GetTexViewTypeLiteralName(ViewDesc.ViewType), ". Required view type: TEXTURE_VIEW_SHADER_RESOURCE.");
1449  DEV_CHECK_ERR((ViewDesc.Flags & TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION) != 0, "Shader resource view '", ViewDesc.Name,
1450  "' was not created with TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION flag and can't be used to generate mipmaps.");
1451  }
1452 #endif
1453 }
1454 
1455 
1456 template <typename ImplementationTraits>
1458  ITexture* pSrcTexture,
1459  ITexture* pDstTexture,
1460  const ResolveTextureSubresourceAttribs& ResolveAttribs)
1461 {
1462 #ifdef DILIGENT_DEVELOPMENT
1463  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "ResolveTextureSubresource command must be used outside of render pass.");
1464 
1465  DEV_CHECK_ERR(pSrcTexture != nullptr && pDstTexture != nullptr, "Src and Dst textures must not be null");
1466  const auto& SrcTexDesc = pSrcTexture->GetDesc();
1467  const auto& DstTexDesc = pDstTexture->GetDesc();
1468 
1469  VerifyResolveTextureSubresourceAttribs(ResolveAttribs, SrcTexDesc, DstTexDesc);
1470 #endif
1471 }
1472 
1473 
1474 template <typename ImplementationTraits>
1476 {
1477  DEV_CHECK_ERR(m_pDevice->GetDeviceCaps().Features.RayTracing, "IDeviceContext::BuildBLAS: ray tracing is not supported by this device");
1478  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "IDeviceContext::BuildBLAS command must be performed outside of render pass");
1479  DEV_CHECK_ERR(VerifyBuildBLASAttribs(Attribs), "BuildBLASAttribs are invalid");
1480 }
1481 
1482 template <typename ImplementationTraits>
1484 {
1485  DEV_CHECK_ERR(m_pDevice->GetDeviceCaps().Features.RayTracing, "IDeviceContext::BuildTLAS: ray tracing is not supported by this device");
1486  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "IDeviceContext::BuildTLAS command must be performed outside of render pass");
1487  DEV_CHECK_ERR(VerifyBuildTLASAttribs(Attribs), "BuildTLASAttribs are invalid");
1488 }
1489 
1490 template <typename ImplementationTraits>
1492 {
1493  DEV_CHECK_ERR(m_pDevice->GetDeviceCaps().Features.RayTracing, "IDeviceContext::CopyBLAS: ray tracing is not supported by this device");
1494  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "IDeviceContext::CopyBLAS command must be performed outside of render pass");
1495  DEV_CHECK_ERR(VerifyCopyBLASAttribs(m_pDevice, Attribs), "CopyBLASAttribs are invalid");
1496 }
1497 
1498 template <typename ImplementationTraits>
1500 {
1501  DEV_CHECK_ERR(m_pDevice->GetDeviceCaps().Features.RayTracing, "IDeviceContext::CopyTLAS: ray tracing is not supported by this device");
1502  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "IDeviceContext::CopyTLAS command must be performed outside of render pass");
1503  DEV_CHECK_ERR(VerifyCopyTLASAttribs(Attribs), "CopyTLASAttribs are invalid");
1504  DEV_CHECK_ERR(ValidatedCast<TopLevelASType>(Attribs.pSrc)->ValidateContent(), "IDeviceContext::CopyTLAS: pSrc acceleration structure is not valid");
1505 }
1506 
1507 template <typename ImplementationTraits>
1509 {
1510  DEV_CHECK_ERR(m_pDevice->GetDeviceCaps().Features.RayTracing, "IDeviceContext::WriteBLASCompactedSize: ray tracing is not supported by this device");
1511  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "IDeviceContext::WriteBLASCompactedSize: command must be performed outside of render pass");
1512  DEV_CHECK_ERR(VerifyWriteBLASCompactedSizeAttribs(m_pDevice, Attribs), "WriteBLASCompactedSizeAttribs are invalid");
1513 }
1514 
1515 template <typename ImplementationTraits>
1517 {
1518  DEV_CHECK_ERR(m_pDevice->GetDeviceCaps().Features.RayTracing, "IDeviceContext::WriteTLASCompactedSize: ray tracing is not supported by this device");
1519  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "IDeviceContext::WriteTLASCompactedSize: command must be performed outside of render pass");
1520  DEV_CHECK_ERR(VerifyWriteTLASCompactedSizeAttribs(m_pDevice, Attribs), "WriteTLASCompactedSizeAttribs are invalid");
1521 }
1522 
1523 template <typename ImplementationTraits>
1525 {
1526  DEV_CHECK_ERR(m_pDevice->GetDeviceCaps().Features.RayTracing,
1527  "IDeviceContext::TraceRays: ray tracing is not supported by this device");
1528  DEV_CHECK_ERR(m_pPipelineState,
1529  "IDeviceContext::TraceRays command arguments are invalid: no pipeline state is bound.");
1530  DEV_CHECK_ERR(m_pPipelineState->GetDesc().IsRayTracingPipeline(),
1531  "IDeviceContext::TraceRays command arguments are invalid: pipeline state '", m_pPipelineState->GetDesc().Name, "' is not a ray tracing pipeline.");
1532 
1533  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "IDeviceContext::TraceRays must be performed outside of render pass");
1534 
1535  DEV_CHECK_ERR(VerifyTraceRaysAttribs(Attribs), "TraceRaysAttribs are invalid");
1536 
1537  DEV_CHECK_ERR(PipelineStateImplType::IsSameObject(m_pPipelineState, ValidatedCast<PipelineStateImplType>(Attribs.pSBT->GetDesc().pPSO)),
1538  "IDeviceContext::TraceRays command arguments are invalid: currently bound pipeline '", m_pPipelineState->GetDesc().Name,
1539  "' doesn't match the pipeline '", Attribs.pSBT->GetDesc().pPSO->GetDesc().Name, "' that was used in ShaderBindingTable");
1540 
1541  const auto* pSBTImpl = ValidatedCast<const ShaderBindingTableImplType>(Attribs.pSBT);
1542  DEV_CHECK_ERR(!pSBTImpl->HasPendingData(), "IDeviceContext::TraceRaysIndirect command arguments are invalid: SBT '",
1543  pSBTImpl->GetDesc().Name, "' has uncommited changes, call UpdateSBT() first");
1544 
1545  VERIFY(pSBTImpl->GetInternalBuffer() != nullptr,
1546  "SBT '", pSBTImpl->GetDesc().Name, "' internal buffer must not be null, this should never happen, ",
1547  "because HasPendingData() must've returned true triggering the assert above.");
1548  VERIFY(pSBTImpl->GetInternalBuffer()->CheckState(RESOURCE_STATE_RAY_TRACING),
1549  "SBT '", pSBTImpl->GetDesc().Name, "' internal buffer is expected to be in RESOURCE_STATE_RAY_TRACING, but current state is ",
1550  GetResourceStateString(pSBTImpl->GetInternalBuffer()->GetState()));
1551 
1552  DEV_CHECK_ERR((Attribs.DimensionX * Attribs.DimensionY * Attribs.DimensionZ) <= m_pDevice->GetProperties().MaxRayGenThreads,
1553  "IDeviceContext::TraceRays command arguments are invalid: the dimension must not exceed the ",
1554  m_pDevice->GetProperties().MaxRayGenThreads, " threads");
1555 }
1556 
1557 template <typename ImplementationTraits>
1559 {
1560  DEV_CHECK_ERR(m_pDevice->GetDeviceCaps().Features.RayTracing2,
1561  "IDeviceContext::TraceRaysIndirect: indirect trace rays is not supported by this device");
1562  DEV_CHECK_ERR(m_pPipelineState,
1563  "IDeviceContext::TraceRaysIndirect command arguments are invalid: no pipeline state is bound.");
1564  DEV_CHECK_ERR(m_pPipelineState->GetDesc().IsRayTracingPipeline(),
1565  "IDeviceContext::TraceRaysIndirect command arguments are invalid: pipeline state '", m_pPipelineState->GetDesc().Name,
1566  "' is not a ray tracing pipeline.");
1567  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr,
1568  "IDeviceContext::TraceRaysIndirect must be performed outside of render pass");
1569 
1570  DEV_CHECK_ERR(VerifyTraceRaysIndirectAttribs(m_pDevice, Attribs, pAttribsBuffer, TraceRaysIndirectCommandSize),
1571  "TraceRaysIndirectAttribs are invalid");
1572 
1573  DEV_CHECK_ERR(PipelineStateImplType::IsSameObject(m_pPipelineState, ValidatedCast<PipelineStateImplType>(Attribs.pSBT->GetDesc().pPSO)),
1574  "IDeviceContext::TraceRaysIndirect command arguments are invalid: currently bound pipeline '", m_pPipelineState->GetDesc().Name,
1575  "' doesn't match the pipeline '", Attribs.pSBT->GetDesc().pPSO->GetDesc().Name, "' that was used in ShaderBindingTable");
1576 
1577  const auto* pSBTImpl = ValidatedCast<const ShaderBindingTableImplType>(Attribs.pSBT);
1578  DEV_CHECK_ERR(!pSBTImpl->HasPendingData(),
1579  "IDeviceContext::TraceRaysIndirect command arguments are invalid: SBT '",
1580  pSBTImpl->GetDesc().Name, "' has uncommited changes, call UpdateSBT() first");
1581 
1582 
1583  VERIFY(pSBTImpl->GetInternalBuffer() != nullptr,
1584  "SBT '", pSBTImpl->GetDesc().Name, "' internal buffer must not be null, this should never happen, ",
1585  "because HasPendingData() must've returned true triggering the assert above.");
1586  VERIFY(pSBTImpl->GetInternalBuffer()->CheckState(RESOURCE_STATE_RAY_TRACING),
1587  "SBT '", pSBTImpl->GetDesc().Name, "' internal buffer is expected to be in RESOURCE_STATE_RAY_TRACING, but current state is ",
1588  GetResourceStateString(pSBTImpl->GetInternalBuffer()->GetState()));
1589 }
1590 
1591 template <typename ImplementationTraits>
1593 {
1594  DEV_CHECK_ERR(m_pDevice->GetDeviceCaps().Features.RayTracing, "IDeviceContext::UpdateSBT: ray tracing is not supported by this device");
1595  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "IDeviceContext::UpdateSBT must be performed outside of render pass");
1596  DEV_CHECK_ERR(pSBT != nullptr, "IDeviceContext::UpdateSBT command arguments are invalid: pSBT must not be null");
1597 
1598  if (pUpdateIndirectBufferAttribs != nullptr)
1599  {
1600  DEV_CHECK_ERR(pUpdateIndirectBufferAttribs->pAttribsBuffer != nullptr,
1601  "IDeviceContext::UpdateSBT command arguments are invalid: pUpdateIndirectBufferAttribs->pAttribsBuffer must not be null");
1602  }
1603 }
1604 
1605 
1606 template <typename ImplementationTraits>
1607 inline void DeviceContextBase<ImplementationTraits>::PrepareCommittedResources(CommittedShaderResources& Resources, Uint32& DvpCompatibleSRBCount)
1608 {
1609  const auto SignCount = m_pPipelineState->GetResourceSignatureCount();
1610 
1611  Resources.ActiveSRBMask = 0;
1612  for (Uint32 i = 0; i < SignCount; ++i)
1613  {
1614  const auto* pSignature = m_pPipelineState->GetResourceSignature(i);
1615  if (pSignature == nullptr || pSignature->GetTotalResourceCount() == 0)
1616  continue;
1617 
1618  Resources.ActiveSRBMask |= 1u << i;
1619  }
1620 
1621  DvpCompatibleSRBCount = 0;
1622 
1623 #ifdef DILIGENT_DEVELOPMENT
1624  // Layout compatibility means that descriptor sets can be bound to a command buffer
1625  // for use by any pipeline created with a compatible pipeline layout, and without having bound
1626  // a particular pipeline first. It also means that descriptor sets can remain valid across
1627  // a pipeline change, and the same resources will be accessible to the newly bound pipeline.
1628  // (14.2.2. Pipeline Layouts, clause 'Pipeline Layout Compatibility')
1629  // https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#descriptorsets-compatibility
1630 
1631  // Find the number of SRBs compatible with signatures in the current pipeline
1632  for (; DvpCompatibleSRBCount < SignCount; ++DvpCompatibleSRBCount)
1633  {
1634  const auto pSRB = Resources.SRBs[DvpCompatibleSRBCount].Lock();
1635 
1636  const auto* pPSOSign = m_pPipelineState->GetResourceSignature(DvpCompatibleSRBCount);
1637  const auto* pSRBSign = pSRB ? pSRB->GetSignature() : nullptr;
1638 
1639  if ((pPSOSign == nullptr || pPSOSign->GetTotalResourceCount() == 0) !=
1640  (pSRBSign == nullptr || pSRBSign->GetTotalResourceCount() == 0))
1641  {
1642  // One signature is null or empty while the other is not - SRB is not compatible with the PSO.
1643  break;
1644  }
1645 
1646  if (pPSOSign != nullptr && pSRBSign != nullptr && pPSOSign->IsIncompatibleWith(*pSRBSign))
1647  {
1648  // Signatures are incompatible
1649  break;
1650  }
1651  }
1652 
1653  // Unbind incompatible shader resources
1654  // A consequence of layout compatibility is that when the implementation compiles a pipeline
1655  // layout and maps pipeline resources to implementation resources, the mechanism for set N
1656  // should only be a function of sets [0..N].
1657  for (Uint32 sign = DvpCompatibleSRBCount; sign < SignCount; ++sign)
1658  {
1659  Resources.Set(sign, nullptr);
1660  }
1661 
1662  Resources.ResourcesValidated = false;
1663 #endif
1664 }
1665 
1666 #ifdef DILIGENT_DEVELOPMENT
1667 
1668 template <typename ImplementationTraits>
1670 {
1671  if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0)
1672  return;
1673 
1674  DEV_CHECK_ERR(m_pPipelineState, "Draw command arguments are invalid: no pipeline state is bound.");
1675 
1676  DEV_CHECK_ERR(m_pPipelineState->GetDesc().PipelineType == PIPELINE_TYPE_GRAPHICS,
1677  "Draw command arguments are invalid: pipeline state '", m_pPipelineState->GetDesc().Name, "' is not a graphics pipeline.");
1678 
1679  DEV_CHECK_ERR(VerifyDrawAttribs(Attribs), "DrawAttribs are invalid");
1680 }
1681 
1682 template <typename ImplementationTraits>
1684 {
1685  if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0)
1686  return;
1687 
1688  DEV_CHECK_ERR(m_pPipelineState, "DrawIndexed command arguments are invalid: no pipeline state is bound.");
1689 
1690  DEV_CHECK_ERR(m_pPipelineState->GetDesc().PipelineType == PIPELINE_TYPE_GRAPHICS,
1691  "DrawIndexed command arguments are invalid: pipeline state '",
1692  m_pPipelineState->GetDesc().Name, "' is not a graphics pipeline.");
1693 
1694  DEV_CHECK_ERR(m_pIndexBuffer, "DrawIndexed command arguments are invalid: no index buffer is bound.");
1695 
1696  DEV_CHECK_ERR(VerifyDrawIndexedAttribs(Attribs), "DrawIndexedAttribs are invalid");
1697 }
1698 
1699 template <typename ImplementationTraits>
1701 {
1702  if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0)
1703  return;
1704 
1705  DEV_CHECK_ERR(m_pDevice->GetDeviceCaps().Features.MeshShaders, "DrawMesh: mesh shaders are not supported by this device");
1706 
1707  DEV_CHECK_ERR(m_pPipelineState, "DrawMesh command arguments are invalid: no pipeline state is bound.");
1708 
1709  DEV_CHECK_ERR(m_pPipelineState->GetDesc().PipelineType == PIPELINE_TYPE_MESH,
1710  "DrawMesh command arguments are invalid: pipeline state '",
1711  m_pPipelineState->GetDesc().Name, "' is not a mesh pipeline.");
1712 
1713  DEV_CHECK_ERR(VerifyDrawMeshAttribs(m_pDevice->GetProperties().MaxDrawMeshTasksCount, Attribs), "DrawMeshAttribs are invalid");
1714 }
1715 
1716 template <typename ImplementationTraits>
1718  const DrawIndirectAttribs& Attribs,
1719  const IBuffer* pAttribsBuffer) const
1720 {
1721  if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0)
1722  return;
1723 
1724  DEV_CHECK_ERR(m_pPipelineState, "DrawIndirect command arguments are invalid: no pipeline state is bound.");
1725 
1726  DEV_CHECK_ERR(m_pPipelineState->GetDesc().PipelineType == PIPELINE_TYPE_GRAPHICS,
1727  "DrawIndirect command arguments are invalid: pipeline state '",
1728  m_pPipelineState->GetDesc().Name, "' is not a graphics pipeline.");
1729 
1730  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr || Attribs.IndirectAttribsBufferStateTransitionMode != RESOURCE_STATE_TRANSITION_MODE_TRANSITION,
1731  "Resource state transitons are not allowed inside a render pass and may result in an undefined behavior. "
1732  "Do not use RESOURCE_STATE_TRANSITION_MODE_TRANSITION or end the render pass first.");
1733 
1734  DEV_CHECK_ERR(VerifyDrawIndirectAttribs(Attribs, pAttribsBuffer), "DrawIndirectAttribs are invalid");
1735 }
1736 
1737 template <typename ImplementationTraits>
1739  const DrawIndexedIndirectAttribs& Attribs,
1740  const IBuffer* pAttribsBuffer) const
1741 {
1742  if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0)
1743  return;
1744 
1745  DEV_CHECK_ERR(m_pPipelineState, "DrawIndexedIndirect command arguments are invalid: no pipeline state is bound.");
1746 
1747  DEV_CHECK_ERR(m_pPipelineState->GetDesc().PipelineType == PIPELINE_TYPE_GRAPHICS,
1748  "DrawIndexedIndirect command arguments are invalid: pipeline state '",
1749  m_pPipelineState->GetDesc().Name, "' is not a graphics pipeline.");
1750 
1751  DEV_CHECK_ERR(m_pIndexBuffer, "DrawIndexedIndirect command arguments are invalid: no index buffer is bound.");
1752 
1753  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr || Attribs.IndirectAttribsBufferStateTransitionMode != RESOURCE_STATE_TRANSITION_MODE_TRANSITION,
1754  "Resource state transitons are not allowed inside a render pass and may result in an undefined behavior. "
1755  "Do not use RESOURCE_STATE_TRANSITION_MODE_TRANSITION or end the render pass first.");
1756 
1757  DEV_CHECK_ERR(VerifyDrawIndexedIndirectAttribs(Attribs, pAttribsBuffer), "DrawIndexedIndirectAttribs are invalid");
1758 }
1759 
1760 template <typename ImplementationTraits>
1762  const DrawMeshIndirectAttribs& Attribs,
1763  const IBuffer* pAttribsBuffer) const
1764 {
1765  if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0)
1766  return;
1767 
1768  DEV_CHECK_ERR(m_pDevice->GetDeviceCaps().Features.MeshShaders, "DrawMeshIndirect: mesh shaders are not supported by this device");
1769 
1770  DEV_CHECK_ERR(m_pPipelineState, "DrawMeshIndirect command arguments are invalid: no pipeline state is bound.");
1771 
1772  DEV_CHECK_ERR(m_pPipelineState->GetDesc().PipelineType == PIPELINE_TYPE_MESH,
1773  "DrawMeshIndirect command arguments are invalid: pipeline state '",
1774  m_pPipelineState->GetDesc().Name, "' is not a mesh pipeline.");
1775 
1776  DEV_CHECK_ERR(VerifyDrawMeshIndirectAttribs(Attribs, pAttribsBuffer), "DrawMeshIndirectAttribs are invalid");
1777 }
1778 
1779 template <typename ImplementationTraits>
1781  const DrawMeshIndirectCountAttribs& Attribs,
1782  const IBuffer* pAttribsBuffer,
1783  const IBuffer* pCountBuff) const
1784 {
1785  if ((Attribs.Flags & DRAW_FLAG_VERIFY_DRAW_ATTRIBS) == 0)
1786  return;
1787 
1788  DEV_CHECK_ERR(m_pDevice->GetDeviceCaps().Features.MeshShaders, "DrawMeshIndirectCount: mesh shaders are not supported by this device");
1789 
1790  DEV_CHECK_ERR(m_pPipelineState, "DrawMeshIndirectCount command arguments are invalid: no pipeline state is bound.");
1791 
1792  DEV_CHECK_ERR(m_pPipelineState->GetDesc().PipelineType == PIPELINE_TYPE_MESH,
1793  "DrawMeshIndirectCount command arguments are invalid: pipeline state '",
1794  m_pPipelineState->GetDesc().Name, "' is not a mesh pipeline.");
1795 
1796  DEV_CHECK_ERR(VerifyDrawMeshIndirectCountAttribs(Attribs, pAttribsBuffer, pCountBuff, DrawMeshIndirectCommandStride),
1797  "DrawMeshIndirectCountAttribs are invalid");
1798 }
1799 
1800 template <typename ImplementationTraits>
1802 {
1803  DEV_CHECK_ERR(m_pPipelineState, "No pipeline state is bound");
1804 
1805  const auto& PSODesc = m_pPipelineState->GetDesc();
1806  DEV_CHECK_ERR(PSODesc.IsAnyGraphicsPipeline(),
1807  "Pipeline state '", PSODesc.Name, "' is not a graphics pipeline");
1808 
1809  TEXTURE_FORMAT BoundRTVFormats[8] = {TEX_FORMAT_UNKNOWN};
1810  TEXTURE_FORMAT BoundDSVFormat = TEX_FORMAT_UNKNOWN;
1811 
1812  for (Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt)
1813  {
1814  if (auto* pRT = m_pBoundRenderTargets[rt].RawPtr())
1815  BoundRTVFormats[rt] = pRT->GetDesc().Format;
1816  else
1817  BoundRTVFormats[rt] = TEX_FORMAT_UNKNOWN;
1818  }
1819 
1820  BoundDSVFormat = m_pBoundDepthStencil ? m_pBoundDepthStencil->GetDesc().Format : TEX_FORMAT_UNKNOWN;
1821 
1822  const auto& GraphicsPipeline = m_pPipelineState->GetGraphicsPipelineDesc();
1823  if (GraphicsPipeline.NumRenderTargets != m_NumBoundRenderTargets)
1824  {
1825  LOG_WARNING_MESSAGE("The number of currently bound render targets (", m_NumBoundRenderTargets,
1826  ") does not match the number of outputs specified by the PSO '", PSODesc.Name,
1827  "' (", Uint32{GraphicsPipeline.NumRenderTargets}, ").");
1828  }
1829 
1830  if (BoundDSVFormat != GraphicsPipeline.DSVFormat)
1831  {
1832  LOG_WARNING_MESSAGE("Currently bound depth-stencil buffer format (", GetTextureFormatAttribs(BoundDSVFormat).Name,
1833  ") does not match the DSV format specified by the PSO '", PSODesc.Name,
1834  "' (", GetTextureFormatAttribs(GraphicsPipeline.DSVFormat).Name, ").");
1835  }
1836 
1837  for (Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt)
1838  {
1839  auto BoundFmt = BoundRTVFormats[rt];
1840  auto PSOFmt = GraphicsPipeline.RTVFormats[rt];
1841  if (BoundFmt != PSOFmt)
1842  {
1843  LOG_WARNING_MESSAGE("Render target bound to slot ", rt, " (", GetTextureFormatAttribs(BoundFmt).Name,
1844  ") does not match the RTV format specified by the PSO '", PSODesc.Name,
1845  "' (", GetTextureFormatAttribs(PSOFmt).Name, ").");
1846  }
1847  }
1848 }
1849 
1850 
1851 
1852 template <typename ImplementationTraits>
1854 {
1855  DEV_CHECK_ERR(m_pPipelineState, "DispatchCompute command arguments are invalid: no pipeline state is bound.");
1856 
1857  DEV_CHECK_ERR(m_pPipelineState->GetDesc().PipelineType == PIPELINE_TYPE_COMPUTE,
1858  "DispatchCompute command arguments are invalid: pipeline state '", m_pPipelineState->GetDesc().Name,
1859  "' is not a compute pipeline.");
1860 
1861  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr,
1862  "DispatchCompute command must be performed outside of render pass");
1863 
1864  DEV_CHECK_ERR(VerifyDispatchComputeAttribs(Attribs), "DispatchComputeAttribs attribs");
1865 }
1866 
1867 template <typename ImplementationTraits>
1869  const DispatchComputeIndirectAttribs& Attribs,
1870  const IBuffer* pAttribsBuffer) const
1871 {
1872  DEV_CHECK_ERR(m_pPipelineState, "DispatchComputeIndirect command arguments are invalid: no pipeline state is bound.");
1873 
1874  DEV_CHECK_ERR(m_pPipelineState->GetDesc().PipelineType == PIPELINE_TYPE_COMPUTE,
1875  "DispatchComputeIndirect command arguments are invalid: pipeline state '",
1876  m_pPipelineState->GetDesc().Name, "' is not a compute pipeline.");
1877 
1878  DEV_CHECK_ERR(m_pActiveRenderPass == nullptr, "DispatchComputeIndirect command must be performed outside of render pass");
1879 
1880  DEV_CHECK_ERR(VerifyDispatchComputeIndirectAttribs(Attribs, pAttribsBuffer), "DispatchComputeIndirectAttribs are invalid");
1881 }
1882 
1883 
1884 template <typename ImplementationTraits>
1886 {
1887  DEV_CHECK_ERR(VerifyStateTransitionDesc(m_pDevice, Barrier), "StateTransitionDesc are invalid");
1888 }
1889 
1890 template <typename ImplementationTraits>
1892  const TextureImplType& Texture,
1893  RESOURCE_STATE RequiredState,
1894  const char* OperationName) const
1895 {
1896  if (Texture.IsInKnownState() && !Texture.CheckState(RequiredState))
1897  {
1898  LOG_ERROR_MESSAGE(OperationName, " requires texture '", Texture.GetDesc().Name, "' to be transitioned to ", GetResourceStateString(RequiredState),
1899  " state. Actual texture state: ", GetResourceStateString(Texture.GetState()),
1900  ". Use appropriate state transiton flags or explicitly transition the texture using IDeviceContext::TransitionResourceStates() method.");
1901  }
1902 }
1903 
1904 template <typename ImplementationTraits>
1906  const BufferImplType& Buffer,
1907  RESOURCE_STATE RequiredState,
1908  const char* OperationName) const
1909 {
1910  if (Buffer.IsInKnownState() && !Buffer.CheckState(RequiredState))
1911  {
1912  LOG_ERROR_MESSAGE(OperationName, " requires buffer '", Buffer.GetDesc().Name, "' to be transitioned to ", GetResourceStateString(RequiredState),
1913  " state. Actual buffer state: ", GetResourceStateString(Buffer.GetState()),
1914  ". Use appropriate state transiton flags or explicitly transition the buffer using IDeviceContext::TransitionResourceStates() method.");
1915  }
1916 }
1917 
1918 template <typename ImplementationTraits>
1920  const BottomLevelASType& BLAS,
1921  RESOURCE_STATE RequiredState,
1922  const char* OperationName) const
1923 {
1924  if (BLAS.IsInKnownState() && !BLAS.CheckState(RequiredState))
1925  {
1926  LOG_ERROR_MESSAGE(OperationName, " requires BLAS '", BLAS.GetDesc().Name, "' to be transitioned to ", GetResourceStateString(RequiredState),
1927  " state. Actual BLAS state: ", GetResourceStateString(BLAS.GetState()),
1928  ". Use appropriate state transiton flags or explicitly transition the BLAS using IDeviceContext::TransitionResourceStates() method.");
1929  }
1930 }
1931 
1932 template <typename ImplementationTraits>
1934  const TopLevelASType& TLAS,
1935  RESOURCE_STATE RequiredState,
1936  const char* OperationName) const
1937 {
1938  if (TLAS.IsInKnownState() && !TLAS.CheckState(RequiredState))
1939  {
1940  LOG_ERROR_MESSAGE(OperationName, " requires TLAS '", TLAS.GetDesc().Name, "' to be transitioned to ", GetResourceStateString(RequiredState),
1941  " state. Actual TLAS state: ", GetResourceStateString(TLAS.GetState()),
1942  ". Use appropriate state transiton flags or explicitly transition the TLAS using IDeviceContext::TransitionResourceStates() method.");
1943  }
1944 }
1945 
1946 template <typename ImplementationTraits>
1947 void DeviceContextBase<ImplementationTraits>::DvpVerifySRBCompatibility(
1948  CommittedShaderResources& Resources,
1949  std::function<PipelineResourceSignatureImplType*(Uint32)> CustomGetSignature) const
1950 {
1951  DEV_CHECK_ERR(m_pPipelineState, "No PSO is bound in the context");
1952 
1953  const auto SignCount = m_pPipelineState->GetResourceSignatureCount();
1954  for (Uint32 sign = 0; sign < SignCount; ++sign)
1955  {
1956  const auto* const pPSOSign = CustomGetSignature ? CustomGetSignature(sign) : m_pPipelineState->GetResourceSignature(sign);
1957  if (pPSOSign == nullptr || pPSOSign->GetTotalResourceCount() == 0)
1958  continue; // Skip null and empty signatures
1959 
1960  VERIFY_EXPR(sign < MAX_RESOURCE_SIGNATURES);
1961  VERIFY_EXPR(pPSOSign->GetDesc().BindingIndex == sign);
1962 
1963  const auto pSRB = Resources.SRBs[sign].Lock();
1964  const auto* pCache = Resources.ResourceCaches[sign];
1965  if (pCache != nullptr)
1966  {
1967  DEV_CHECK_ERR(pSRB, "Shader resource cache pointer at index ", sign,
1968  " is non-null, but the corresponding SRB is null. This indicates that the SRB has been released while still "
1969  "being used by the context commands. This usage is invalid. A resource must be released only after "
1970  "the last command that uses it.");
1971  }
1972  else
1973  {
1974  VERIFY(!pSRB, "Shader resource cache pointer is null, but SRB is not null. This is unexpected and is likely a bug.");
1975  }
1976 
1977  DEV_CHECK_ERR(pSRB, "Pipeline state '", m_pPipelineState->GetDesc().Name, "' requires SRB at index ", sign,
1978  ", but none is bound in the device context. Did you call CommitShaderResources()?");
1979 
1980  VERIFY_EXPR(pCache == &pSRB->GetResourceCache());
1981 
1982  const auto* const pSRBSign = pSRB->GetSignature();
1983  DEV_CHECK_ERR(pPSOSign->IsCompatibleWith(pSRBSign), "Shader resource binding at index ", sign, " with signature '",
1984  pSRBSign->GetDesc().Name, "' is not compatible with the signature in PSO '",
1985  m_pPipelineState->GetDesc().Name, "'.");
1986  }
1987 }
1988 
1989 #endif // DILIGENT_DEVELOPMENT
1990 
1991 } // namespace Diligent
Diligent::MAP_FLAGS
MAP_FLAGS
Special map flags.
Definition: GraphicsTypes.h:227
Diligent::ITextureView::GetTexture
virtual struct ITexture *METHOD() GetTexture()
Returns the pointer to the referenced texture object.
Diligent::TEXTURE_VIEW_RENDER_TARGET
@ TEXTURE_VIEW_RENDER_TARGET
A texture view will define a render target view that will be used as the target for rendering operati...
Definition: GraphicsTypes.h:285
Diligent::VerifyBuildTLASAttribs
bool VerifyBuildTLASAttribs(const BuildTLASAttribs &Attribs)
Definition: DeviceContextBase.cpp:510
Diligent::USAGE_STAGING
@ USAGE_STAGING
A resource that facilitates transferring data between GPU and CPU. D3D11 Counterpart: D3D11_USAGE_S...
Definition: GraphicsTypes.h:167
ObjectBase.hpp
Diligent::DeviceContextBase::SetRenderTargets
bool SetRenderTargets(Uint32 NumRenderTargets, ITextureView *ppRenderTargets[], ITextureView *pDepthStencil)
Caches the render target and depth stencil views. Returns true if any view is different from the cach...
Definition: DeviceContextBase.hpp:708
Diligent::DeviceContextBase< EngineGLImplTraits >::QueryImplType
typename EngineGLImplTraits ::QueryImplType QueryImplType
Definition: DeviceContextBase.hpp:118
Diligent::uint
uint32_t uint
Definition: BasicMath.hpp:1826
Diligent::IReferenceCounters
Base interface for a reference counter object that stores the number of strong and weak references an...
Definition: ReferenceCounters.h:44
Diligent::DeviceContextBase::DvpVerifyRenderTargets
bool DvpVerifyRenderTargets() const
Definition: DeviceContextBase.hpp:383
Diligent::DeviceContextBase::GetFrameNumber
virtual Uint64 GetFrameNumber() const override final
Definition: DeviceContextBase.hpp:235
LOG_ERROR_MESSAGE
#define LOG_ERROR_MESSAGE(...)
Definition: Errors.hpp:122
GraphicsAccessories.hpp
Diligent::PVoid
void * PVoid
Definition: BasicTypes.h:56
Diligent::CopyTLASAttribs::pSrc
ITopLevelAS * pSrc
Source top-level AS. Access to the TLAS must be externally synchronized.
Definition: DeviceContext.h:1192
Diligent::TextureDesc
struct TextureDesc TextureDesc
Definition: Texture.h:162
Diligent::UpdateIndirectRTBufferAttribs
This structure is used by IDeviceContext::UpdateSBT().
Definition: DeviceContext.h:1303
Diligent::TraceRaysIndirectAttribs
This structure is used by IDeviceContext::TraceRaysIndirect().
Definition: DeviceContext.h:1284
Diligent::IShaderResourceBinding
Shader resource binding interface.
Definition: ShaderResourceBinding.h:58
Diligent::DeviceContextBase::m_Viewports
Viewport m_Viewports[MAX_VIEWPORTS]
Current viewports.
Definition: DeviceContextBase.hpp:437
Diligent::DeviceContextBase::BeginQuery
void BeginQuery(IQuery *pQuery, int)
Definition: DeviceContextBase.hpp:1250
Diligent::DeviceContextBase::EndQuery
void EndQuery(IQuery *pQuery, int)
Definition: DeviceContextBase.hpp:1263
Diligent::TraceRaysAttribs
This structure is used by IDeviceContext::TraceRays().
Definition: DeviceContext.h:1267
Diligent::DeviceContextBase::~DeviceContextBase
~DeviceContextBase()
Definition: DeviceContextBase.hpp:139
Diligent::DeviceContextBase::ResolveTextureSubresource
virtual void ResolveTextureSubresource(ITexture *pSrcTexture, ITexture *pDstTexture, const ResolveTextureSubresourceAttribs &ResolveAttribs) override=0
Definition: DeviceContextBase.hpp:1457
Diligent::DeviceContextBase< EngineGLImplTraits >::ShaderResourceCacheImplType
typename EngineGLImplTraits ::ShaderResourceCacheImplType ShaderResourceCacheImplType
Definition: DeviceContextBase.hpp:124
DeviceObjectBase.hpp
Diligent::TraceRaysIndirectAttribs
struct TraceRaysIndirectAttribs TraceRaysIndirectAttribs
Definition: DeviceContext.h:1299
Diligent::BeginRenderPassAttribs
BeginRenderPass command attributes.
Definition: DeviceContext.h:731
Diligent::VerifyDrawMeshIndirectCountAttribs
bool VerifyDrawMeshIndirectCountAttribs(const DrawMeshIndirectCountAttribs &Attribs, const IBuffer *pAttribsBuffer, const IBuffer *pCountBuff, Uint32 IndirectCmdStride)
Definition: DeviceContextBase.cpp:134
Diligent::VerifyDrawMeshAttribs
bool VerifyDrawMeshAttribs(Uint32 MaxDrawMeshTasksCount, const DrawMeshAttribs &Attribs)
Definition: DeviceContextBase.cpp:78
Diligent::IShaderBindingTable
Shader binding table interface.
Definition: ShaderBindingTable.h:93
Diligent::DrawMeshIndirectCountAttribs
Defines the mesh indirect draw count command attributes.
Definition: DeviceContext.h:440
Diligent::VerifyDrawIndexedAttribs
bool VerifyDrawIndexedAttribs(const DrawIndexedAttribs &Attribs)
Definition: DeviceContextBase.cpp:64
Diligent::IPipelineState
Pipeline state interface.
Definition: PipelineState.h:505
Diligent::DeviceContextBase::UpdateTexture
virtual void UpdateTexture(ITexture *pTexture, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData, RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, RESOURCE_STATE_TRANSITION_MODE TextureTransitionMode) override=0
Base implementaiton of IDeviceContext::UpdateData(); validates input parameters.
Definition: DeviceContextBase.hpp:1389
Diligent::RESOURCE_STATE_TRANSITION_MODE
RESOURCE_STATE_TRANSITION_MODE
Defines resource state transition mode performed by various commands.
Definition: DeviceContext.h:136
Diligent::DRAW_FLAG_VERIFY_DRAW_ATTRIBS
@ DRAW_FLAG_VERIFY_DRAW_ATTRIBS
Verify correctness of parameters passed to the draw command.
Definition: DeviceContext.h:79
Diligent::DrawMeshIndirectAttribs
struct DrawMeshIndirectAttribs DrawMeshIndirectAttribs
Definition: DeviceContext.h:434
Flags
Uint32 Flags
Definition: DXBCUtils.cpp:71
Diligent::DeviceContextBase::BuildTLAS
void BuildTLAS(const BuildTLASAttribs &Attribs, int) const
Definition: DeviceContextBase.hpp:1483
Diligent::DeviceContextBase::CommittedShaderResources::MakeAllStale
void MakeAllStale()
Definition: DeviceContextBase.hpp:301
Diligent::DeviceContextBase::DvpVerifyBLASState
bool DvpVerifyBLASState(const BottomLevelASType &BLAS, RESOURCE_STATE RequiredState, const char *OperationName) const
Definition: DeviceContextBase.hpp:387
Diligent::IPipelineState::GetDesc
virtual const PipelineStateDesc &METHOD() GetDesc() const override=0
Returns the pipeline description used to create the object.
Diligent::DispatchComputeIndirectAttribs
struct DispatchComputeIndirectAttribs DispatchComputeIndirectAttribs
Definition: DeviceContext.h:543
Diligent::IObject
Base interface for all dynamic objects in the engine.
Definition: Object.h:41
Diligent::DeviceContextBase::m_VertexStreams
VertexStreamInfo< BufferImplType > m_VertexStreams[MAX_BUFFER_SLOTS]
Vertex streams. Every stream holds strong reference to the buffer.
Definition: DeviceContextBase.hpp:412
Diligent::Uint64
uint64_t Uint64
64-bit unsigned integer
Definition: BasicTypes.h:50
Diligent::DeviceContextBase::CommittedShaderResources::StaleSRBMask
SRBMaskType StaleSRBMask
Definition: DeviceContextBase.hpp:281
Diligent::MAP_FLAG_DISCARD
@ MAP_FLAG_DISCARD
Previous contents of the resource will be undefined. This flag is only compatible with MAP_WRITE D3D...
Definition: GraphicsTypes.h:241
Diligent::WriteBLASCompactedSizeAttribs
This structure is used by IDeviceContext::WriteBLASCompactedSize().
Definition: DeviceContext.h:1217
Diligent::ITextureView::GetDesc
virtual const TextureViewDesc &METHOD() GetDesc() const override=0
Returns the texture view description used to create the object.
Diligent::Float32
float Float32
32-bit float
Definition: BasicTypes.h:43
UNEXPECTED
#define UNEXPECTED(...)
Definition: DebugUtilities.hpp:77
Diligent::USAGE_UNIFIED
@ USAGE_UNIFIED
A resource residing in a unified memory (e.g. memory shared between CPU and GPU), that can be read an...
Definition: GraphicsTypes.h:179
Diligent::DeviceContextBase::ResetRenderTargets
virtual void ResetRenderTargets()
Definition: DeviceContextBase.hpp:1038
Diligent::MAP_FLAG_NO_OVERWRITE
@ MAP_FLAG_NO_OVERWRITE
The system will not synchronize pending operations before mapping the buffer. It is responsibility of...
Definition: GraphicsTypes.h:247
Diligent::WriteTLASCompactedSizeAttribs
This structure is used by IDeviceContext::WriteTLASCompactedSize().
Definition: DeviceContext.h:1242
Diligent::DeviceContextBase::UpdateBuffer
virtual void UpdateBuffer(IBuffer *pBuffer, Uint32 Offset, Uint32 Size, const void *pData, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override=0
Base implementation of IDeviceContext::UpdateBuffer(); validates input parameters.
Definition: DeviceContextBase.hpp:1273
Diligent::DispatchComputeAttribs
struct DispatchComputeAttribs DispatchComputeAttribs
Definition: DeviceContext.h:517
Diligent::DeviceContextBase::CommittedShaderResources::Set
void Set(Uint32 Index, ShaderResourceBindingImplType *pSRB)
Definition: DeviceContextBase.hpp:283
Diligent::DeviceContextBase::m_FramebufferWidth
Uint32 m_FramebufferWidth
Width of the currently bound framebuffer.
Definition: DeviceContextBase.hpp:452
Diligent::IShaderBindingTable::GetDesc
virtual const ShaderBindingTableDesc & GetDesc() const override=0
Returns the shader binding table description that was used to create the object.
Diligent::DeviceContextBase< EngineGLImplTraits >::ShaderBindingTableImplType
typename EngineGLImplTraits ::ShaderBindingTableImplType ShaderBindingTableImplType
Definition: DeviceContextBase.hpp:123
Diligent::DeviceContextBase::TraceRaysIndirectCommandSize
static constexpr Uint32 TraceRaysIndirectCommandSize
Definition: DeviceContextBase.hpp:406
DeviceContext.h
Diligent::DrawIndexedAttribs
struct DrawIndexedAttribs DrawIndexedAttribs
Definition: DeviceContext.h:285
Diligent::ITextureView
Texture view interface.
Definition: TextureView.h:202
Diligent::DeviceContextBase::DvpVerifyBufferState
bool DvpVerifyBufferState(const BufferImplType &Buffer, RESOURCE_STATE RequiredState, const char *OperationName) const
Definition: DeviceContextBase.hpp:386
DebugUtilities.hpp
Diligent::DrawMeshAttribs
Defines the mesh draw command attributes.
Definition: DeviceContext.h:376
Diligent::DeviceContextBase::DvpVerifyDrawIndexedIndirectArguments
bool DvpVerifyDrawIndexedIndirectArguments(const DrawIndexedIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer) const
Definition: DeviceContextBase.hpp:376
Diligent::USAGE_DYNAMIC
@ USAGE_DYNAMIC
A resource that can be read by the GPU and written at least once per frame by the CPU....
Definition: GraphicsTypes.h:161
DEV_CHECK_ERR
#define DEV_CHECK_ERR(...)
Definition: DebugUtilities.hpp:90
Diligent::DeviceContextBase::HasActiveRenderPass
bool HasActiveRenderPass() const
Definition: DeviceContextBase.hpp:260
Diligent::Box
Box.
Definition: GraphicsTypes.h:2407
Diligent::MappedTextureSubresource
Definition: Texture.h:245
Diligent::DeviceContextBase::DvpVerifyDrawMeshIndirectArguments
bool DvpVerifyDrawMeshIndirectArguments(const DrawMeshIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer) const
Definition: DeviceContextBase.hpp:377
Diligent::DeviceContextBase::ClearStateCache
void ClearStateCache()
Clears all cached resources.
Definition: DeviceContextBase.hpp:919
Diligent::ValidateMapTextureParams
void ValidateMapTextureParams(const TextureDesc &TexDesc, Uint32 MipLevel, Uint32 ArraySlice, MAP_TYPE MapType, Uint32 MapFlags, const Box *pMapRegion)
Validates map texture command paramters.
Definition: TextureBase.cpp:291
Diligent::DeviceContextBase< EngineGLImplTraits >::ShaderResourceBindingImplType
typename EngineGLImplTraits ::ShaderResourceBindingImplType ShaderResourceBindingImplType
Definition: DeviceContextBase.hpp:116
Diligent::DeviceContextBase< EngineGLImplTraits >::BufferImplType
typename EngineGLImplTraits ::BufferImplType BufferImplType
Definition: DeviceContextBase.hpp:113
Diligent::StateTransitionDesc
struct StateTransitionDesc StateTransitionDesc
Definition: DeviceContext.h:1444
Diligent::GetTexViewTypeLiteralName
const Char * GetTexViewTypeLiteralName(TEXTURE_VIEW_TYPE ViewType)
Returns the literal name of a texture view type. For instance, for a shader resource view,...
Definition: GraphicsAccessories.cpp:408
Diligent::DeviceContextBase::m_IndexDataStartOffset
Uint32 m_IndexDataStartOffset
Offset from the beginning of the index buffer to the start of the index data, in bytes.
Definition: DeviceContextBase.hpp:428
Diligent::DeviceContextBase< EngineGLImplTraits >::TextureViewImplType
typename EngineGLImplTraits ::TextureViewImplType TextureViewImplType
Definition: DeviceContextBase.hpp:117
Diligent::VerifyTraceRaysIndirectAttribs
bool VerifyTraceRaysIndirectAttribs(const IRenderDevice *pDevice, const TraceRaysIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer, Uint32 SBTSize)
Definition: DeviceContextBase.cpp:797
Diligent::DeviceContextBase::SetViewports
void SetViewports(Uint32 NumViewports, const Viewport *pViewports, Uint32 &RTWidth, Uint32 &RTHeight)
Caches the viewports.
Definition: DeviceContextBase.hpp:641
Diligent::DeviceContextBase::m_NumScissorRects
Uint32 m_NumScissorRects
Number of current scissor rects.
Definition: DeviceContextBase.hpp:444
ValidatedCast.hpp
Diligent::Viewport
struct Viewport Viewport
Definition: DeviceContext.h:632
Diligent::ObjectBase
Template class implementing base functionality for an object.
Definition: ObjectBase.hpp:66
Diligent::DeviceContextBase::SetSubpassRenderTargets
bool SetSubpassRenderTargets()
Initializes render targets for the current subpass.
Definition: DeviceContextBase.hpp:823
Diligent::ResolveTextureSubresourceAttribs
struct ResolveTextureSubresourceAttribs ResolveTextureSubresourceAttribs
Definition: DeviceContext.h:574
Diligent::CopyBLASAttribs
struct CopyBLASAttribs CopyBLASAttribs
Definition: DeviceContext.h:1184
Diligent::DeviceContextBase::m_StencilRef
Uint32 m_StencilRef
Current stencil reference value.
Definition: DeviceContextBase.hpp:431
Diligent::IBuffer
Buffer interface.
Definition: Buffer.h:187
std::min
Diligent::Vector2< T > min(const Diligent::Vector2< T > &Left, const Diligent::Vector2< T > &Right)
Definition: BasicMath.hpp:2289
Diligent::DeviceContextBase::SetBlendFactors
bool SetBlendFactors(const float *BlendFactors, int Dummy)
Definition: DeviceContextBase.hpp:617
Diligent::CopyTextureAttribs::pSrcTexture
ITexture * pSrcTexture
Source texture to copy data from.
Definition: DeviceContext.h:675
Diligent::TEX_FORMAT_UNKNOWN
@ TEX_FORMAT_UNKNOWN
Unknown format.
Definition: GraphicsTypes.h:331
Diligent::BeginRenderPassAttribs
struct BeginRenderPassAttribs BeginRenderPassAttribs
Definition: DeviceContext.h:763
Diligent::Rect
struct Rect Rect
Definition: DeviceContext.h:666
Diligent::DeviceContextBase::CommitShaderResources
void CommitShaderResources(IShaderResourceBinding *pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, int)
Base implementation of IDeviceContext::CommitShaderResources(); validates parameters.
Definition: DeviceContextBase.hpp:553
Diligent::DeviceContextBase< EngineGLImplTraits >::RenderPassImplType
typename EngineGLImplTraits ::RenderPassImplType RenderPassImplType
Definition: DeviceContextBase.hpp:120
Diligent::DeviceContextBase::m_SubpassIndex
Uint32 m_SubpassIndex
Current subpass index.
Definition: DeviceContextBase.hpp:471
VulkanUtilities::VulkanHandleTypeId::Buffer
@ Buffer
Diligent::DeviceContextBase::SetStencilRef
bool SetStencilRef(Uint32 StencilRef, int Dummy)
Definition: DeviceContextBase.hpp:630
Diligent::DeviceContextBase::BeginRenderPass
virtual void BeginRenderPass(const BeginRenderPassAttribs &Attribs) override=0
Definition: DeviceContextBase.hpp:1061
Diligent::ValidateUpdateTextureParams
void ValidateUpdateTextureParams(const TextureDesc &TexDesc, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData)
Validates update texture command paramters.
Definition: TextureBase.cpp:226
Diligent::QueryDesc::Type
enum QUERY_TYPE Type
Query type, see Diligent::QUERY_TYPE.
Definition: Query.h:153
Diligent::DeviceContextBase::m_FrameNumber
Uint64 m_FrameNumber
Definition: DeviceContextBase.hpp:478
Diligent::IRenderDevice
Render device interface.
Definition: RenderDevice.h:75
Diligent::CopyTLASAttribs
struct CopyTLASAttribs CopyTLASAttribs
Definition: DeviceContext.h:1213
Diligent::DeviceContextBase::EndFrame
void EndFrame()
Definition: DeviceContextBase.hpp:340
Diligent::StateTransitionDesc
Resource state transition barrier description.
Definition: DeviceContext.h:1333
Diligent::VerifyWriteTLASCompactedSizeAttribs
bool VerifyWriteTLASCompactedSizeAttribs(const IRenderDevice *pDevice, const WriteTLASCompactedSizeAttribs &Attribs)
Definition: DeviceContextBase.cpp:754
Diligent::BuildTLASAttribs
struct BuildTLASAttribs BuildTLASAttribs
Definition: DeviceContext.h:1155
Diligent::DeviceContextBase::SetPipelineState
void SetPipelineState(PipelineStateImplType *pPipelineState, int)
Definition: DeviceContextBase.hpp:545
Diligent::GetResourceStateString
String GetResourceStateString(RESOURCE_STATE State)
Definition: GraphicsAccessories.cpp:1080
Diligent::VertexStreamInfo::Offset
Uint32 Offset
Offset in bytes.
Definition: DeviceContextBase.hpp:95
Diligent::DeviceContextBase< EngineGLImplTraits >::DeviceImplType
typename EngineGLImplTraits ::RenderDeviceImplType DeviceImplType
Definition: DeviceContextBase.hpp:112
Diligent::DeviceContextBase::GetViewports
void GetViewports(Uint32 &NumViewports, Viewport *pViewports)
Returns currently set viewports.
Definition: DeviceContextBase.hpp:673
LOG_INFO_MESSAGE
#define LOG_INFO_MESSAGE(...)
Definition: Errors.hpp:124
Diligent::DeviceContextBase::DvpVerifyDrawIndexedArguments
bool DvpVerifyDrawIndexedArguments(const DrawIndexedAttribs &Attribs) const
Definition: DeviceContextBase.hpp:373
Diligent::VerifyDrawAttribs
bool VerifyDrawAttribs(const DrawAttribs &Attribs)
Definition: DeviceContextBase.cpp:53
Diligent::DeviceContextBase::m_pActiveRenderPass
RefCntAutoPtr< RenderPassImplType > m_pActiveRenderPass
Strong reference to the render pass.
Definition: DeviceContextBase.hpp:468
Diligent::SET_VERTEX_BUFFERS_FLAGS
SET_VERTEX_BUFFERS_FLAGS
Defines allowed flags for IDeviceContext::SetVertexBuffers() function.
Definition: DeviceContext.h:578
Diligent::DeviceContextBase::TObjectBase
ObjectBase< BaseInterface > TObjectBase
Definition: DeviceContextBase.hpp:111
Diligent::DeviceContextBase::m_FramebufferSamples
Uint32 m_FramebufferSamples
Number of samples in the currently bound framebuffer.
Definition: DeviceContextBase.hpp:458
Diligent::RESOURCE_STATE_TRANSITION_MODE_TRANSITION
@ RESOURCE_STATE_TRANSITION_MODE_TRANSITION
Transition resources to the states required by the specific command. Resources in unknown state are i...
Definition: DeviceContext.h:152
Diligent::DeviceContextBase::NextSubpass
virtual void NextSubpass() override=0
Definition: DeviceContextBase.hpp:1113
Diligent::DeviceContextBase::m_pIndexBuffer
RefCntAutoPtr< BufferImplType > m_pIndexBuffer
Strong reference to the bound index buffer. Use final buffer implementation type to avoid virtual cal...
Definition: DeviceContextBase.hpp:425
Diligent::TextureFormatAttribs::Name
const Char * Name
Literal texture format name (for instance, for TEX_FORMAT_RGBA8_UNORM format, this will be "TEX_FORMA...
Definition: GraphicsTypes.h:2487
Diligent::ResolveTextureSubresourceAttribs
Describes multi-sampled texture resolve command arguments.
Definition: DeviceContext.h:549
Diligent::DispatchComputeIndirectAttribs
Describes dispatch command arguments.
Definition: DeviceContext.h:523
Diligent::DeviceContextBase::m_BlendFactors
Float32 m_BlendFactors[4]
Curent blend factors.
Definition: DeviceContextBase.hpp:434
Diligent::PIPELINE_TYPE_MESH
@ PIPELINE_TYPE_MESH
Mesh pipeline, which is used by IDeviceContext::DrawMesh(), IDeviceContext::DrawMeshIndirect().
Definition: PipelineState.h:305
Diligent::DeviceContextBase::UnbindTextureFromFramebuffer
bool UnbindTextureFromFramebuffer(TextureImplType *pTexture, bool bShowMessage)
Checks if a texture is bound as a render target or depth-stencil buffer and resets render targets if ...
Definition: DeviceContextBase.hpp:984
Diligent::DeviceContextBase::m_FramebufferHeight
Uint32 m_FramebufferHeight
Height of the currently bound framebuffer.
Definition: DeviceContextBase.hpp:454
Diligent::DeviceContextBase::DvpVerifyTextureState
bool DvpVerifyTextureState(const TextureImplType &Texture, RESOURCE_STATE RequiredState, const char *OperationName) const
Definition: DeviceContextBase.hpp:385
Diligent::DeviceContextBase::InvalidateState
virtual void InvalidateState() override=0
Definition: DeviceContextBase.hpp:566
Diligent::MAP_READ_WRITE
@ MAP_READ_WRITE
The resource is mapped for reading and writing. D3D11 counterpart: D3D11_MAP_READ_WRITE....
Definition: GraphicsTypes.h:218
Diligent::DeviceContextBase::CommittedShaderResources::ResourceCaches
std::array< ShaderResourceCacheImplType *, MAX_RESOURCE_SIGNATURES > ResourceCaches
Definition: DeviceContextBase.hpp:267
Diligent::DrawIndexedIndirectAttribs
Defines the indexed indirect draw command attributes.
Definition: DeviceContext.h:330
Diligent::WriteTLASCompactedSizeAttribs
struct WriteTLASCompactedSizeAttribs WriteTLASCompactedSizeAttribs
Definition: DeviceContext.h:1263
Diligent::DeviceContextBase::DrawMeshIndirectCommandStride
static constexpr Uint32 DrawMeshIndirectCommandStride
Definition: DeviceContextBase.hpp:402
IMPLEMENT_QUERY_INTERFACE_IN_PLACE
#define IMPLEMENT_QUERY_INTERFACE_IN_PLACE(InterfaceID, ParentClassName)
Definition: ObjectBase.hpp:59
Diligent::RESOURCE_STATE_RAY_TRACING
@ RESOURCE_STATE_RAY_TRACING
The resource is used as a top-level AS shader resource in a trace rays operation.
Definition: GraphicsTypes.h:2878
Diligent::DeviceContextBase::SetIndexBuffer
virtual void SetIndexBuffer(IBuffer *pIndexBuffer, Uint32 ByteOffset, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode) override=0
Base implementation of IDeviceContext::SetIndexBuffer(); caches the strong reference to the index buf...
Definition: DeviceContextBase.hpp:574
Diligent::DeviceContextBase::TraceRays
void TraceRays(const TraceRaysAttribs &Attribs, int) const
Definition: DeviceContextBase.hpp:1524
Diligent::TraceRaysAttribs
struct TraceRaysAttribs TraceRaysAttribs
Definition: DeviceContext.h:1280
Dummy
n int Dummy
Definition: GenerateMipsCS_inc.h:25
ResourceMapping.h
Diligent::RefCntAutoPtr< BufferImplType >
Diligent::RESOURCE_STATE_TRANSITION_MODE_NONE
@ RESOURCE_STATE_TRANSITION_MODE_NONE
Perform no state transitions and no state validation. Resource states are not accessed (either read o...
Definition: DeviceContext.h:140
Diligent::VertexStreamInfo::VertexStreamInfo
VertexStreamInfo()
Definition: DeviceContextBase.hpp:89
Diligent::DeviceContextBase::DvpVerifyDispatchIndirectArguments
bool DvpVerifyDispatchIndirectArguments(const DispatchComputeIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer) const
Definition: DeviceContextBase.hpp:381
DILIGENT_CALL_TYPE
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
Diligent::DrawMeshIndirectCountAttribs
struct DrawMeshIndirectCountAttribs DrawMeshIndirectCountAttribs
Definition: DeviceContext.h:477
Diligent::DeviceContextBase::TraceRaysIndirectCommandSBTSize
static constexpr Uint32 TraceRaysIndirectCommandSBTSize
Definition: DeviceContextBase.hpp:404
Diligent::PIPELINE_TYPE_COMPUTE
@ PIPELINE_TYPE_COMPUTE
Compute pipeline, which is used by IDeviceContext::DispatchCompute(), IDeviceContext::DispatchCompute...
Definition: PipelineState.h:302
Diligent::DeviceContextBase::DvpVerifyStateTransitionDesc
bool DvpVerifyStateTransitionDesc(const StateTransitionDesc &Barrier) const
Definition: DeviceContextBase.hpp:384
Diligent::DeviceContextBase::DvpVerifyDrawMeshIndirectCountArguments
bool DvpVerifyDrawMeshIndirectCountArguments(const DrawMeshIndirectCountAttribs &Attribs, const IBuffer *pAttribsBuffer, const IBuffer *pCountBuff) const
Definition: DeviceContextBase.hpp:378
Diligent::CPU_ACCESS_WRITE
@ CPU_ACCESS_WRITE
A resource can be mapped for writing.
Definition: GraphicsTypes.h:195
Diligent::BuildTLASAttribs
This structure is used by IDeviceContext::BuildTLAS().
Definition: DeviceContext.h:1082
Diligent::RESOURCE_STATE_TRANSITION_MODE_VERIFY
@ RESOURCE_STATE_TRANSITION_MODE_VERIFY
Do not transition, but verify that states are correct. No validation is performed if the state is unk...
Definition: DeviceContext.h:162
Diligent::DeviceContextBase< EngineGLImplTraits >::PipelineStateImplType
typename EngineGLImplTraits ::PipelineStateImplType PipelineStateImplType
Definition: DeviceContextBase.hpp:115
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Diligent::DrawMeshIndirectAttribs
Defines the mesh indirect draw command attributes.
Definition: DeviceContext.h:402
Diligent::TraceRaysAttribs::DimensionX
Uint32 DimensionX
The number of rays dispatched in X direction.
Definition: DeviceContext.h:1272
Diligent::DeviceContextBase< EngineGLImplTraits >::TopLevelASType
typename EngineGLImplTraits ::TopLevelASImplType TopLevelASType
Definition: DeviceContextBase.hpp:122
Diligent::VerifyStateTransitionDesc
bool VerifyStateTransitionDesc(const IRenderDevice *pDevice, const StateTransitionDesc &Barrier)
Definition: DeviceContextBase.cpp:266
Diligent::TraceRaysAttribs::DimensionY
Uint32 DimensionY
The number of rays dispatched in Y direction.
Definition: DeviceContext.h:1273
Diligent::DeviceContextBase
Base implementation of the device context.
Definition: DeviceContextBase.hpp:107
Diligent::MAP_WRITE
@ MAP_WRITE
The resource is mapped for writing. D3D11 counterpart: D3D11_MAP_WRITE. OpenGL counterpart: GL_MAP_...
Definition: GraphicsTypes.h:214
Diligent::DeviceContextBase::CopyBLAS
void CopyBLAS(const CopyBLASAttribs &Attribs, int) const
Definition: DeviceContextBase.hpp:1491
Diligent::DeviceContextBase::SetVertexBuffers
virtual void SetVertexBuffers(Uint32 StartSlot, Uint32 NumBuffersSet, IBuffer **ppBuffers, Uint32 *pOffsets, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, SET_VERTEX_BUFFERS_FLAGS Flags) override=0
Base implementation of IDeviceContext::SetVertexBuffers(); validates parameters and caches references...
Definition: DeviceContextBase.hpp:493
Diligent::Viewport
Describes the viewport.
Definition: DeviceContext.h:593
Diligent::DispatchComputeAttribs
Describes dispatch command arguments.
Definition: DeviceContext.h:500
Diligent::MAP_READ
@ MAP_READ
The resource is mapped for reading. D3D11 counterpart: D3D11_MAP_READ. OpenGL counterpart: GL_MAP_R...
Definition: GraphicsTypes.h:210
Diligent::RESOURCE_STATE_UNKNOWN
@ RESOURCE_STATE_UNKNOWN
The resource state is not known to the engine and is managed by the application.
Definition: GraphicsTypes.h:2817
Diligent::CopyTextureAttribs::pDstTexture
ITexture * pDstTexture
Destination texture.
Definition: DeviceContext.h:690
Diligent::DeviceContextBase::CopyBuffer
virtual void CopyBuffer(IBuffer *pSrcBuffer, Uint32 SrcOffset, RESOURCE_STATE_TRANSITION_MODE SrcBufferTransitionMode, IBuffer *pDstBuffer, Uint32 DstOffset, Uint32 Size, RESOURCE_STATE_TRANSITION_MODE DstBufferTransitionMode) override=0
Base implementation of IDeviceContext::CopyBuffer(); validates input parameters.
Definition: DeviceContextBase.hpp:1293
Diligent::DrawMeshAttribs
struct DrawMeshAttribs DrawMeshAttribs
Definition: DeviceContext.h:396
Diligent::DeviceContextBase::DvpVerifyDispatchArguments
bool DvpVerifyDispatchArguments(const DispatchComputeAttribs &Attribs) const
Definition: DeviceContextBase.hpp:380
Diligent::DeviceContextBase::GetPipelineState
void GetPipelineState(IPipelineState **ppPSO, float *BlendFactors, Uint32 &StencilRef)
Returns currently bound pipeline state and blend factors.
Definition: DeviceContextBase.hpp:598
Diligent::BuildBLASAttribs
This structure is used by IDeviceContext::BuildBLAS().
Definition: DeviceContext.h:925
Diligent::CopyBLASAttribs
This structure is used by IDeviceContext::CopyBLAS().
Definition: DeviceContext.h:1159
Diligent::TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION
@ TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION
Allow automatic mipmap generation for this view. This flag is only allowed for TEXTURE_VIEW_SHADER_RE...
Definition: TextureView.h:74
Diligent::CPU_ACCESS_READ
@ CPU_ACCESS_READ
A resource can be mapped for reading.
Definition: GraphicsTypes.h:194
Diligent::VerifyDrawMeshIndirectAttribs
bool VerifyDrawMeshIndirectAttribs(const DrawMeshIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer)
Definition: DeviceContextBase.cpp:120
Diligent::VerifyCopyTLASAttribs
bool VerifyCopyTLASAttribs(const CopyTLASAttribs &Attribs)
Definition: DeviceContextBase.cpp:697
Diligent::BeginRenderPassAttribs::pRenderPass
IRenderPass * pRenderPass
Render pass to begin.
Definition: DeviceContext.h:734
Diligent::TEXTURE_FORMAT
TEXTURE_FORMAT
Texture formats.
Definition: GraphicsTypes.h:328
Diligent::DeviceContextBase::UnmapTextureSubresource
virtual void UnmapTextureSubresource(ITexture *pTexture, Uint32 MipLevel, Uint32 ArraySlice) override=0
Base implementaiton of IDeviceContext::UnmapTextureSubresource()
Definition: DeviceContextBase.hpp:1429
Diligent::DeviceContextBase::m_RenderPassAttachmentsTransitionMode
RESOURCE_STATE_TRANSITION_MODE m_RenderPassAttachmentsTransitionMode
Render pass attachments transition mode.
Definition: DeviceContextBase.hpp:474
Diligent::DeviceContextBase::m_pBoundDepthStencil
RefCntAutoPtr< TextureViewImplType > m_pBoundDepthStencil
Strong references to the bound depth stencil view. Use final texture view implementation type to avoi...
Definition: DeviceContextBase.hpp:462
Diligent::DeviceContextBase::GetRenderTargets
void GetRenderTargets(Uint32 &NumRenderTargets, ITextureView **ppRTVs, ITextureView **ppDSV)
Returns currently bound render targets.
Definition: DeviceContextBase.hpp:883
Diligent::DeviceContextBase::GenerateMips
virtual void GenerateMips(ITextureView *pTexView) override=0
Definition: DeviceContextBase.hpp:1440
Diligent::DeviceContextBase::SetScissorRects
void SetScissorRects(Uint32 NumRects, const Rect *pRects, Uint32 &RTWidth, Uint32 &RTHeight)
Caches the scissor rects.
Definition: DeviceContextBase.hpp:684
Diligent::DrawIndirectAttribs
Defines the indirect draw command attributes.
Definition: DeviceContext.h:291
Diligent::DeviceContextBase::MapBuffer
virtual void MapBuffer(IBuffer *pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags, PVoid &pMappedData) override=0
Base implementation of IDeviceContext::MapBuffer(); validates input parameters.
Definition: DeviceContextBase.hpp:1316
Diligent::DeviceContextBase< EngineGLImplTraits >::BottomLevelASType
typename EngineGLImplTraits ::BottomLevelASImplType BottomLevelASType
Definition: DeviceContextBase.hpp:121
LOG_WARNING_MESSAGE
#define LOG_WARNING_MESSAGE(...)
Definition: Errors.hpp:123
Diligent::DrawAttribs::Flags
DRAW_FLAGS Flags
Additional flags, see Diligent::DRAW_FLAGS.
Definition: DeviceContext.h:175
Diligent::VertexStreamInfo
Describes input vertex stream.
Definition: DeviceContextBase.hpp:87
Diligent::VerifyWriteBLASCompactedSizeAttribs
bool VerifyWriteBLASCompactedSizeAttribs(const IRenderDevice *pDevice, const WriteBLASCompactedSizeAttribs &Attribs)
Definition: DeviceContextBase.cpp:730
Diligent::DeviceContextBase::CommittedShaderResources
Committed shader resources for each resource signature.
Definition: DeviceContextBase.hpp:264
Diligent::UpdateIndirectRTBufferAttribs::pAttribsBuffer
IBuffer * pAttribsBuffer
Indirect buffer that can be used by IDeviceContext::TraceRaysIndirect() command.
Definition: DeviceContext.h:1306
Diligent::BIND_DEPTH_STENCIL
@ BIND_DEPTH_STENCIL
A texture can be bound as a depth-stencil target.
Definition: GraphicsTypes.h:126
Diligent::CopyTLASAttribs
This structure is used by IDeviceContext::CopyTLAS().
Definition: DeviceContext.h:1188
Diligent::VerifyDispatchComputeAttribs
bool VerifyDispatchComputeAttribs(const DispatchComputeAttribs &Attribs)
Definition: DeviceContextBase.cpp:160
Diligent::DrawIndexedAttribs
Defines the indexed draw command attributes.
Definition: DeviceContext.h:224
Diligent::DeviceContextBase::m_pPipelineState
RefCntAutoPtr< PipelineStateImplType > m_pPipelineState
Strong reference to the bound pipeline state object. Use final PSO implementation type to avoid virtu...
Definition: DeviceContextBase.hpp:421
Diligent::TraceRaysAttribs::DimensionZ
Uint32 DimensionZ
The number of rays dispatched in Z direction.
Definition: DeviceContext.h:1274
Diligent::DeviceContextBase::MapTextureSubresource
virtual void MapTextureSubresource(ITexture *pTexture, Uint32 MipLevel, Uint32 ArraySlice, MAP_TYPE MapType, MAP_FLAGS MapFlags, const Box *pMapRegion, MappedTextureSubresource &MappedData) override=0
Base implementaiton of IDeviceContext::MapTextureSubresource()
Definition: DeviceContextBase.hpp:1415
Diligent::VertexStreamInfo::pBuffer
RefCntAutoPtr< BufferImplType > pBuffer
Strong reference to the buffer object.
Definition: DeviceContextBase.hpp:92
Diligent::DeviceContextBase< EngineGLImplTraits >::TextureImplType
typename EngineGLImplTraits ::TextureImplType TextureImplType
Definition: DeviceContextBase.hpp:114
Diligent::TraceRaysIndirectAttribs::pSBT
const IShaderBindingTable * pSBT
Shader binding table.
Definition: DeviceContext.h:1287
Diligent::DeviceContextBase::ClearDepthStencil
void ClearDepthStencil(ITextureView *pView)
Definition: DeviceContextBase.hpp:1171
Diligent::DeviceContextBase::CheckIfBoundAsRenderTarget
bool CheckIfBoundAsRenderTarget(TextureImplType *pTexture)
Checks if the texture is currently bound as a render target.
Definition: DeviceContextBase.hpp:958
std::max
Diligent::Vector2< T > max(const Diligent::Vector2< T > &Left, const Diligent::Vector2< T > &Right)
Definition: BasicMath.hpp:2261
Diligent::DeviceContextBase::BuildBLAS
void BuildBLAS(const BuildBLASAttribs &Attribs, int) const
Definition: DeviceContextBase.hpp:1475
Diligent::TEXTURE_VIEW_DEPTH_STENCIL
@ TEXTURE_VIEW_DEPTH_STENCIL
A texture view will define a depth stencil view that will be used as the target for rendering operati...
Definition: GraphicsTypes.h:289
Diligent::DeviceContextBase::UpdateSBT
void UpdateSBT(IShaderBindingTable *pSBT, const UpdateIndirectRTBufferAttribs *pUpdateIndirectBufferAttribs, int) const
Definition: DeviceContextBase.hpp:1592
Diligent::BIND_VERTEX_BUFFER
@ BIND_VERTEX_BUFFER
A buffer can be bound as a vertex buffer.
Definition: GraphicsTypes.h:118
Diligent::DeviceContextBase::EndRenderPass
virtual void EndRenderPass() override=0
Definition: DeviceContextBase.hpp:1153
Diligent::IQuery
Query interface.
Definition: Query.h:177
Diligent::DeviceContextBase::m_NumViewports
Uint32 m_NumViewports
Number of current viewports.
Definition: DeviceContextBase.hpp:439
Diligent::Uint8
uint8_t Uint8
8-bit unsigned integer
Definition: BasicTypes.h:53
Diligent::DeviceContextBase::CheckIfBoundAsDepthStencil
bool CheckIfBoundAsDepthStencil(TextureImplType *pTexture)
Checks if the texture is currently bound as depth-stencil buffer.
Definition: DeviceContextBase.hpp:975
VERIFY_EXPR
#define VERIFY_EXPR(...)
Definition: DebugUtilities.hpp:79
Diligent::BuildBLASAttribs
struct BuildBLASAttribs BuildBLASAttribs
Definition: DeviceContext.h:982
Diligent::ValidateCopyTextureParams
void ValidateCopyTextureParams(const CopyTextureAttribs &CopyAttribs)
Validates copy texture command paramters.
Definition: TextureBase.cpp:264
Diligent::ShaderBindingTableDesc::pPSO
IPipelineState * pPSO
Ray tracing pipeline state object from which shaders will be taken.
Definition: ShaderBindingTable.h:53
Diligent::DeviceContextBase< EngineGLImplTraits >::BaseInterface
typename EngineGLImplTraits ::DeviceContextInterface BaseInterface
Definition: DeviceContextBase.hpp:110
VERIFY
#define VERIFY(...)
Definition: DebugUtilities.hpp:76
Diligent::VerifyCopyBLASAttribs
bool VerifyCopyBLASAttribs(const IRenderDevice *pDevice, const CopyBLASAttribs &Attribs)
Definition: DeviceContextBase.cpp:609
Diligent::Rect
Describes the rectangle.
Definition: DeviceContext.h:642
Diligent::BIND_RENDER_TARGET
@ BIND_RENDER_TARGET
A texture can be bound as a render target.
Definition: GraphicsTypes.h:125
Diligent::DeviceContextBase::m_ScissorRects
Rect m_ScissorRects[MAX_VIEWPORTS]
Current scissor rects.
Definition: DeviceContextBase.hpp:442
Diligent::VerifyDrawIndirectAttribs
bool VerifyDrawIndirectAttribs(const DrawIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer)
Definition: DeviceContextBase.cpp:91
Diligent::DeviceContextBase::TraceRaysIndirect
void TraceRaysIndirect(const TraceRaysIndirectAttribs &Attribs, IBuffer *pAttribsBuffer, int) const
Definition: DeviceContextBase.hpp:1558
Diligent::QUERY_TYPE_TIMESTAMP
@ QUERY_TYPE_TIMESTAMP
Gets the GPU timestamp corresponding to IDeviceContext::EndQuery call. Fot this query type IDeviceCon...
Definition: GraphicsTypes.h:1462
Diligent::ITexture::GetDesc
virtual const TextureDesc &METHOD() GetDesc() const override=0
Returns the texture description used to create the object.
Diligent::VerifyResolveTextureSubresourceAttribs
bool VerifyResolveTextureSubresourceAttribs(const ResolveTextureSubresourceAttribs &ResolveAttribs, const TextureDesc &SrcTexDesc, const TextureDesc &DstTexDesc)
Definition: DeviceContextBase.cpp:187
Diligent::DeviceContextBase::DvpVerifyTLASState
bool DvpVerifyTLASState(const TopLevelASType &TLAS, RESOURCE_STATE RequiredState, const char *OperationName) const
Definition: DeviceContextBase.hpp:388
_countof
#define _countof(_Array)
Definition: AndroidPlatformDefinitions.h:38
Diligent::DrawAttribs
Defines the draw command attributes.
Definition: DeviceContext.h:169
Diligent::DeviceContextBase::m_FramebufferSlices
Uint32 m_FramebufferSlices
Number of array slices in the currently bound framebuffer.
Definition: DeviceContextBase.hpp:456
Diligent::DeviceContextBase::CommittedShaderResources::ActiveSRBMask
SRBMaskType ActiveSRBMask
Definition: DeviceContextBase.hpp:280
Diligent::DeviceContextBase::IsDeferred
bool IsDeferred() const
Definition: DeviceContextBase.hpp:254
Diligent::VerifyDrawIndexedIndirectAttribs
bool VerifyDrawIndexedIndirectAttribs(const DrawIndexedIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer)
Definition: DeviceContextBase.cpp:104
Diligent::BeginRenderPassAttribs::pFramebuffer
IFramebuffer * pFramebuffer
Framebuffer containing the attachments that are used with the render pass.
Definition: DeviceContext.h:737
Diligent::DeviceContextBase::m_NumVertexStreams
Uint32 m_NumVertexStreams
Number of bound vertex streams.
Definition: DeviceContextBase.hpp:415
Diligent::DeviceContextBase::UpdateAttachmentStates
void UpdateAttachmentStates(Uint32 SubpassIndex)
Updates the states of render pass attachments to match states within the gievn subpass.
Definition: DeviceContextBase.hpp:1123
Diligent::DeviceContextBase::CopyTLAS
void CopyTLAS(const CopyTLASAttribs &Attribs, int) const
Definition: DeviceContextBase.hpp:1499
Diligent::DeviceContextBase::PrepareCommittedResources
void PrepareCommittedResources(CommittedShaderResources &Resources, Uint32 &DvpCompatibleSRBCount)
Definition: DeviceContextBase.hpp:1607
Sampler.h
Diligent::RESOURCE_STATE
RESOURCE_STATE
Resource usage state.
Definition: GraphicsTypes.h:2814
Diligent::BeginRenderPassAttribs::StateTransitionMode
RESOURCE_STATE_TRANSITION_MODE StateTransitionMode
Framebuffer attachments state transition mode before the render pass begins.
Definition: DeviceContext.h:761
Diligent::VerifyBuildBLASAttribs
bool VerifyBuildBLASAttribs(const BuildBLASAttribs &Attribs)
Definition: DeviceContextBase.cpp:358
Diligent::DeviceContextBase::WriteBLASCompactedSize
void WriteBLASCompactedSize(const WriteBLASCompactedSizeAttribs &Attribs, int) const
Definition: DeviceContextBase.hpp:1508
Diligent::DeviceContextBase::m_pBoundRenderTargets
RefCntAutoPtr< TextureViewImplType > m_pBoundRenderTargets[MAX_RENDER_TARGETS]
Vector of strong references to the bound render targets. Use final texture view implementation type t...
Definition: DeviceContextBase.hpp:448
Diligent::DrawIndexedIndirectAttribs
struct DrawIndexedIndirectAttribs DrawIndexedIndirectAttribs
Definition: DeviceContext.h:370
Diligent::DeviceContextBase::m_pBoundFramebuffer
RefCntAutoPtr< FramebufferImplType > m_pBoundFramebuffer
Strong reference to the bound framebuffer.
Definition: DeviceContextBase.hpp:465
Diligent::BIND_INDEX_BUFFER
@ BIND_INDEX_BUFFER
A buffer can be bound as an index buffer.
Definition: GraphicsTypes.h:119
Diligent::IQuery::GetDesc
virtual const QueryDesc &METHOD() GetDesc() const override=0
Returns the Query description used to create the object.
Diligent::DeviceContextBase::m_bIsDeferred
const bool m_bIsDeferred
Definition: DeviceContextBase.hpp:476
Diligent::MAP_TYPE
MAP_TYPE
Resource mapping type.
Definition: GraphicsTypes.h:206
Diligent::CopyTextureAttribs
Defines copy texture command attributes.
Definition: DeviceContext.h:672
Diligent::DeviceContextBase::UnmapBuffer
virtual void UnmapBuffer(IBuffer *pBuffer, MAP_TYPE MapType) override=0
Base implementation of IDeviceContext::UnmapBuffer()
Definition: DeviceContextBase.hpp:1374
Diligent::DeviceContextBase::ClearRenderTarget
void ClearRenderTarget(ITextureView *pView)
Definition: DeviceContextBase.hpp:1208
Diligent::GetTextureFormatAttribs
const TextureFormatAttribs & GetTextureFormatAttribs(TEXTURE_FORMAT Format)
Returns invariant texture format attributes, see TextureFormatAttribs for details.
Definition: GraphicsAccessories.cpp:250
TextureBase.hpp
Diligent::DeviceContextBase::GetDevice
IRenderDevice * GetDevice()
Returns the render device.
Definition: DeviceContextBase.hpp:250
Diligent::DeviceContextBase::m_pDevice
RefCntAutoPtr< DeviceImplType > m_pDevice
Strong reference to the device.
Definition: DeviceContextBase.hpp:409
Diligent::SET_VERTEX_BUFFERS_FLAG_RESET
@ SET_VERTEX_BUFFERS_FLAG_RESET
Reset the vertex buffers to only the buffers specified in this call. All buffers previously bound to ...
Definition: DeviceContext.h:585
Diligent::DeviceContextBase::CopyTexture
virtual void CopyTexture(const CopyTextureAttribs &CopyAttribs) override=0
Base implementaiton of IDeviceContext::CopyTexture(); validates input parameters.
Definition: DeviceContextBase.hpp:1405
ATTACHMENT_UNUSED
#define ATTACHMENT_UNUSED
Definition: RenderPass.h:143
Diligent::WriteBLASCompactedSizeAttribs
struct WriteBLASCompactedSizeAttribs WriteBLASCompactedSizeAttribs
Definition: DeviceContext.h:1238
Diligent::DeviceContextBase::DvpVerifyDrawIndirectArguments
bool DvpVerifyDrawIndirectArguments(const DrawIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer) const
Definition: DeviceContextBase.hpp:375
Diligent::TEXTURE_VIEW_SHADER_RESOURCE
@ TEXTURE_VIEW_SHADER_RESOURCE
A texture view will define a shader resource view that will be used as the source for the shader read...
Definition: GraphicsTypes.h:281
Diligent::DeviceContextBase::CommittedShaderResources::SRBMaskType
Uint8 SRBMaskType
Definition: DeviceContextBase.hpp:277
Diligent::ITexture
Texture inteface.
Definition: Texture.h:273
Diligent::DrawIndirectAttribs
struct DrawIndirectAttribs DrawIndirectAttribs
Definition: DeviceContext.h:324
Diligent::DeviceContextBase< EngineGLImplTraits >::FramebufferImplType
typename EngineGLImplTraits ::FramebufferImplType FramebufferImplType
Definition: DeviceContextBase.hpp:119
Diligent::PIPELINE_TYPE_GRAPHICS
@ PIPELINE_TYPE_GRAPHICS
Graphics pipeline, which is used by IDeviceContext::Draw(), IDeviceContext::DrawIndexed(),...
Definition: PipelineState.h:299
Diligent::DeviceContextBase::WriteTLASCompactedSize
void WriteTLASCompactedSize(const WriteTLASCompactedSizeAttribs &Attribs, int) const
Definition: DeviceContextBase.hpp:1516
Diligent::DeviceContextBase::m_NumBoundRenderTargets
Uint32 m_NumBoundRenderTargets
Number of bound render targets.
Definition: DeviceContextBase.hpp:450
Diligent::IBuffer::GetDesc
virtual const BufferDesc &METHOD() GetDesc() const override=0
Returns the buffer description used to create the object.
Diligent::DeviceObjectAttribs::Name
const Char * Name
Object name.
Definition: GraphicsTypes.h:1199
Diligent::DeviceContextBase::DvpVerifyDrawMeshArguments
bool DvpVerifyDrawMeshArguments(const DrawMeshAttribs &Attribs) const
Definition: DeviceContextBase.hpp:374
Diligent::VerifyBeginRenderPassAttribs
bool VerifyBeginRenderPassAttribs(const BeginRenderPassAttribs &Attribs)
Definition: DeviceContextBase.cpp:231
Diligent::DeviceContextBase< EngineGLImplTraits >::PipelineResourceSignatureImplType
typename EngineGLImplTraits ::PipelineResourceSignatureImplType PipelineResourceSignatureImplType
Definition: DeviceContextBase.hpp:125
Diligent::DrawAttribs
struct DrawAttribs DrawAttribs
Definition: DeviceContext.h:218
Diligent::DeviceContextBase::DeviceContextBase
DeviceContextBase(IReferenceCounters *pRefCounters, DeviceImplType *pRenderDevice, bool bIsDeferred)
Definition: DeviceContextBase.hpp:130
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
Diligent::TraceRaysAttribs::pSBT
const IShaderBindingTable * pSBT
Shader binding table.
Definition: DeviceContext.h:1270
Diligent::TextureDesc::SampleCount
Uint32 SampleCount
Number of samples. Only 2D textures or 2D texture arrays can be multisampled.
Definition: Texture.h:76
Diligent::VerifyDispatchComputeIndirectAttribs
bool VerifyDispatchComputeIndirectAttribs(const DispatchComputeIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer)
Definition: DeviceContextBase.cpp:173
Diligent::TextureSubResData
Describes data for one subresource.
Definition: Texture.h:165
Diligent::USAGE_DEFAULT
@ USAGE_DEFAULT
A resource that requires read and write access by the GPU and can also be occasionally written by the...
Definition: GraphicsTypes.h:156
Diligent::DeviceContextBase::DvpVerifyDrawArguments
bool DvpVerifyDrawArguments(const DrawAttribs &Attribs) const
Definition: DeviceContextBase.hpp:372
Diligent::VerifyTraceRaysAttribs
bool VerifyTraceRaysAttribs(const TraceRaysAttribs &Attribs)
Definition: DeviceContextBase.cpp:778