yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1// d3d12-command-buffer.h 2#pragma once 3 4#include "d3d12-base.h" 5#include "d3d12-command-encoder.h" 6#include "d3d12-shader-object.h" 7 8#ifndef __ID3D12GraphicsCommandList1_FWD_DEFINED__ 9// If can't find a definition of CommandList1, just use an empty definition 10struct ID3D12GraphicsCommandList1 11{ 12}; 13#endif 14 15namespace gfx 16{ 17namespace d3d12 18{ 19 20using namespace Slang ; 21 22class CommandBufferImpl :public ICommandBufferD3D12 ,public ComObject 23{ 24public : 25// There are a pair of cyclic references between a `TransientResourceHeap` and 26// a `CommandBuffer` created from the heap. We need to break the cycle upon 27// the public reference count of a command buffer dropping to 0. 28SLANG_COM_OBJECT_IUNKNOWN_ALL 29 30ICommandBufferD3D12 * getInterface (const Guid & guid ); 31virtual void comFree ()override {m_transientHeap .breakStrongReference (); } 32 33virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle (InteropHandle * handle )override ; 34 35public : 36ComPtr < ID3D12GraphicsCommandList > m_cmdList ; 37ComPtr < ID3D12GraphicsCommandList1 > m_cmdList1 ; 38ComPtr < ID3D12GraphicsCommandList4 > m_cmdList4 ; 39ComPtr < ID3D12GraphicsCommandList6 > m_cmdList6 ; 40 41BreakableReference < TransientResourceHeapImpl > m_transientHeap ; 42// Weak reference is fine here since `m_transientHeap` already holds strong reference to 43// device. 44DeviceImpl * m_renderer ; 45RootShaderObjectImpl m_rootShaderObject ; 46RefPtr < MutableRootShaderObjectImpl > m_mutableRootShaderObject ; 47bool m_descriptorHeapsBound = false; 48 49void bindDescriptorHeaps (); 50 51virtual SLANG_NO_THROW void SLANG_MCALL invalidateDescriptorHeapBinding ()override 52 { 53m_descriptorHeapsBound = false; 54 } 55virtual SLANG_NO_THROW void SLANG_MCALL ensureInternalDescriptorHeapsBound ()override 56 { 57bindDescriptorHeaps (); 58 } 59 60void reinit (); 61 62void init ( 63DeviceImpl * renderer , 64ID3D12GraphicsCommandList * d3dCommandList , 65TransientResourceHeapImpl * transientHeap ); 66 67ResourceCommandEncoderImpl m_resourceCommandEncoder ; 68 69virtual SLANG_NO_THROW void SLANG_MCALL 70encodeResourceCommands (IResourceCommandEncoder ** outEncoder )override ; 71 72RenderCommandEncoderImpl m_renderCommandEncoder ; 73virtual SLANG_NO_THROW void SLANG_MCALL encodeRenderCommands ( 74IRenderPassLayout * renderPass , 75IFramebuffer * framebuffer , 76IRenderCommandEncoder ** outEncoder )override ; 77 78ComputeCommandEncoderImpl m_computeCommandEncoder ; 79virtual SLANG_NO_THROW void SLANG_MCALL 80encodeComputeCommands (IComputeCommandEncoder ** outEncoder )override ; 81 82#if SLANG_GFX_HAS_DXR_SUPPORT 83RayTracingCommandEncoderImpl m_rayTracingCommandEncoder ; 84#endif 85virtual SLANG_NO_THROW void SLANG_MCALL 86encodeRayTracingCommands (IRayTracingCommandEncoder ** outEncoder )override ; 87virtual SLANG_NO_THROW void SLANG_MCALL close ()override ; 88}; 89 90}// namespace d3d12 91}// namespace gfx