summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D11
diff options
context:
space:
mode:
authorazhirnov <zh1dron@gmail.com>2020-10-28 16:33:03 +0000
committerazhirnov <zh1dron@gmail.com>2020-10-28 18:04:08 +0000
commit135d5dc6743fc89d7a19c539fa06eca33506f51b (patch)
tree9c8ed6e0d40a010f20657e62acbe955fba0757da /Graphics/GraphicsEngineD3D11
parentFixed vexing gcc/clang liker error (diff)
downloadDiligentCore-135d5dc6743fc89d7a19c539fa06eca33506f51b.tar.gz
DiligentCore-135d5dc6743fc89d7a19c539fa06eca33506f51b.zip
added ray tracing implementation for dx12 and vulkan
Diffstat (limited to 'Graphics/GraphicsEngineD3D11')
-rw-r--r--Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp4
-rwxr-xr-xGraphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp61
2 files changed, 36 insertions, 29 deletions
diff --git a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp
index 6b613458..5e69da8e 100644
--- a/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp
+++ b/Graphics/GraphicsEngineD3D11/include/DeviceContextD3D11Impl.hpp
@@ -41,6 +41,8 @@
#include "FramebufferD3D11Impl.hpp"
#include "RenderPassD3D11Impl.hpp"
#include "DisjointQueryPool.hpp"
+#include "BottomLevelASBase.hpp"
+#include "TopLevelASBase.hpp"
#ifdef DILIGENT_DEBUG
# define VERIFY_CONTEXT_BINDINGS
@@ -58,6 +60,8 @@ struct DeviceContextD3D11ImplTraits
using QueryType = QueryD3D11Impl;
using FramebufferType = FramebufferD3D11Impl;
using RenderPassType = RenderPassD3D11Impl;
+ using BottomLevelASType = BottomLevelASBase<IBottomLevelAS, RenderDeviceD3D11Impl>;
+ using TopLevelASType = TopLevelASBase<ITopLevelAS, RenderDeviceD3D11Impl>;
};
/// Device context implementation in Direct3D11 backend.
diff --git a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp
index 9286f3f8..e42dd2d0 100755
--- a/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp
+++ b/Graphics/GraphicsEngineD3D11/src/DeviceContextD3D11Impl.cpp
@@ -2157,7 +2157,6 @@ void DeviceContextD3D11Impl::TransitionResourceStates(Uint32 BarrierCount, State
#ifdef DILIGENT_DEVELOPMENT
DvpVerifyStateTransitionDesc(Barrier);
#endif
- DEV_CHECK_ERR((Barrier.pTexture != nullptr) ^ (Barrier.pBuffer != nullptr), "Exactly one of pTexture or pBuffer must not be null");
DEV_CHECK_ERR(Barrier.NewState != RESOURCE_STATE_UNKNOWN, "New resource state can't be unknown");
if (Barrier.TransitionType == STATE_TRANSITION_TYPE_BEGIN)
@@ -2168,28 +2167,28 @@ void DeviceContextD3D11Impl::TransitionResourceStates(Uint32 BarrierCount, State
}
VERIFY(Barrier.TransitionType == STATE_TRANSITION_TYPE_IMMEDIATE || Barrier.TransitionType == STATE_TRANSITION_TYPE_END, "Unexpected barrier type");
- if (Barrier.pTexture)
+ RefCntAutoPtr<TextureBaseD3D11> pTexture{Barrier.pResource, IID_TextureD3D11};
+ if (pTexture)
{
- auto* pTextureD3D11Impl = ValidatedCast<TextureBaseD3D11>(Barrier.pTexture);
- auto OldState = Barrier.OldState;
+ auto OldState = Barrier.OldState;
if (OldState == RESOURCE_STATE_UNKNOWN)
{
- if (pTextureD3D11Impl->IsInKnownState())
+ if (pTexture->IsInKnownState())
{
- OldState = pTextureD3D11Impl->GetState();
+ OldState = pTexture->GetState();
}
else
{
- LOG_ERROR_MESSAGE("Failed to transition the state of texture '", pTextureD3D11Impl->GetDesc().Name, "' because the buffer state is unknown and is not explicitly specified");
+ LOG_ERROR_MESSAGE("Failed to transition the state of texture '", pTexture->GetDesc().Name, "' because the buffer state is unknown and is not explicitly specified");
continue;
}
}
else
{
- if (pTextureD3D11Impl->IsInKnownState() && pTextureD3D11Impl->GetState() != OldState)
+ if (pTexture->IsInKnownState() && pTexture->GetState() != OldState)
{
- LOG_ERROR_MESSAGE("The state ", GetResourceStateString(pTextureD3D11Impl->GetState()), " of texture '",
- pTextureD3D11Impl->GetDesc().Name, "' does not match the old state ", GetResourceStateString(OldState),
+ LOG_ERROR_MESSAGE("The state ", GetResourceStateString(pTexture->GetState()), " of texture '",
+ pTexture->GetDesc().Name, "' does not match the old state ", GetResourceStateString(OldState),
" specified by the barrier");
}
}
@@ -2197,52 +2196,53 @@ void DeviceContextD3D11Impl::TransitionResourceStates(Uint32 BarrierCount, State
if ((Barrier.NewState & RESOURCE_STATE_UNORDERED_ACCESS) != 0)
{
DEV_CHECK_ERR((Barrier.NewState & (RESOURCE_STATE_GENERIC_READ | RESOURCE_STATE_INPUT_ATTACHMENT)) == 0, "Unordered access state is not compatible with any input state");
- UnbindTextureFromInput(pTextureD3D11Impl, pTextureD3D11Impl->GetD3D11Texture());
+ UnbindTextureFromInput(pTexture, pTexture->GetD3D11Texture());
}
if ((Barrier.NewState & (RESOURCE_STATE_GENERIC_READ | RESOURCE_STATE_INPUT_ATTACHMENT)) != 0)
{
if ((OldState & RESOURCE_STATE_RENDER_TARGET) != 0)
- UnbindTextureFromRenderTarget(pTextureD3D11Impl);
+ UnbindTextureFromRenderTarget(pTexture);
if ((OldState & RESOURCE_STATE_DEPTH_WRITE) != 0)
- UnbindTextureFromDepthStencil(pTextureD3D11Impl);
+ UnbindTextureFromDepthStencil(pTexture);
if ((OldState & RESOURCE_STATE_UNORDERED_ACCESS) != 0)
{
- UnbindResourceFromUAV(pTextureD3D11Impl, pTextureD3D11Impl->GetD3D11Texture());
- pTextureD3D11Impl->ClearState(RESOURCE_STATE_UNORDERED_ACCESS);
+ UnbindResourceFromUAV(pTexture, pTexture->GetD3D11Texture());
+ pTexture->ClearState(RESOURCE_STATE_UNORDERED_ACCESS);
}
}
if (Barrier.UpdateResourceState)
{
- pTextureD3D11Impl->SetState(Barrier.NewState);
+ pTexture->SetState(Barrier.NewState);
}
+ continue;
}
- else
+
+ RefCntAutoPtr<BufferD3D11Impl> pBuffer{Barrier.pResource, IID_BufferD3D11};
+ if (pBuffer)
{
- VERIFY_EXPR(Barrier.pBuffer);
- auto* pBufferD3D11Impl = ValidatedCast<BufferD3D11Impl>(Barrier.pBuffer);
- auto OldState = Barrier.OldState;
+ auto OldState = Barrier.OldState;
if (OldState == RESOURCE_STATE_UNKNOWN)
{
- if (pBufferD3D11Impl->IsInKnownState())
+ if (pBuffer->IsInKnownState())
{
- OldState = pBufferD3D11Impl->GetState();
+ OldState = pBuffer->GetState();
}
else
{
- LOG_ERROR_MESSAGE("Failed to transition the state of buffer '", pBufferD3D11Impl->GetDesc().Name, "' because the buffer state is unknown and is not explicitly specified");
+ LOG_ERROR_MESSAGE("Failed to transition the state of buffer '", pBuffer->GetDesc().Name, "' because the buffer state is unknown and is not explicitly specified");
continue;
}
}
else
{
- if (pBufferD3D11Impl->IsInKnownState() && pBufferD3D11Impl->GetState() != OldState)
+ if (pBuffer->IsInKnownState() && pBuffer->GetState() != OldState)
{
- LOG_ERROR_MESSAGE("The state ", GetResourceStateString(pBufferD3D11Impl->GetState()), " of buffer '",
- pBufferD3D11Impl->GetDesc().Name, "' does not match the old state ", GetResourceStateString(OldState),
+ LOG_ERROR_MESSAGE("The state ", GetResourceStateString(pBuffer->GetState()), " of buffer '",
+ pBuffer->GetDesc().Name, "' does not match the old state ", GetResourceStateString(OldState),
" specified by the barrier");
}
}
@@ -2250,19 +2250,22 @@ void DeviceContextD3D11Impl::TransitionResourceStates(Uint32 BarrierCount, State
if ((Barrier.NewState & RESOURCE_STATE_UNORDERED_ACCESS) != 0)
{
DEV_CHECK_ERR((Barrier.NewState & RESOURCE_STATE_GENERIC_READ) == 0, "Unordered access state is not compatible with any input state");
- UnbindBufferFromInput(pBufferD3D11Impl, pBufferD3D11Impl->m_pd3d11Buffer);
+ UnbindBufferFromInput(pBuffer, pBuffer->m_pd3d11Buffer);
}
if ((Barrier.NewState & RESOURCE_STATE_GENERIC_READ) != 0)
{
- UnbindResourceFromUAV(pBufferD3D11Impl, pBufferD3D11Impl->m_pd3d11Buffer);
+ UnbindResourceFromUAV(pBuffer, pBuffer->m_pd3d11Buffer);
}
if (Barrier.UpdateResourceState)
{
- pBufferD3D11Impl->SetState(Barrier.NewState);
+ pBuffer->SetState(Barrier.NewState);
}
+ continue;
}
+
+ UNEXPECTED("unsupported resource type");
}
}