86 lines
3.6 KiB
C++
86 lines
3.6 KiB
C++
#pragma once
|
|
|
|
#include "XCEngine/RHI/RHICommandList.h"
|
|
#include "XCEngine/RHI/Vulkan/VulkanCommon.h"
|
|
|
|
#include <vector>
|
|
|
|
namespace XCEngine {
|
|
namespace RHI {
|
|
|
|
class VulkanDevice;
|
|
class VulkanPipelineState;
|
|
class VulkanTexture;
|
|
|
|
class VulkanCommandList : public RHICommandList {
|
|
public:
|
|
VulkanCommandList() = default;
|
|
~VulkanCommandList() override;
|
|
|
|
bool Initialize(VulkanDevice* device);
|
|
|
|
void Shutdown() override;
|
|
void Reset() override;
|
|
void Close() override;
|
|
|
|
void TransitionBarrier(RHIResourceView* resource, ResourceStates stateBefore, ResourceStates stateAfter) override;
|
|
|
|
void BeginRenderPass(class RHIRenderPass* renderPass, class RHIFramebuffer* framebuffer,
|
|
const Rect& renderArea, uint32_t clearValueCount, const ClearValue* clearValues) override;
|
|
void EndRenderPass() override;
|
|
|
|
void SetShader(RHIShader* shader) override;
|
|
void SetPipelineState(RHIPipelineState* pso) override;
|
|
void SetGraphicsDescriptorSets(uint32_t firstSet, uint32_t count, RHIDescriptorSet** descriptorSets, RHIPipelineLayout* pipelineLayout) override;
|
|
void SetComputeDescriptorSets(uint32_t firstSet, uint32_t count, RHIDescriptorSet** descriptorSets, RHIPipelineLayout* pipelineLayout) override;
|
|
void SetPrimitiveTopology(PrimitiveTopology topology) override;
|
|
void SetViewport(const Viewport& viewport) override;
|
|
void SetViewports(uint32_t count, const Viewport* viewports) override;
|
|
void SetScissorRect(const Rect& rect) override;
|
|
void SetScissorRects(uint32_t count, const Rect* rects) override;
|
|
void SetRenderTargets(uint32_t count, RHIResourceView** renderTargets, RHIResourceView* depthStencil = nullptr) override;
|
|
|
|
void SetStencilRef(uint8_t ref) override;
|
|
void SetBlendFactor(const float factor[4]) override;
|
|
|
|
void SetVertexBuffers(uint32_t startSlot, uint32_t count, RHIResourceView** buffers, const uint64_t* offsets, const uint32_t* strides) override;
|
|
void SetIndexBuffer(RHIResourceView* buffer, uint64_t offset) override;
|
|
|
|
void Draw(uint32_t vertexCount, uint32_t instanceCount = 1, uint32_t startVertex = 0, uint32_t startInstance = 0) override;
|
|
void DrawIndexed(uint32_t indexCount, uint32_t instanceCount = 1, uint32_t startIndex = 0, int32_t baseVertex = 0, uint32_t startInstance = 0) override;
|
|
|
|
void Clear(float r, float g, float b, float a, uint32_t buffers) override;
|
|
void ClearRenderTarget(RHIResourceView* renderTarget, const float color[4]) override;
|
|
void ClearDepthStencil(RHIResourceView* depthStencil, float depth, uint8_t stencil) override;
|
|
|
|
void CopyResource(RHIResourceView* dst, RHIResourceView* src) override;
|
|
void Dispatch(uint32_t x, uint32_t y, uint32_t z) override;
|
|
|
|
void* GetNativeHandle() override { return m_commandBuffer; }
|
|
|
|
VkCommandBuffer GetCommandBuffer() const { return m_commandBuffer; }
|
|
|
|
private:
|
|
bool EnsureGraphicsRenderPass();
|
|
void EndActiveRenderPass();
|
|
void DestroyTransientFramebuffers();
|
|
void TransitionTexture(VulkanTexture* texture, ResourceStates newState);
|
|
|
|
VulkanDevice* m_device = nullptr;
|
|
VkCommandPool m_commandPool = VK_NULL_HANDLE;
|
|
VkCommandBuffer m_commandBuffer = VK_NULL_HANDLE;
|
|
RHIResourceView* m_currentColorTarget = nullptr;
|
|
RHIResourceView* m_currentDepthTarget = nullptr;
|
|
VulkanPipelineState* m_currentPipelineState = nullptr;
|
|
PrimitiveTopology m_currentPrimitiveTopology = PrimitiveTopology::TriangleList;
|
|
bool m_renderPassActive = false;
|
|
bool m_hasViewport = false;
|
|
bool m_hasScissor = false;
|
|
VkViewport m_viewport = {};
|
|
VkRect2D m_scissor = {};
|
|
std::vector<VkFramebuffer> m_transientFramebuffers;
|
|
};
|
|
|
|
} // namespace RHI
|
|
} // namespace XCEngine
|