summaryrefslogtreecommitdiff
path: root/tools/gfx/d3d12/d3d12-command-buffer.h
diff options
context:
space:
mode:
authorlucy96chen <47800040+lucy96chen@users.noreply.github.com>2022-05-17 10:56:14 -0700
committerGitHub <noreply@github.com>2022-05-17 10:56:14 -0700
commit5a3aa6159e0ef0241b528812e1d138f0d7055f22 (patch)
tree71d286e06030ee73f0b739e071cd58dd05d507d1 /tools/gfx/d3d12/d3d12-command-buffer.h
parent716e75b9ed1acfaee3dc7f3bc347ad17fca65e05 (diff)
Split render-d3d12.h/cpp into a set of smaller files (#2231)
* Split render-d3d12 into numerous smaller files to make the code easier to parse * Added all new D3D12 files created from splitting render-d3d12 * Fixed several uses of attachment still floating around; Changed resource-d3d12 and descriptor-heap-d3d12 to match naming conventions of new d3d12 implementation header files * Readded files with name changes because changing them from inside VS apparently results in them being treated as new files * Merged in externals changes from master * Small cleanup changes * Rerun CI Co-authored-by: Theresa Foley <10618364+tangent-vector@users.noreply.github.com>
Diffstat (limited to 'tools/gfx/d3d12/d3d12-command-buffer.h')
-rw-r--r--tools/gfx/d3d12/d3d12-command-buffer.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/tools/gfx/d3d12/d3d12-command-buffer.h b/tools/gfx/d3d12/d3d12-command-buffer.h
new file mode 100644
index 000000000..dbe019807
--- /dev/null
+++ b/tools/gfx/d3d12/d3d12-command-buffer.h
@@ -0,0 +1,84 @@
+// d3d12-command-buffer.h
+#pragma once
+
+#include "d3d12-base.h"
+#include "d3d12-shader-object.h"
+#include "d3d12-command-encoder.h"
+
+#ifndef __ID3D12GraphicsCommandList1_FWD_DEFINED__
+// If can't find a definition of CommandList1, just use an empty definition
+struct ID3D12GraphicsCommandList1
+{};
+#endif
+
+namespace gfx
+{
+namespace d3d12
+{
+
+using namespace Slang;
+
+class CommandBufferImpl
+ : public ICommandBufferD3D12
+ , public ComObject
+{
+public:
+ // There are a pair of cyclic references between a `TransientResourceHeap` and
+ // a `CommandBuffer` created from the heap. We need to break the cycle upon
+ // the public reference count of a command buffer dropping to 0.
+ SLANG_COM_OBJECT_IUNKNOWN_ALL
+
+ ICommandBufferD3D12* getInterface(const Guid& guid);
+ virtual void comFree() override { m_transientHeap.breakStrongReference(); }
+
+ virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(InteropHandle* handle) override;
+
+public:
+ ComPtr<ID3D12GraphicsCommandList> m_cmdList;
+ ComPtr<ID3D12GraphicsCommandList1> m_cmdList1;
+ ComPtr<ID3D12GraphicsCommandList4> m_cmdList4;
+
+ BreakableReference<TransientResourceHeapImpl> m_transientHeap;
+ // Weak reference is fine here since `m_transientHeap` already holds strong reference to
+ // device.
+ DeviceImpl* m_renderer;
+ RootShaderObjectImpl m_rootShaderObject;
+ RefPtr<MutableRootShaderObjectImpl> m_mutableRootShaderObject;
+ bool m_descriptorHeapsBound = false;
+
+ void bindDescriptorHeaps();
+
+ virtual SLANG_NO_THROW void SLANG_MCALL invalidateDescriptorHeapBinding() override { m_descriptorHeapsBound = false; }
+
+ void reinit();
+
+ void init(
+ DeviceImpl* renderer,
+ ID3D12GraphicsCommandList* d3dCommandList,
+ TransientResourceHeapImpl* transientHeap);
+
+ ResourceCommandEncoderImpl m_resourceCommandEncoder;
+
+ virtual SLANG_NO_THROW void SLANG_MCALL
+ encodeResourceCommands(IResourceCommandEncoder** outEncoder) override;
+
+ RenderCommandEncoderImpl m_renderCommandEncoder;
+ virtual SLANG_NO_THROW void SLANG_MCALL encodeRenderCommands(
+ IRenderPassLayout* renderPass,
+ IFramebuffer* framebuffer,
+ IRenderCommandEncoder** outEncoder) override;
+
+ ComputeCommandEncoderImpl m_computeCommandEncoder;
+ virtual SLANG_NO_THROW void SLANG_MCALL
+ encodeComputeCommands(IComputeCommandEncoder** outEncoder) override;
+
+#if SLANG_GFX_HAS_DXR_SUPPORT
+ RayTracingCommandEncoderImpl m_rayTracingCommandEncoder;
+#endif
+ virtual SLANG_NO_THROW void SLANG_MCALL
+ encodeRayTracingCommands(IRayTracingCommandEncoder** outEncoder) override;
+ virtual SLANG_NO_THROW void SLANG_MCALL close() override;
+};
+
+} // namespace d3d12
+} // namespace gfx