yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1// vk-command-buffer.h 2#pragma once 3 4#include "vk-base.h" 5#include "vk-command-encoder.h" 6#include "vk-shader-object.h" 7#include "vk-transient-heap.h" 8 9namespace gfx 10{ 11 12using namespace Slang ; 13 14namespace vk 15{ 16 17class CommandBufferImpl :public ICommandBuffer ,public ComObject 18{ 19public : 20// There are a pair of cyclic references between a `TransientResourceHeap` and 21// a `CommandBuffer` created from the heap. We need to break the cycle when 22// the public reference count of a command buffer drops to 0. 23SLANG_COM_OBJECT_IUNKNOWN_ALL 24ICommandBuffer * getInterface (const Guid & guid ); 25virtual void comFree ()override ; 26 27public : 28VkCommandBuffer m_commandBuffer ; 29VkCommandBuffer m_preCommandBuffer = VK_NULL_HANDLE ; 30VkCommandPool m_pool ; 31DeviceImpl * m_renderer ; 32BreakableReference < TransientResourceHeapImpl > m_transientHeap ; 33bool m_isPreCommandBufferEmpty = true; 34RootShaderObjectImpl m_rootObject ; 35RefPtr < MutableRootShaderObjectImpl > m_mutableRootShaderObject ; 36 37RefPtr < ResourceCommandEncoder > m_resourceCommandEncoder ; 38RefPtr < ComputeCommandEncoder > m_computeCommandEncoder ; 39RefPtr < RenderCommandEncoder > m_renderCommandEncoder ; 40RefPtr < RayTracingCommandEncoder > m_rayTracingCommandEncoder ; 41 42// Command buffers are deallocated by its command pool, 43// so no need to free individually. 44 ~CommandBufferImpl ()= default ; 45 46Result init (DeviceImpl * renderer ,VkCommandPool pool ,TransientResourceHeapImpl * transientHeap ); 47 48void beginCommandBuffer (); 49 50Result createPreCommandBuffer (); 51 52VkCommandBuffer getPreCommandBuffer (); 53 54public : 55virtual SLANG_NO_THROW void SLANG_MCALL encodeRenderCommands ( 56IRenderPassLayout * renderPass , 57IFramebuffer * framebuffer , 58IRenderCommandEncoder ** outEncoder )override ; 59virtual SLANG_NO_THROW void SLANG_MCALL 60encodeComputeCommands (IComputeCommandEncoder ** outEncoder )override ; 61virtual SLANG_NO_THROW void SLANG_MCALL 62encodeResourceCommands (IResourceCommandEncoder ** outEncoder )override ; 63virtual SLANG_NO_THROW void SLANG_MCALL 64encodeRayTracingCommands (IRayTracingCommandEncoder ** outEncoder )override ; 65virtual SLANG_NO_THROW void SLANG_MCALL close ()override ; 66virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle ( InteropHandle * outHandle) override; 67}; 68 69} // namespace vk 70} // namespace gfx