Go to the documentation of this file.
33 #include <unordered_map>
80 const IBuffer* pAttribsBuffer,
86 template <
typename BufferImplType>
106 template <
typename EngineImplTraits>
198 PVoid& pMappedData)
override = 0;
221 const Box* pMapRegion,
227 Uint32 ArraySlice)
override = 0;
267 std::array<ShaderResourceCacheImplType*, MAX_RESOURCE_SIGNATURES>
ResourceCaches = {};
269 #ifdef DILIGENT_DEVELOPMENT
271 std::array<RefCntWeakPtr<ShaderResourceBindingImplType>, MAX_RESOURCE_SIGNATURES> SRBs;
274 bool ResourcesValidated =
false;
278 static_assert(
sizeof(
SRBMaskType) * 8 >= MAX_RESOURCE_SIGNATURES,
"Not enought space to store MAX_RESOURCE_SIGNATURES bits");
286 ResourceCaches[Index] = pSRB !=
nullptr ? &pSRB->GetResourceCache() :
nullptr;
288 const auto SRBBit =
static_cast<SRBMaskType>(1u << Index);
294 #ifdef DILIGENT_DEVELOPMENT
297 ResourcesValidated =
false;
347 #ifdef DILIGENT_DEVELOPMENT
368 void DvpVerifySRBCompatibility(
369 CommittedShaderResources& Resources,
480 #ifdef DILIGENT_DEBUG
483 struct DbgMappedBufferInfo
487 std::unordered_map<IBuffer*, DbgMappedBufferInfo> m_DbgMappedBuffers;
492 template <
typename ImplementationTraits>
501 DEV_CHECK_ERR(StartSlot < MAX_BUFFER_SLOTS,
"Start vertex buffer slot ", StartSlot,
" is out of allowed range [0, ", MAX_BUFFER_SLOTS - 1,
"].");
504 "The range of vertex buffer slots being set [", StartSlot,
", ", StartSlot + NumBuffersSet - 1,
505 "] is out of allowed range [0, ", MAX_BUFFER_SLOTS - 1,
"].");
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.");
516 for (
Uint32 s = 0; s < StartSlot; ++s)
518 for (
Uint32 s = StartSlot + NumBuffersSet; s < m_NumVertexStreams; ++s)
520 m_NumVertexStreams = 0;
522 m_NumVertexStreams =
std::max(m_NumVertexStreams, StartSlot + NumBuffersSet);
524 for (
Uint32 Buff = 0; Buff < NumBuffersSet; ++Buff)
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)
532 const auto& BuffDesc = CurrStream.pBuffer->GetDesc();
534 "Buffer '", BuffDesc.Name ? BuffDesc.Name :
"",
"' being bound as vertex buffer to slot ", Buff,
535 " was not created with BIND_VERTEX_BUFFER flag");
540 while (m_NumVertexStreams > 0 && !m_VertexStreams[m_NumVertexStreams - 1].pBuffer)
544 template <
typename ImplementationTraits>
549 m_pPipelineState = pPipelineState;
552 template <
typename ImplementationTraits>
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.");
562 DEV_CHECK_ERR(pShaderResourceBinding !=
nullptr,
"pShaderResourceBinding must not be null");
565 template <
typename ImplementationTraits>
568 DEV_CHECK_ERR(m_pActiveRenderPass ==
nullptr,
"Invalidating context inside an active render pass. Call EndRenderPass() to finish the pass.");
573 template <
typename ImplementationTraits>
579 m_pIndexBuffer = ValidatedCast<BufferImplType>(pIndexBuffer);
580 m_IndexDataStartOffset = ByteOffset;
582 #ifdef DILIGENT_DEVELOPMENT
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.");
589 const auto& BuffDesc = m_pIndexBuffer->GetDesc();
591 "Buffer '", BuffDesc.Name ? BuffDesc.Name :
"",
"' being bound as index buffer was not created with BIND_INDEX_BUFFER flag");
597 template <
typename ImplementationTraits>
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)
604 m_pPipelineState->QueryInterface(IID_PipelineState,
reinterpret_cast<IObject**
>(ppPSO));
611 for (
Uint32 f = 0; f < 4; ++f)
612 BlendFactors[f] = m_BlendFactors[f];
613 StencilRef = m_StencilRef;
616 template <
typename ImplementationTraits>
619 bool FactorsDiffer =
false;
620 for (
Uint32 f = 0; f < 4; ++f)
622 if (m_BlendFactors[f] != BlendFactors[f])
623 FactorsDiffer =
true;
624 m_BlendFactors[f] = BlendFactors[f];
626 return FactorsDiffer;
629 template <
typename ImplementationTraits>
632 if (m_StencilRef != StencilRef)
634 m_StencilRef = StencilRef;
640 template <
typename ImplementationTraits>
647 if (RTWidth == 0 || RTHeight == 0)
649 RTWidth = m_FramebufferWidth;
650 RTHeight = m_FramebufferHeight;
653 DEV_CHECK_ERR(NumViewports < MAX_VIEWPORTS,
"Number of viewports (", NumViewports,
") exceeds the limit (", MAX_VIEWPORTS,
")");
654 m_NumViewports =
std::min(MAX_VIEWPORTS, NumViewports);
656 Viewport DefaultVP(0, 0,
static_cast<float>(RTWidth),
static_cast<float>(RTHeight));
658 if (m_NumViewports == 1 && pViewports ==
nullptr)
660 pViewports = &DefaultVP;
663 for (
Uint32 vp = 0; vp < m_NumViewports; ++vp)
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,
"]");
672 template <
typename ImplementationTraits>
675 NumViewports = m_NumViewports;
678 for (
Uint32 vp = 0; vp < m_NumViewports; ++vp)
679 pViewports[vp] = m_Viewports[vp];
683 template <
typename ImplementationTraits>
690 if (RTWidth == 0 || RTHeight == 0)
692 RTWidth = m_FramebufferWidth;
693 RTHeight = m_FramebufferHeight;
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);
699 for (
Uint32 sr = 0; sr < m_NumScissorRects; ++sr)
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,
")");
707 template <
typename ImplementationTraits>
713 if (NumRenderTargets == 0 && pDepthStencil ==
nullptr)
715 ResetRenderTargets();
719 bool bBindRenderTargets =
false;
720 m_FramebufferWidth = 0;
721 m_FramebufferHeight = 0;
722 m_FramebufferSlices = 0;
723 m_FramebufferSamples = 0;
725 if (NumRenderTargets != m_NumBoundRenderTargets)
727 bBindRenderTargets =
true;
728 for (
Uint32 rt = NumRenderTargets; rt < m_NumBoundRenderTargets; ++rt)
729 m_pBoundRenderTargets[rt].Release();
731 m_NumBoundRenderTargets = NumRenderTargets;
734 for (
Uint32 rt = 0; rt < NumRenderTargets; ++rt)
736 auto* pRTView = ppRenderTargets[rt];
739 const auto& RTVDesc = pRTView->
GetDesc();
741 "Texture view object named '", RTVDesc.Name ? RTVDesc.Name :
"",
"' has incorrect view type (",
GetTexViewTypeLiteralName(RTVDesc.ViewType),
"). Render target view is expected");
744 if (m_FramebufferWidth == 0)
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;
755 #ifdef DILIGENT_DEVELOPMENT
756 const auto& TexDesc = pRTView->GetTexture()->GetDesc();
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,
")");
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,
")");
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,
")");
764 "Sample count (", TexDesc.SampleCount,
") of RTV '", RTVDesc.Name,
"' is inconsistent with the sample count of previously bound render targets (", m_FramebufferSamples,
")");
772 if (m_pBoundRenderTargets[rt] != pRTView)
774 m_pBoundRenderTargets[rt] = ValidatedCast<TextureViewImplType>(pRTView);
775 bBindRenderTargets =
true;
779 if (pDepthStencil !=
nullptr)
781 const auto& DSVDesc = pDepthStencil->
GetDesc();
783 "Texture view object named '", DSVDesc.Name ? DSVDesc.Name :
"",
"' has incorrect view type (",
GetTexViewTypeLiteralName(DSVDesc.ViewType),
"). Depth stencil view is expected");
786 if (m_FramebufferWidth == 0)
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;
797 #ifdef DILIGENT_DEVELOPMENT
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,
")");
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,
")");
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,
")");
806 "Sample count (", TexDesc.SampleCount,
") of DSV '", DSVDesc.Name,
"' is inconsistent with the sample count of previously bound render targets (", m_FramebufferSamples,
")");
811 if (m_pBoundDepthStencil != pDepthStencil)
813 m_pBoundDepthStencil = ValidatedCast<TextureViewImplType>(pDepthStencil);
814 bBindRenderTargets =
true;
817 VERIFY_EXPR(m_FramebufferWidth > 0 && m_FramebufferHeight > 0 && m_FramebufferSlices > 0 && m_FramebufferSamples > 0);
819 return bBindRenderTargets;
822 template <
typename ImplementationTraits>
828 const auto& RPDesc = m_pActiveRenderPass->GetDesc();
829 const auto& FBDesc = m_pBoundFramebuffer->GetDesc();
831 const auto& Subpass = RPDesc.pSubpasses[m_SubpassIndex];
833 m_FramebufferSamples = 0;
837 for (
Uint32 rt = 0; rt < Subpass.RenderTargetAttachmentCount; ++rt)
839 const auto& RTAttachmentRef = Subpass.pRenderTargetAttachments[rt];
842 VERIFY_EXPR(RTAttachmentRef.AttachmentIndex < RPDesc.AttachmentCount);
843 ppRTVs[rt] = FBDesc.ppAttachments[RTAttachmentRef.AttachmentIndex];
844 if (ppRTVs[rt] !=
nullptr)
846 if (m_FramebufferSamples == 0)
849 DEV_CHECK_ERR(m_FramebufferSamples == ppRTVs[rt]->GetTexture()->GetDesc().SampleCount,
"Inconsistent sample count");
854 if (Subpass.pDepthStencilAttachment !=
nullptr)
856 const auto& DSAttachmentRef = *Subpass.pDepthStencilAttachment;
859 VERIFY_EXPR(DSAttachmentRef.AttachmentIndex < RPDesc.AttachmentCount);
860 pDSV = FBDesc.ppAttachments[DSAttachmentRef.AttachmentIndex];
863 if (m_FramebufferSamples == 0)
870 bool BindRenderTargets = SetRenderTargets(Subpass.RenderTargetAttachmentCount, ppRTVs, pDSV);
873 m_FramebufferWidth = FBDesc.Width;
874 m_FramebufferHeight = FBDesc.Height;
875 m_FramebufferSlices = FBDesc.NumArraySlices;
878 return BindRenderTargets;
882 template <
typename ImplementationTraits>
888 NumRenderTargets = m_NumBoundRenderTargets;
892 for (
Uint32 rt = 0; rt < NumRenderTargets; ++rt)
894 DEV_CHECK_ERR(ppRTVs[rt] ==
nullptr,
"Non-null pointer found in RTV array element #", rt);
895 auto pBoundRTV = m_pBoundRenderTargets[rt];
897 pBoundRTV->QueryInterface(IID_TextureView,
reinterpret_cast<IObject**
>(ppRTVs + rt));
899 ppRTVs[rt] =
nullptr;
901 for (
Uint32 rt = NumRenderTargets; rt < MAX_RENDER_TARGETS; ++rt)
903 DEV_CHECK_ERR(ppRTVs[rt] ==
nullptr,
"Non-null pointer found in RTV array element #", rt);
904 ppRTVs[rt] =
nullptr;
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));
918 template <
typename ImplementationTraits>
921 for (
Uint32 stream = 0; stream < m_NumVertexStreams; ++stream)
923 #ifdef DILIGENT_DEBUG
924 for (
Uint32 stream = m_NumVertexStreams; stream <
_countof(m_VertexStreams); ++stream)
926 VERIFY(m_VertexStreams[stream].pBuffer ==
nullptr,
"Unexpected non-null buffer");
927 VERIFY(m_VertexStreams[stream].Offset == 0,
"Unexpected non-zero offset");
930 m_NumVertexStreams = 0;
932 m_pPipelineState.Release();
934 m_pIndexBuffer.Release();
935 m_IndexDataStartOffset = 0;
939 for (
int i = 0; i < 4; ++i)
940 m_BlendFactors[i] = -1;
942 for (
Uint32 vp = 0; vp < m_NumViewports; ++vp)
946 for (
Uint32 sr = 0; sr < m_NumScissorRects; ++sr)
947 m_ScissorRects[sr] =
Rect();
948 m_NumScissorRects = 0;
950 ResetRenderTargets();
952 VERIFY(!m_pActiveRenderPass,
"Clearing state cache inside an active render pass");
953 m_pActiveRenderPass =
nullptr;
954 m_pBoundFramebuffer =
nullptr;
957 template <
typename ImplementationTraits>
960 if (pTexture ==
nullptr)
963 for (
Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt)
965 if (m_pBoundRenderTargets[rt] && m_pBoundRenderTargets[rt]->GetTexture() == pTexture)
974 template <
typename ImplementationTraits>
977 if (pTexture ==
nullptr)
980 return m_pBoundDepthStencil && m_pBoundDepthStencil->GetTexture() == pTexture;
983 template <
typename ImplementationTraits>
986 DEV_CHECK_ERR(m_pActiveRenderPass ==
nullptr,
"State transitions are not allowed inside a render pass.");
988 if (pTexture ==
nullptr)
991 const auto& TexDesc = pTexture->GetDesc();
993 bool bResetRenderTargets =
false;
996 if (CheckIfBoundAsRenderTarget(pTexture))
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)");
1008 bResetRenderTargets =
true;
1014 if (CheckIfBoundAsDepthStencil(pTexture))
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)");
1025 bResetRenderTargets =
true;
1029 if (bResetRenderTargets)
1031 ResetRenderTargets();
1034 return bResetRenderTargets;
1037 template <
typename ImplementationTraits>
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)
1045 VERIFY(m_pBoundRenderTargets[rt] ==
nullptr,
"Non-null render target found");
1048 m_NumBoundRenderTargets = 0;
1049 m_FramebufferWidth = 0;
1050 m_FramebufferHeight = 0;
1051 m_FramebufferSlices = 0;
1052 m_FramebufferSamples = 0;
1054 m_pBoundDepthStencil.Release();
1060 template <
typename ImplementationTraits>
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.");
1069 ResetRenderTargets();
1071 auto* pNewRenderPass = ValidatedCast<RenderPassImplType>(Attribs.
pRenderPass);
1072 auto* pNewFramebuffer = ValidatedCast<FramebufferImplType>(Attribs.
pFramebuffer);
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)
1082 auto* pView = FBDesc.ppAttachments[i];
1083 if (pView ==
nullptr)
1086 auto* pTex = ValidatedCast<TextureImplType>(pView->GetTexture());
1087 auto RequiredState = RPDesc.pAttachments[i].InitialState;
1090 if (pTex->IsInKnownState() && !pTex->CheckState(RequiredState))
1093 this->TransitionResourceStates(1, &Barrier);
1098 DvpVerifyTextureState(*pTex, RequiredState,
"BeginRenderPass");
1103 m_pActiveRenderPass = pNewRenderPass;
1104 m_pBoundFramebuffer = pNewFramebuffer;
1108 UpdateAttachmentStates(m_SubpassIndex);
1109 SetSubpassRenderTargets();
1112 template <
typename ImplementationTraits>
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");
1118 UpdateAttachmentStates(m_SubpassIndex);
1119 SetSubpassRenderTargets();
1122 template <
typename ImplementationTraits>
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");
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,
")");
1136 for (
Uint32 i = 0; i < RPDesc.AttachmentCount; ++i)
1138 if (
auto* pView = FBDesc.ppAttachments[i])
1140 auto* pTex = ValidatedCast<TextureImplType>(pView->GetTexture());
1141 if (pTex->IsInKnownState())
1143 auto CurrState = SubpassIndex < RPDesc.SubpassCount ?
1144 m_pActiveRenderPass->GetAttachmentState(SubpassIndex, i) :
1145 RPDesc.pAttachments[i].FinalState;
1146 pTex->SetState(CurrState);
1152 template <
typename ImplementationTraits>
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");
1160 UpdateAttachmentStates(m_SubpassIndex + 1);
1162 m_pActiveRenderPass.Release();
1163 m_pBoundFramebuffer.Release();
1166 ResetRenderTargets();
1170 template <
typename ImplementationTraits>
1173 DEV_CHECK_ERR(pView !=
nullptr,
"Depth-stencil view to clear must not be null");
1175 #ifdef DILIGENT_DEVELOPMENT
1177 const auto& ViewDesc = pView->
GetDesc();
1180 "' is invalid: ClearDepthStencil command expects depth-stencil view (TEXTURE_VIEW_DEPTH_STENCIL).");
1182 if (pView != m_pBoundDepthStencil)
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.");
1189 if (m_pDevice->GetDeviceCaps().IsGLDevice())
1192 "' is not bound to the device context. ClearDepthStencil command requires "
1193 "depth-stencil view be bound to the device contex in OpenGL backend");
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.");
1207 template <
typename ImplementationTraits>
1210 DEV_CHECK_ERR(pView !=
nullptr,
"Render target view to clear must not be null");
1212 #ifdef DILIGENT_DEVELOPMENT
1214 const auto& ViewDesc = pView->
GetDesc();
1217 "' is invalid: ClearRenderTarget command expects render target view (TEXTURE_VIEW_RENDER_TARGET).");
1219 bool RTFound =
false;
1220 for (
Uint32 i = 0; i < m_NumBoundRenderTargets && !RTFound; ++i)
1222 RTFound = m_pBoundRenderTargets[i] == pView;
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.");
1232 if (m_pDevice->GetDeviceCaps().IsGLDevice())
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");
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.");
1249 template <
typename ImplementationTraits>
1252 DEV_CHECK_ERR(pQuery !=
nullptr,
"IDeviceContext::BeginQuery: pQuery must not be null");
1254 DEV_CHECK_ERR(!m_bIsDeferred,
"IDeviceContext::BeginQuery: Deferred contexts do not support queries");
1257 "BeginQuery() is disabled for timestamp queries. Call EndQuery() to set the timestamp.");
1259 ValidatedCast<QueryImplType>(pQuery)->OnBeginQuery(
this);
1262 template <
typename ImplementationTraits>
1265 DEV_CHECK_ERR(pQuery !=
nullptr,
"IDeviceContext::EndQuery: pQuery must not be null");
1267 DEV_CHECK_ERR(!m_bIsDeferred,
"IDeviceContext::EndQuery: Deferred contexts do not support queries");
1269 ValidatedCast<QueryImplType>(pQuery)->OnEndQuery(
this);
1272 template <
typename ImplementationTraits>
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
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,
")");
1292 template <
typename ImplementationTraits>
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
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,
")");
1315 template <
typename ImplementationTraits>
1324 const auto& BuffDesc = pBuffer->
GetDesc();
1326 #ifdef DILIGENT_DEBUG
1328 VERIFY(m_DbgMappedBuffers.find(pBuffer) == m_DbgMappedBuffers.end(),
"Buffer '", BuffDesc.Name,
"' has already been mapped");
1329 m_DbgMappedBuffers[pBuffer] = DbgMappedBufferInfo{MapType};
1333 pMappedData =
nullptr;
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");
1345 "Only buffers with usage USAGE_STAGING, USAGE_DYNAMIC or USAGE_UNIFIED can be mapped for writing");
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");
1373 template <
typename ImplementationTraits>
1376 VERIFY(pBuffer,
"pBuffer must not be null");
1377 #ifdef DILIGENT_DEBUG
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);
1388 template <
typename ImplementationTraits>
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.");
1404 template <
typename ImplementationTraits>
1409 DEV_CHECK_ERR(m_pActiveRenderPass ==
nullptr,
"CopyTexture command must be used outside of render pass.");
1414 template <
typename ImplementationTraits>
1421 const Box* pMapRegion,
1428 template <
typename ImplementationTraits>
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");
1439 template <
typename ImplementationTraits>
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
1446 const auto& ViewDesc = pTexView->
GetDesc();
1448 "' can't be used to generate mipmaps because its type is ",
GetTexViewTypeLiteralName(ViewDesc.ViewType),
". Required view type: TEXTURE_VIEW_SHADER_RESOURCE.");
1450 "' was not created with TEXTURE_VIEW_FLAG_ALLOW_MIP_MAP_GENERATION flag and can't be used to generate mipmaps.");
1456 template <
typename ImplementationTraits>
1462 #ifdef DILIGENT_DEVELOPMENT
1463 DEV_CHECK_ERR(m_pActiveRenderPass ==
nullptr,
"ResolveTextureSubresource command must be used outside of render pass.");
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();
1474 template <
typename ImplementationTraits>
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");
1482 template <
typename ImplementationTraits>
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");
1490 template <
typename ImplementationTraits>
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");
1498 template <
typename ImplementationTraits>
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");
1504 DEV_CHECK_ERR(ValidatedCast<TopLevelASType>(Attribs.
pSrc)->ValidateContent(),
"IDeviceContext::CopyTLAS: pSrc acceleration structure is not valid");
1507 template <
typename ImplementationTraits>
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");
1515 template <
typename ImplementationTraits>
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");
1523 template <
typename ImplementationTraits>
1526 DEV_CHECK_ERR(m_pDevice->GetDeviceCaps().Features.RayTracing,
1527 "IDeviceContext::TraceRays: ray tracing is not supported by this device");
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.");
1533 DEV_CHECK_ERR(m_pActiveRenderPass ==
nullptr,
"IDeviceContext::TraceRays must be performed outside of render pass");
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,
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");
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.");
1549 "SBT '", pSBTImpl->GetDesc().Name,
"' internal buffer is expected to be in RESOURCE_STATE_RAY_TRACING, but current state is ",
1553 "IDeviceContext::TraceRays command arguments are invalid: the dimension must not exceed the ",
1554 m_pDevice->GetProperties().MaxRayGenThreads,
" threads");
1557 template <
typename ImplementationTraits>
1560 DEV_CHECK_ERR(m_pDevice->GetDeviceCaps().Features.RayTracing2,
1561 "IDeviceContext::TraceRaysIndirect: indirect trace rays is not supported by this device");
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.");
1568 "IDeviceContext::TraceRaysIndirect must be performed outside of render pass");
1571 "TraceRaysIndirectAttribs are invalid");
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,
1577 const auto* pSBTImpl = ValidatedCast<const ShaderBindingTableImplType>(Attribs.
pSBT);
1579 "IDeviceContext::TraceRaysIndirect command arguments are invalid: SBT '",
1580 pSBTImpl->GetDesc().Name,
"' has uncommited changes, call UpdateSBT() first");
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.");
1587 "SBT '", pSBTImpl->GetDesc().Name,
"' internal buffer is expected to be in RESOURCE_STATE_RAY_TRACING, but current state is ",
1591 template <
typename ImplementationTraits>
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");
1598 if (pUpdateIndirectBufferAttribs !=
nullptr)
1601 "IDeviceContext::UpdateSBT command arguments are invalid: pUpdateIndirectBufferAttribs->pAttribsBuffer must not be null");
1606 template <
typename ImplementationTraits>
1609 const auto SignCount = m_pPipelineState->GetResourceSignatureCount();
1611 Resources.ActiveSRBMask = 0;
1612 for (
Uint32 i = 0; i < SignCount; ++i)
1614 const auto* pSignature = m_pPipelineState->GetResourceSignature(i);
1615 if (pSignature ==
nullptr || pSignature->GetTotalResourceCount() == 0)
1618 Resources.ActiveSRBMask |= 1u << i;
1621 DvpCompatibleSRBCount = 0;
1623 #ifdef DILIGENT_DEVELOPMENT
1632 for (; DvpCompatibleSRBCount < SignCount; ++DvpCompatibleSRBCount)
1634 const auto pSRB = Resources.SRBs[DvpCompatibleSRBCount].Lock();
1636 const auto* pPSOSign = m_pPipelineState->GetResourceSignature(DvpCompatibleSRBCount);
1637 const auto* pSRBSign = pSRB ? pSRB->GetSignature() :
nullptr;
1639 if ((pPSOSign ==
nullptr || pPSOSign->GetTotalResourceCount() == 0) !=
1640 (pSRBSign ==
nullptr || pSRBSign->GetTotalResourceCount() == 0))
1646 if (pPSOSign !=
nullptr && pSRBSign !=
nullptr && pPSOSign->IsIncompatibleWith(*pSRBSign))
1657 for (
Uint32 sign = DvpCompatibleSRBCount; sign < SignCount; ++sign)
1659 Resources.Set(sign,
nullptr);
1662 Resources.ResourcesValidated =
false;
1666 #ifdef DILIGENT_DEVELOPMENT
1668 template <
typename ImplementationTraits>
1674 DEV_CHECK_ERR(m_pPipelineState,
"Draw command arguments are invalid: no pipeline state is bound.");
1677 "Draw command arguments are invalid: pipeline state '", m_pPipelineState->GetDesc().Name,
"' is not a graphics pipeline.");
1682 template <
typename ImplementationTraits>
1688 DEV_CHECK_ERR(m_pPipelineState,
"DrawIndexed command arguments are invalid: no pipeline state is bound.");
1691 "DrawIndexed command arguments are invalid: pipeline state '",
1692 m_pPipelineState->GetDesc().Name,
"' is not a graphics pipeline.");
1694 DEV_CHECK_ERR(m_pIndexBuffer,
"DrawIndexed command arguments are invalid: no index buffer is bound.");
1699 template <
typename ImplementationTraits>
1705 DEV_CHECK_ERR(m_pDevice->GetDeviceCaps().Features.MeshShaders,
"DrawMesh: mesh shaders are not supported by this device");
1707 DEV_CHECK_ERR(m_pPipelineState,
"DrawMesh command arguments are invalid: no pipeline state is bound.");
1710 "DrawMesh command arguments are invalid: pipeline state '",
1711 m_pPipelineState->GetDesc().Name,
"' is not a mesh pipeline.");
1716 template <
typename ImplementationTraits>
1719 const IBuffer* pAttribsBuffer)
const
1724 DEV_CHECK_ERR(m_pPipelineState,
"DrawIndirect command arguments are invalid: no pipeline state is bound.");
1727 "DrawIndirect command arguments are invalid: pipeline state '",
1728 m_pPipelineState->GetDesc().Name,
"' is not a graphics pipeline.");
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.");
1737 template <
typename ImplementationTraits>
1740 const IBuffer* pAttribsBuffer)
const
1745 DEV_CHECK_ERR(m_pPipelineState,
"DrawIndexedIndirect command arguments are invalid: no pipeline state is bound.");
1748 "DrawIndexedIndirect command arguments are invalid: pipeline state '",
1749 m_pPipelineState->GetDesc().Name,
"' is not a graphics pipeline.");
1751 DEV_CHECK_ERR(m_pIndexBuffer,
"DrawIndexedIndirect command arguments are invalid: no index buffer is bound.");
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.");
1760 template <
typename ImplementationTraits>
1763 const IBuffer* pAttribsBuffer)
const
1768 DEV_CHECK_ERR(m_pDevice->GetDeviceCaps().Features.MeshShaders,
"DrawMeshIndirect: mesh shaders are not supported by this device");
1770 DEV_CHECK_ERR(m_pPipelineState,
"DrawMeshIndirect command arguments are invalid: no pipeline state is bound.");
1773 "DrawMeshIndirect command arguments are invalid: pipeline state '",
1774 m_pPipelineState->GetDesc().Name,
"' is not a mesh pipeline.");
1779 template <
typename ImplementationTraits>
1782 const IBuffer* pAttribsBuffer,
1783 const IBuffer* pCountBuff)
const
1788 DEV_CHECK_ERR(m_pDevice->GetDeviceCaps().Features.MeshShaders,
"DrawMeshIndirectCount: mesh shaders are not supported by this device");
1790 DEV_CHECK_ERR(m_pPipelineState,
"DrawMeshIndirectCount command arguments are invalid: no pipeline state is bound.");
1793 "DrawMeshIndirectCount command arguments are invalid: pipeline state '",
1794 m_pPipelineState->GetDesc().Name,
"' is not a mesh pipeline.");
1797 "DrawMeshIndirectCountAttribs are invalid");
1800 template <
typename ImplementationTraits>
1803 DEV_CHECK_ERR(m_pPipelineState,
"No pipeline state is bound");
1805 const auto& PSODesc = m_pPipelineState->GetDesc();
1807 "Pipeline state '", PSODesc.Name,
"' is not a graphics pipeline");
1812 for (
Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt)
1814 if (
auto* pRT = m_pBoundRenderTargets[rt].RawPtr())
1815 BoundRTVFormats[rt] = pRT->GetDesc().Format;
1820 BoundDSVFormat = m_pBoundDepthStencil ? m_pBoundDepthStencil->GetDesc().Format :
TEX_FORMAT_UNKNOWN;
1822 const auto& GraphicsPipeline = m_pPipelineState->GetGraphicsPipelineDesc();
1823 if (GraphicsPipeline.NumRenderTargets != m_NumBoundRenderTargets)
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},
").");
1830 if (BoundDSVFormat != GraphicsPipeline.DSVFormat)
1833 ") does not match the DSV format specified by the PSO '", PSODesc.
Name,
1837 for (
Uint32 rt = 0; rt < m_NumBoundRenderTargets; ++rt)
1839 auto BoundFmt = BoundRTVFormats[rt];
1840 auto PSOFmt = GraphicsPipeline.RTVFormats[rt];
1841 if (BoundFmt != PSOFmt)
1844 ") does not match the RTV format specified by the PSO '", PSODesc.
Name,
1852 template <
typename ImplementationTraits>
1855 DEV_CHECK_ERR(m_pPipelineState,
"DispatchCompute command arguments are invalid: no pipeline state is bound.");
1858 "DispatchCompute command arguments are invalid: pipeline state '", m_pPipelineState->GetDesc().Name,
1859 "' is not a compute pipeline.");
1862 "DispatchCompute command must be performed outside of render pass");
1867 template <
typename ImplementationTraits>
1870 const IBuffer* pAttribsBuffer)
const
1872 DEV_CHECK_ERR(m_pPipelineState,
"DispatchComputeIndirect command arguments are invalid: no pipeline state is bound.");
1875 "DispatchComputeIndirect command arguments are invalid: pipeline state '",
1876 m_pPipelineState->GetDesc().Name,
"' is not a compute pipeline.");
1878 DEV_CHECK_ERR(m_pActiveRenderPass ==
nullptr,
"DispatchComputeIndirect command must be performed outside of render pass");
1884 template <
typename ImplementationTraits>
1890 template <
typename ImplementationTraits>
1892 const TextureImplType& Texture,
1894 const char* OperationName)
const
1896 if (Texture.IsInKnownState() && !Texture.CheckState(RequiredState))
1900 ". Use appropriate state transiton flags or explicitly transition the texture using IDeviceContext::TransitionResourceStates() method.");
1904 template <
typename ImplementationTraits>
1906 const BufferImplType& Buffer,
1908 const char* OperationName)
const
1910 if (
Buffer.IsInKnownState() && !
Buffer.CheckState(RequiredState))
1914 ". Use appropriate state transiton flags or explicitly transition the buffer using IDeviceContext::TransitionResourceStates() method.");
1918 template <
typename ImplementationTraits>
1920 const BottomLevelASType& BLAS,
1922 const char* OperationName)
const
1924 if (BLAS.IsInKnownState() && !BLAS.CheckState(RequiredState))
1928 ". Use appropriate state transiton flags or explicitly transition the BLAS using IDeviceContext::TransitionResourceStates() method.");
1932 template <
typename ImplementationTraits>
1934 const TopLevelASType& TLAS,
1936 const char* OperationName)
const
1938 if (TLAS.IsInKnownState() && !TLAS.CheckState(RequiredState))
1942 ". Use appropriate state transiton flags or explicitly transition the TLAS using IDeviceContext::TransitionResourceStates() method.");
1946 template <
typename ImplementationTraits>
1947 void DeviceContextBase<ImplementationTraits>::DvpVerifySRBCompatibility(
1948 CommittedShaderResources& Resources,
1949 std::function<PipelineResourceSignatureImplType*(
Uint32)> CustomGetSignature)
const
1951 DEV_CHECK_ERR(m_pPipelineState,
"No PSO is bound in the context");
1953 const auto SignCount = m_pPipelineState->GetResourceSignatureCount();
1954 for (
Uint32 sign = 0; sign < SignCount; ++sign)
1956 const auto*
const pPSOSign = CustomGetSignature ? CustomGetSignature(sign) : m_pPipelineState->GetResourceSignature(sign);
1957 if (pPSOSign ==
nullptr || pPSOSign->GetTotalResourceCount() == 0)
1961 VERIFY_EXPR(pPSOSign->GetDesc().BindingIndex == sign);
1963 const auto pSRB = Resources.SRBs[sign].Lock();
1964 const auto* pCache = Resources.ResourceCaches[sign];
1965 if (pCache !=
nullptr)
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.");
1974 VERIFY(!pSRB,
"Shader resource cache pointer is null, but SRB is not null. This is unexpected and is likely a bug.");
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()?");
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,
"'.");
1989 #endif // DILIGENT_DEVELOPMENT
MAP_FLAGS
Special map flags.
Definition: GraphicsTypes.h:227
virtual struct ITexture *METHOD() GetTexture()
Returns the pointer to the referenced texture object.
@ 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
bool VerifyBuildTLASAttribs(const BuildTLASAttribs &Attribs)
Definition: DeviceContextBase.cpp:510
@ USAGE_STAGING
A resource that facilitates transferring data between GPU and CPU. D3D11 Counterpart: D3D11_USAGE_S...
Definition: GraphicsTypes.h:167
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
typename EngineGLImplTraits ::QueryImplType QueryImplType
Definition: DeviceContextBase.hpp:118
uint32_t uint
Definition: BasicMath.hpp:1826
Base interface for a reference counter object that stores the number of strong and weak references an...
Definition: ReferenceCounters.h:44
bool DvpVerifyRenderTargets() const
Definition: DeviceContextBase.hpp:383
virtual Uint64 GetFrameNumber() const override final
Definition: DeviceContextBase.hpp:235
#define LOG_ERROR_MESSAGE(...)
Definition: Errors.hpp:122
void * PVoid
Definition: BasicTypes.h:56
ITopLevelAS * pSrc
Source top-level AS. Access to the TLAS must be externally synchronized.
Definition: DeviceContext.h:1192
struct TextureDesc TextureDesc
Definition: Texture.h:162
This structure is used by IDeviceContext::UpdateSBT().
Definition: DeviceContext.h:1303
This structure is used by IDeviceContext::TraceRaysIndirect().
Definition: DeviceContext.h:1284
Shader resource binding interface.
Definition: ShaderResourceBinding.h:58
Viewport m_Viewports[MAX_VIEWPORTS]
Current viewports.
Definition: DeviceContextBase.hpp:437
void BeginQuery(IQuery *pQuery, int)
Definition: DeviceContextBase.hpp:1250
void EndQuery(IQuery *pQuery, int)
Definition: DeviceContextBase.hpp:1263
This structure is used by IDeviceContext::TraceRays().
Definition: DeviceContext.h:1267
~DeviceContextBase()
Definition: DeviceContextBase.hpp:139
virtual void ResolveTextureSubresource(ITexture *pSrcTexture, ITexture *pDstTexture, const ResolveTextureSubresourceAttribs &ResolveAttribs) override=0
Definition: DeviceContextBase.hpp:1457
typename EngineGLImplTraits ::ShaderResourceCacheImplType ShaderResourceCacheImplType
Definition: DeviceContextBase.hpp:124
struct TraceRaysIndirectAttribs TraceRaysIndirectAttribs
Definition: DeviceContext.h:1299
BeginRenderPass command attributes.
Definition: DeviceContext.h:731
bool VerifyDrawMeshIndirectCountAttribs(const DrawMeshIndirectCountAttribs &Attribs, const IBuffer *pAttribsBuffer, const IBuffer *pCountBuff, Uint32 IndirectCmdStride)
Definition: DeviceContextBase.cpp:134
bool VerifyDrawMeshAttribs(Uint32 MaxDrawMeshTasksCount, const DrawMeshAttribs &Attribs)
Definition: DeviceContextBase.cpp:78
Shader binding table interface.
Definition: ShaderBindingTable.h:93
Defines the mesh indirect draw count command attributes.
Definition: DeviceContext.h:440
bool VerifyDrawIndexedAttribs(const DrawIndexedAttribs &Attribs)
Definition: DeviceContextBase.cpp:64
Pipeline state interface.
Definition: PipelineState.h:505
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
RESOURCE_STATE_TRANSITION_MODE
Defines resource state transition mode performed by various commands.
Definition: DeviceContext.h:136
@ DRAW_FLAG_VERIFY_DRAW_ATTRIBS
Verify correctness of parameters passed to the draw command.
Definition: DeviceContext.h:79
struct DrawMeshIndirectAttribs DrawMeshIndirectAttribs
Definition: DeviceContext.h:434
Uint32 Flags
Definition: DXBCUtils.cpp:71
void BuildTLAS(const BuildTLASAttribs &Attribs, int) const
Definition: DeviceContextBase.hpp:1483
void MakeAllStale()
Definition: DeviceContextBase.hpp:301
bool DvpVerifyBLASState(const BottomLevelASType &BLAS, RESOURCE_STATE RequiredState, const char *OperationName) const
Definition: DeviceContextBase.hpp:387
virtual const PipelineStateDesc &METHOD() GetDesc() const override=0
Returns the pipeline description used to create the object.
struct DispatchComputeIndirectAttribs DispatchComputeIndirectAttribs
Definition: DeviceContext.h:543
Base interface for all dynamic objects in the engine.
Definition: Object.h:41
VertexStreamInfo< BufferImplType > m_VertexStreams[MAX_BUFFER_SLOTS]
Vertex streams. Every stream holds strong reference to the buffer.
Definition: DeviceContextBase.hpp:412
uint64_t Uint64
64-bit unsigned integer
Definition: BasicTypes.h:50
SRBMaskType StaleSRBMask
Definition: DeviceContextBase.hpp:281
@ MAP_FLAG_DISCARD
Previous contents of the resource will be undefined. This flag is only compatible with MAP_WRITE D3D...
Definition: GraphicsTypes.h:241
This structure is used by IDeviceContext::WriteBLASCompactedSize().
Definition: DeviceContext.h:1217
virtual const TextureViewDesc &METHOD() GetDesc() const override=0
Returns the texture view description used to create the object.
float Float32
32-bit float
Definition: BasicTypes.h:43
#define UNEXPECTED(...)
Definition: DebugUtilities.hpp:77
@ 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
virtual void ResetRenderTargets()
Definition: DeviceContextBase.hpp:1038
@ MAP_FLAG_NO_OVERWRITE
The system will not synchronize pending operations before mapping the buffer. It is responsibility of...
Definition: GraphicsTypes.h:247
This structure is used by IDeviceContext::WriteTLASCompactedSize().
Definition: DeviceContext.h:1242
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
struct DispatchComputeAttribs DispatchComputeAttribs
Definition: DeviceContext.h:517
void Set(Uint32 Index, ShaderResourceBindingImplType *pSRB)
Definition: DeviceContextBase.hpp:283
Uint32 m_FramebufferWidth
Width of the currently bound framebuffer.
Definition: DeviceContextBase.hpp:452
virtual const ShaderBindingTableDesc & GetDesc() const override=0
Returns the shader binding table description that was used to create the object.
typename EngineGLImplTraits ::ShaderBindingTableImplType ShaderBindingTableImplType
Definition: DeviceContextBase.hpp:123
static constexpr Uint32 TraceRaysIndirectCommandSize
Definition: DeviceContextBase.hpp:406
struct DrawIndexedAttribs DrawIndexedAttribs
Definition: DeviceContext.h:285
Texture view interface.
Definition: TextureView.h:202
bool DvpVerifyBufferState(const BufferImplType &Buffer, RESOURCE_STATE RequiredState, const char *OperationName) const
Definition: DeviceContextBase.hpp:386
Defines the mesh draw command attributes.
Definition: DeviceContext.h:376
bool DvpVerifyDrawIndexedIndirectArguments(const DrawIndexedIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer) const
Definition: DeviceContextBase.hpp:376
@ 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
#define DEV_CHECK_ERR(...)
Definition: DebugUtilities.hpp:90
bool HasActiveRenderPass() const
Definition: DeviceContextBase.hpp:260
Box.
Definition: GraphicsTypes.h:2407
Definition: Texture.h:245
bool DvpVerifyDrawMeshIndirectArguments(const DrawMeshIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer) const
Definition: DeviceContextBase.hpp:377
void ClearStateCache()
Clears all cached resources.
Definition: DeviceContextBase.hpp:919
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
typename EngineGLImplTraits ::ShaderResourceBindingImplType ShaderResourceBindingImplType
Definition: DeviceContextBase.hpp:116
typename EngineGLImplTraits ::BufferImplType BufferImplType
Definition: DeviceContextBase.hpp:113
struct StateTransitionDesc StateTransitionDesc
Definition: DeviceContext.h:1444
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
Uint32 m_IndexDataStartOffset
Offset from the beginning of the index buffer to the start of the index data, in bytes.
Definition: DeviceContextBase.hpp:428
typename EngineGLImplTraits ::TextureViewImplType TextureViewImplType
Definition: DeviceContextBase.hpp:117
bool VerifyTraceRaysIndirectAttribs(const IRenderDevice *pDevice, const TraceRaysIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer, Uint32 SBTSize)
Definition: DeviceContextBase.cpp:797
void SetViewports(Uint32 NumViewports, const Viewport *pViewports, Uint32 &RTWidth, Uint32 &RTHeight)
Caches the viewports.
Definition: DeviceContextBase.hpp:641
Uint32 m_NumScissorRects
Number of current scissor rects.
Definition: DeviceContextBase.hpp:444
struct Viewport Viewport
Definition: DeviceContext.h:632
Template class implementing base functionality for an object.
Definition: ObjectBase.hpp:66
bool SetSubpassRenderTargets()
Initializes render targets for the current subpass.
Definition: DeviceContextBase.hpp:823
struct ResolveTextureSubresourceAttribs ResolveTextureSubresourceAttribs
Definition: DeviceContext.h:574
struct CopyBLASAttribs CopyBLASAttribs
Definition: DeviceContext.h:1184
Uint32 m_StencilRef
Current stencil reference value.
Definition: DeviceContextBase.hpp:431
Buffer interface.
Definition: Buffer.h:187
Diligent::Vector2< T > min(const Diligent::Vector2< T > &Left, const Diligent::Vector2< T > &Right)
Definition: BasicMath.hpp:2289
bool SetBlendFactors(const float *BlendFactors, int Dummy)
Definition: DeviceContextBase.hpp:617
ITexture * pSrcTexture
Source texture to copy data from.
Definition: DeviceContext.h:675
@ TEX_FORMAT_UNKNOWN
Unknown format.
Definition: GraphicsTypes.h:331
struct BeginRenderPassAttribs BeginRenderPassAttribs
Definition: DeviceContext.h:763
struct Rect Rect
Definition: DeviceContext.h:666
void CommitShaderResources(IShaderResourceBinding *pShaderResourceBinding, RESOURCE_STATE_TRANSITION_MODE StateTransitionMode, int)
Base implementation of IDeviceContext::CommitShaderResources(); validates parameters.
Definition: DeviceContextBase.hpp:553
typename EngineGLImplTraits ::RenderPassImplType RenderPassImplType
Definition: DeviceContextBase.hpp:120
Uint32 m_SubpassIndex
Current subpass index.
Definition: DeviceContextBase.hpp:471
bool SetStencilRef(Uint32 StencilRef, int Dummy)
Definition: DeviceContextBase.hpp:630
virtual void BeginRenderPass(const BeginRenderPassAttribs &Attribs) override=0
Definition: DeviceContextBase.hpp:1061
void ValidateUpdateTextureParams(const TextureDesc &TexDesc, Uint32 MipLevel, Uint32 Slice, const Box &DstBox, const TextureSubResData &SubresData)
Validates update texture command paramters.
Definition: TextureBase.cpp:226
enum QUERY_TYPE Type
Query type, see Diligent::QUERY_TYPE.
Definition: Query.h:153
Uint64 m_FrameNumber
Definition: DeviceContextBase.hpp:478
Render device interface.
Definition: RenderDevice.h:75
struct CopyTLASAttribs CopyTLASAttribs
Definition: DeviceContext.h:1213
void EndFrame()
Definition: DeviceContextBase.hpp:340
Resource state transition barrier description.
Definition: DeviceContext.h:1333
bool VerifyWriteTLASCompactedSizeAttribs(const IRenderDevice *pDevice, const WriteTLASCompactedSizeAttribs &Attribs)
Definition: DeviceContextBase.cpp:754
struct BuildTLASAttribs BuildTLASAttribs
Definition: DeviceContext.h:1155
void SetPipelineState(PipelineStateImplType *pPipelineState, int)
Definition: DeviceContextBase.hpp:545
String GetResourceStateString(RESOURCE_STATE State)
Definition: GraphicsAccessories.cpp:1080
Uint32 Offset
Offset in bytes.
Definition: DeviceContextBase.hpp:95
typename EngineGLImplTraits ::RenderDeviceImplType DeviceImplType
Definition: DeviceContextBase.hpp:112
void GetViewports(Uint32 &NumViewports, Viewport *pViewports)
Returns currently set viewports.
Definition: DeviceContextBase.hpp:673
#define LOG_INFO_MESSAGE(...)
Definition: Errors.hpp:124
bool DvpVerifyDrawIndexedArguments(const DrawIndexedAttribs &Attribs) const
Definition: DeviceContextBase.hpp:373
bool VerifyDrawAttribs(const DrawAttribs &Attribs)
Definition: DeviceContextBase.cpp:53
RefCntAutoPtr< RenderPassImplType > m_pActiveRenderPass
Strong reference to the render pass.
Definition: DeviceContextBase.hpp:468
SET_VERTEX_BUFFERS_FLAGS
Defines allowed flags for IDeviceContext::SetVertexBuffers() function.
Definition: DeviceContext.h:578
ObjectBase< BaseInterface > TObjectBase
Definition: DeviceContextBase.hpp:111
Uint32 m_FramebufferSamples
Number of samples in the currently bound framebuffer.
Definition: DeviceContextBase.hpp:458
@ 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
virtual void NextSubpass() override=0
Definition: DeviceContextBase.hpp:1113
RefCntAutoPtr< BufferImplType > m_pIndexBuffer
Strong reference to the bound index buffer. Use final buffer implementation type to avoid virtual cal...
Definition: DeviceContextBase.hpp:425
const Char * Name
Literal texture format name (for instance, for TEX_FORMAT_RGBA8_UNORM format, this will be "TEX_FORMA...
Definition: GraphicsTypes.h:2487
Describes multi-sampled texture resolve command arguments.
Definition: DeviceContext.h:549
Describes dispatch command arguments.
Definition: DeviceContext.h:523
Float32 m_BlendFactors[4]
Curent blend factors.
Definition: DeviceContextBase.hpp:434
@ PIPELINE_TYPE_MESH
Mesh pipeline, which is used by IDeviceContext::DrawMesh(), IDeviceContext::DrawMeshIndirect().
Definition: PipelineState.h:305
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
Uint32 m_FramebufferHeight
Height of the currently bound framebuffer.
Definition: DeviceContextBase.hpp:454
bool DvpVerifyTextureState(const TextureImplType &Texture, RESOURCE_STATE RequiredState, const char *OperationName) const
Definition: DeviceContextBase.hpp:385
virtual void InvalidateState() override=0
Definition: DeviceContextBase.hpp:566
@ MAP_READ_WRITE
The resource is mapped for reading and writing. D3D11 counterpart: D3D11_MAP_READ_WRITE....
Definition: GraphicsTypes.h:218
std::array< ShaderResourceCacheImplType *, MAX_RESOURCE_SIGNATURES > ResourceCaches
Definition: DeviceContextBase.hpp:267
Defines the indexed indirect draw command attributes.
Definition: DeviceContext.h:330
struct WriteTLASCompactedSizeAttribs WriteTLASCompactedSizeAttribs
Definition: DeviceContext.h:1263
static constexpr Uint32 DrawMeshIndirectCommandStride
Definition: DeviceContextBase.hpp:402
#define IMPLEMENT_QUERY_INTERFACE_IN_PLACE(InterfaceID, ParentClassName)
Definition: ObjectBase.hpp:59
@ RESOURCE_STATE_RAY_TRACING
The resource is used as a top-level AS shader resource in a trace rays operation.
Definition: GraphicsTypes.h:2878
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
void TraceRays(const TraceRaysAttribs &Attribs, int) const
Definition: DeviceContextBase.hpp:1524
struct TraceRaysAttribs TraceRaysAttribs
Definition: DeviceContext.h:1280
n int Dummy
Definition: GenerateMipsCS_inc.h:25
@ 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
VertexStreamInfo()
Definition: DeviceContextBase.hpp:89
bool DvpVerifyDispatchIndirectArguments(const DispatchComputeIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer) const
Definition: DeviceContextBase.hpp:381
#define DILIGENT_CALL_TYPE
Definition: CommonDefinitions.h:45
struct DrawMeshIndirectCountAttribs DrawMeshIndirectCountAttribs
Definition: DeviceContext.h:477
static constexpr Uint32 TraceRaysIndirectCommandSBTSize
Definition: DeviceContextBase.hpp:404
@ PIPELINE_TYPE_COMPUTE
Compute pipeline, which is used by IDeviceContext::DispatchCompute(), IDeviceContext::DispatchCompute...
Definition: PipelineState.h:302
bool DvpVerifyStateTransitionDesc(const StateTransitionDesc &Barrier) const
Definition: DeviceContextBase.hpp:384
bool DvpVerifyDrawMeshIndirectCountArguments(const DrawMeshIndirectCountAttribs &Attribs, const IBuffer *pAttribsBuffer, const IBuffer *pCountBuff) const
Definition: DeviceContextBase.hpp:378
@ CPU_ACCESS_WRITE
A resource can be mapped for writing.
Definition: GraphicsTypes.h:195
This structure is used by IDeviceContext::BuildTLAS().
Definition: DeviceContext.h:1082
@ 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
typename EngineGLImplTraits ::PipelineStateImplType PipelineStateImplType
Definition: DeviceContextBase.hpp:115
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Defines the mesh indirect draw command attributes.
Definition: DeviceContext.h:402
Uint32 DimensionX
The number of rays dispatched in X direction.
Definition: DeviceContext.h:1272
typename EngineGLImplTraits ::TopLevelASImplType TopLevelASType
Definition: DeviceContextBase.hpp:122
bool VerifyStateTransitionDesc(const IRenderDevice *pDevice, const StateTransitionDesc &Barrier)
Definition: DeviceContextBase.cpp:266
Uint32 DimensionY
The number of rays dispatched in Y direction.
Definition: DeviceContext.h:1273
Base implementation of the device context.
Definition: DeviceContextBase.hpp:107
@ MAP_WRITE
The resource is mapped for writing. D3D11 counterpart: D3D11_MAP_WRITE. OpenGL counterpart: GL_MAP_...
Definition: GraphicsTypes.h:214
void CopyBLAS(const CopyBLASAttribs &Attribs, int) const
Definition: DeviceContextBase.hpp:1491
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
Describes the viewport.
Definition: DeviceContext.h:593
Describes dispatch command arguments.
Definition: DeviceContext.h:500
@ MAP_READ
The resource is mapped for reading. D3D11 counterpart: D3D11_MAP_READ. OpenGL counterpart: GL_MAP_R...
Definition: GraphicsTypes.h:210
@ RESOURCE_STATE_UNKNOWN
The resource state is not known to the engine and is managed by the application.
Definition: GraphicsTypes.h:2817
ITexture * pDstTexture
Destination texture.
Definition: DeviceContext.h:690
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
struct DrawMeshAttribs DrawMeshAttribs
Definition: DeviceContext.h:396
bool DvpVerifyDispatchArguments(const DispatchComputeAttribs &Attribs) const
Definition: DeviceContextBase.hpp:380
void GetPipelineState(IPipelineState **ppPSO, float *BlendFactors, Uint32 &StencilRef)
Returns currently bound pipeline state and blend factors.
Definition: DeviceContextBase.hpp:598
This structure is used by IDeviceContext::BuildBLAS().
Definition: DeviceContext.h:925
This structure is used by IDeviceContext::CopyBLAS().
Definition: DeviceContext.h:1159
@ 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
@ CPU_ACCESS_READ
A resource can be mapped for reading.
Definition: GraphicsTypes.h:194
bool VerifyDrawMeshIndirectAttribs(const DrawMeshIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer)
Definition: DeviceContextBase.cpp:120
bool VerifyCopyTLASAttribs(const CopyTLASAttribs &Attribs)
Definition: DeviceContextBase.cpp:697
IRenderPass * pRenderPass
Render pass to begin.
Definition: DeviceContext.h:734
TEXTURE_FORMAT
Texture formats.
Definition: GraphicsTypes.h:328
virtual void UnmapTextureSubresource(ITexture *pTexture, Uint32 MipLevel, Uint32 ArraySlice) override=0
Base implementaiton of IDeviceContext::UnmapTextureSubresource()
Definition: DeviceContextBase.hpp:1429
RESOURCE_STATE_TRANSITION_MODE m_RenderPassAttachmentsTransitionMode
Render pass attachments transition mode.
Definition: DeviceContextBase.hpp:474
RefCntAutoPtr< TextureViewImplType > m_pBoundDepthStencil
Strong references to the bound depth stencil view. Use final texture view implementation type to avoi...
Definition: DeviceContextBase.hpp:462
void GetRenderTargets(Uint32 &NumRenderTargets, ITextureView **ppRTVs, ITextureView **ppDSV)
Returns currently bound render targets.
Definition: DeviceContextBase.hpp:883
virtual void GenerateMips(ITextureView *pTexView) override=0
Definition: DeviceContextBase.hpp:1440
void SetScissorRects(Uint32 NumRects, const Rect *pRects, Uint32 &RTWidth, Uint32 &RTHeight)
Caches the scissor rects.
Definition: DeviceContextBase.hpp:684
Defines the indirect draw command attributes.
Definition: DeviceContext.h:291
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
typename EngineGLImplTraits ::BottomLevelASImplType BottomLevelASType
Definition: DeviceContextBase.hpp:121
#define LOG_WARNING_MESSAGE(...)
Definition: Errors.hpp:123
DRAW_FLAGS Flags
Additional flags, see Diligent::DRAW_FLAGS.
Definition: DeviceContext.h:175
Describes input vertex stream.
Definition: DeviceContextBase.hpp:87
bool VerifyWriteBLASCompactedSizeAttribs(const IRenderDevice *pDevice, const WriteBLASCompactedSizeAttribs &Attribs)
Definition: DeviceContextBase.cpp:730
Committed shader resources for each resource signature.
Definition: DeviceContextBase.hpp:264
IBuffer * pAttribsBuffer
Indirect buffer that can be used by IDeviceContext::TraceRaysIndirect() command.
Definition: DeviceContext.h:1306
@ BIND_DEPTH_STENCIL
A texture can be bound as a depth-stencil target.
Definition: GraphicsTypes.h:126
This structure is used by IDeviceContext::CopyTLAS().
Definition: DeviceContext.h:1188
bool VerifyDispatchComputeAttribs(const DispatchComputeAttribs &Attribs)
Definition: DeviceContextBase.cpp:160
Defines the indexed draw command attributes.
Definition: DeviceContext.h:224
RefCntAutoPtr< PipelineStateImplType > m_pPipelineState
Strong reference to the bound pipeline state object. Use final PSO implementation type to avoid virtu...
Definition: DeviceContextBase.hpp:421
Uint32 DimensionZ
The number of rays dispatched in Z direction.
Definition: DeviceContext.h:1274
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
RefCntAutoPtr< BufferImplType > pBuffer
Strong reference to the buffer object.
Definition: DeviceContextBase.hpp:92
typename EngineGLImplTraits ::TextureImplType TextureImplType
Definition: DeviceContextBase.hpp:114
const IShaderBindingTable * pSBT
Shader binding table.
Definition: DeviceContext.h:1287
void ClearDepthStencil(ITextureView *pView)
Definition: DeviceContextBase.hpp:1171
bool CheckIfBoundAsRenderTarget(TextureImplType *pTexture)
Checks if the texture is currently bound as a render target.
Definition: DeviceContextBase.hpp:958
Diligent::Vector2< T > max(const Diligent::Vector2< T > &Left, const Diligent::Vector2< T > &Right)
Definition: BasicMath.hpp:2261
void BuildBLAS(const BuildBLASAttribs &Attribs, int) const
Definition: DeviceContextBase.hpp:1475
@ 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
void UpdateSBT(IShaderBindingTable *pSBT, const UpdateIndirectRTBufferAttribs *pUpdateIndirectBufferAttribs, int) const
Definition: DeviceContextBase.hpp:1592
@ BIND_VERTEX_BUFFER
A buffer can be bound as a vertex buffer.
Definition: GraphicsTypes.h:118
virtual void EndRenderPass() override=0
Definition: DeviceContextBase.hpp:1153
Query interface.
Definition: Query.h:177
Uint32 m_NumViewports
Number of current viewports.
Definition: DeviceContextBase.hpp:439
uint8_t Uint8
8-bit unsigned integer
Definition: BasicTypes.h:53
bool CheckIfBoundAsDepthStencil(TextureImplType *pTexture)
Checks if the texture is currently bound as depth-stencil buffer.
Definition: DeviceContextBase.hpp:975
#define VERIFY_EXPR(...)
Definition: DebugUtilities.hpp:79
struct BuildBLASAttribs BuildBLASAttribs
Definition: DeviceContext.h:982
void ValidateCopyTextureParams(const CopyTextureAttribs &CopyAttribs)
Validates copy texture command paramters.
Definition: TextureBase.cpp:264
IPipelineState * pPSO
Ray tracing pipeline state object from which shaders will be taken.
Definition: ShaderBindingTable.h:53
typename EngineGLImplTraits ::DeviceContextInterface BaseInterface
Definition: DeviceContextBase.hpp:110
#define VERIFY(...)
Definition: DebugUtilities.hpp:76
bool VerifyCopyBLASAttribs(const IRenderDevice *pDevice, const CopyBLASAttribs &Attribs)
Definition: DeviceContextBase.cpp:609
Describes the rectangle.
Definition: DeviceContext.h:642
@ BIND_RENDER_TARGET
A texture can be bound as a render target.
Definition: GraphicsTypes.h:125
Rect m_ScissorRects[MAX_VIEWPORTS]
Current scissor rects.
Definition: DeviceContextBase.hpp:442
bool VerifyDrawIndirectAttribs(const DrawIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer)
Definition: DeviceContextBase.cpp:91
void TraceRaysIndirect(const TraceRaysIndirectAttribs &Attribs, IBuffer *pAttribsBuffer, int) const
Definition: DeviceContextBase.hpp:1558
@ QUERY_TYPE_TIMESTAMP
Gets the GPU timestamp corresponding to IDeviceContext::EndQuery call. Fot this query type IDeviceCon...
Definition: GraphicsTypes.h:1462
virtual const TextureDesc &METHOD() GetDesc() const override=0
Returns the texture description used to create the object.
bool VerifyResolveTextureSubresourceAttribs(const ResolveTextureSubresourceAttribs &ResolveAttribs, const TextureDesc &SrcTexDesc, const TextureDesc &DstTexDesc)
Definition: DeviceContextBase.cpp:187
bool DvpVerifyTLASState(const TopLevelASType &TLAS, RESOURCE_STATE RequiredState, const char *OperationName) const
Definition: DeviceContextBase.hpp:388
Defines the draw command attributes.
Definition: DeviceContext.h:169
Uint32 m_FramebufferSlices
Number of array slices in the currently bound framebuffer.
Definition: DeviceContextBase.hpp:456
SRBMaskType ActiveSRBMask
Definition: DeviceContextBase.hpp:280
bool IsDeferred() const
Definition: DeviceContextBase.hpp:254
bool VerifyDrawIndexedIndirectAttribs(const DrawIndexedIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer)
Definition: DeviceContextBase.cpp:104
IFramebuffer * pFramebuffer
Framebuffer containing the attachments that are used with the render pass.
Definition: DeviceContext.h:737
Uint32 m_NumVertexStreams
Number of bound vertex streams.
Definition: DeviceContextBase.hpp:415
void UpdateAttachmentStates(Uint32 SubpassIndex)
Updates the states of render pass attachments to match states within the gievn subpass.
Definition: DeviceContextBase.hpp:1123
void CopyTLAS(const CopyTLASAttribs &Attribs, int) const
Definition: DeviceContextBase.hpp:1499
void PrepareCommittedResources(CommittedShaderResources &Resources, Uint32 &DvpCompatibleSRBCount)
Definition: DeviceContextBase.hpp:1607
RESOURCE_STATE
Resource usage state.
Definition: GraphicsTypes.h:2814
RESOURCE_STATE_TRANSITION_MODE StateTransitionMode
Framebuffer attachments state transition mode before the render pass begins.
Definition: DeviceContext.h:761
bool VerifyBuildBLASAttribs(const BuildBLASAttribs &Attribs)
Definition: DeviceContextBase.cpp:358
void WriteBLASCompactedSize(const WriteBLASCompactedSizeAttribs &Attribs, int) const
Definition: DeviceContextBase.hpp:1508
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
struct DrawIndexedIndirectAttribs DrawIndexedIndirectAttribs
Definition: DeviceContext.h:370
RefCntAutoPtr< FramebufferImplType > m_pBoundFramebuffer
Strong reference to the bound framebuffer.
Definition: DeviceContextBase.hpp:465
@ BIND_INDEX_BUFFER
A buffer can be bound as an index buffer.
Definition: GraphicsTypes.h:119
virtual const QueryDesc &METHOD() GetDesc() const override=0
Returns the Query description used to create the object.
const bool m_bIsDeferred
Definition: DeviceContextBase.hpp:476
MAP_TYPE
Resource mapping type.
Definition: GraphicsTypes.h:206
Defines copy texture command attributes.
Definition: DeviceContext.h:672
virtual void UnmapBuffer(IBuffer *pBuffer, MAP_TYPE MapType) override=0
Base implementation of IDeviceContext::UnmapBuffer()
Definition: DeviceContextBase.hpp:1374
void ClearRenderTarget(ITextureView *pView)
Definition: DeviceContextBase.hpp:1208
const TextureFormatAttribs & GetTextureFormatAttribs(TEXTURE_FORMAT Format)
Returns invariant texture format attributes, see TextureFormatAttribs for details.
Definition: GraphicsAccessories.cpp:250
IRenderDevice * GetDevice()
Returns the render device.
Definition: DeviceContextBase.hpp:250
RefCntAutoPtr< DeviceImplType > m_pDevice
Strong reference to the device.
Definition: DeviceContextBase.hpp:409
@ 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
virtual void CopyTexture(const CopyTextureAttribs &CopyAttribs) override=0
Base implementaiton of IDeviceContext::CopyTexture(); validates input parameters.
Definition: DeviceContextBase.hpp:1405
#define ATTACHMENT_UNUSED
Definition: RenderPass.h:143
struct WriteBLASCompactedSizeAttribs WriteBLASCompactedSizeAttribs
Definition: DeviceContext.h:1238
bool DvpVerifyDrawIndirectArguments(const DrawIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer) const
Definition: DeviceContextBase.hpp:375
@ 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
Uint8 SRBMaskType
Definition: DeviceContextBase.hpp:277
Texture inteface.
Definition: Texture.h:273
struct DrawIndirectAttribs DrawIndirectAttribs
Definition: DeviceContext.h:324
typename EngineGLImplTraits ::FramebufferImplType FramebufferImplType
Definition: DeviceContextBase.hpp:119
@ PIPELINE_TYPE_GRAPHICS
Graphics pipeline, which is used by IDeviceContext::Draw(), IDeviceContext::DrawIndexed(),...
Definition: PipelineState.h:299
void WriteTLASCompactedSize(const WriteTLASCompactedSizeAttribs &Attribs, int) const
Definition: DeviceContextBase.hpp:1516
Uint32 m_NumBoundRenderTargets
Number of bound render targets.
Definition: DeviceContextBase.hpp:450
virtual const BufferDesc &METHOD() GetDesc() const override=0
Returns the buffer description used to create the object.
const Char * Name
Object name.
Definition: GraphicsTypes.h:1199
bool DvpVerifyDrawMeshArguments(const DrawMeshAttribs &Attribs) const
Definition: DeviceContextBase.hpp:374
bool VerifyBeginRenderPassAttribs(const BeginRenderPassAttribs &Attribs)
Definition: DeviceContextBase.cpp:231
typename EngineGLImplTraits ::PipelineResourceSignatureImplType PipelineResourceSignatureImplType
Definition: DeviceContextBase.hpp:125
struct DrawAttribs DrawAttribs
Definition: DeviceContext.h:218
DeviceContextBase(IReferenceCounters *pRefCounters, DeviceImplType *pRenderDevice, bool bIsDeferred)
Definition: DeviceContextBase.hpp:130
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
const IShaderBindingTable * pSBT
Shader binding table.
Definition: DeviceContext.h:1270
Uint32 SampleCount
Number of samples. Only 2D textures or 2D texture arrays can be multisampled.
Definition: Texture.h:76
bool VerifyDispatchComputeIndirectAttribs(const DispatchComputeIndirectAttribs &Attribs, const IBuffer *pAttribsBuffer)
Definition: DeviceContextBase.cpp:173
Describes data for one subresource.
Definition: Texture.h:165
@ 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
bool DvpVerifyDrawArguments(const DrawAttribs &Attribs) const
Definition: DeviceContextBase.hpp:372
bool VerifyTraceRaysAttribs(const TraceRaysAttribs &Attribs)
Definition: DeviceContextBase.cpp:778