Files
Seele/src/Engine/Graphics/Vulkan/Graphics.h
T

115 lines
5.2 KiB
C++
Raw Normal View History

2020-03-24 21:05:32 +01:00
#pragma once
2023-10-26 18:37:29 +02:00
#include "Enums.h"
2020-04-12 15:47:19 +02:00
#include "Graphics/Graphics.h"
2020-03-02 19:07:49 +01:00
namespace Seele
{
2020-04-12 15:47:19 +02:00
namespace Vulkan
{
2021-04-01 16:40:14 +02:00
DECLARE_REF(Allocator)
DECLARE_REF(StagingManager)
DECLARE_REF(CommandBufferManager)
DECLARE_REF(Queue)
2022-01-12 14:40:26 +01:00
DECLARE_REF(RenderPass)
2021-04-01 16:40:14 +02:00
DECLARE_REF(Framebuffer)
DECLARE_REF(RenderCommand)
DECLARE_REF(PipelineCache)
2023-10-26 18:37:29 +02:00
DECLARE_REF(Window)
DECLARE_REF(RenderTargetLayout)
DECLARE_REF(Viewport)
2020-04-12 15:47:19 +02:00
class Graphics : public Gfx::Graphics
{
public:
Graphics();
virtual ~Graphics();
constexpr VkInstance getInstance() const { return instance; };
constexpr VkDevice getDevice() const { return handle; };
constexpr VkPhysicalDevice getPhysicalDevice() const { return physicalDevice; };
2020-04-12 15:47:19 +02:00
PCommandBufferManager getQueueCommands(Gfx::QueueType queueType);
PCommandBufferManager getGraphicsCommands();
PCommandBufferManager getComputeCommands();
PCommandBufferManager getTransferCommands();
PCommandBufferManager getDedicatedTransferCommands();
2020-04-12 15:47:19 +02:00
PAllocator getAllocator();
PStagingManager getStagingManager();
2020-04-12 15:47:19 +02:00
// Inherited via Graphics
virtual void init(GraphicsInitializer initializer) override;
2023-11-01 23:12:30 +01:00
virtual Gfx::OWindow createWindow(const WindowCreateInfo &createInfo) override;
virtual Gfx::OViewport createViewport(Gfx::PWindow owner, const ViewportCreateInfo &createInfo) override;
2020-04-12 15:47:19 +02:00
2023-11-01 23:12:30 +01:00
virtual Gfx::ORenderPass createRenderPass(Gfx::ORenderTargetLayout layout, Gfx::PViewport renderArea) override;
virtual void beginRenderPass(Gfx::PRenderPass renderPass) override;
virtual void endRenderPass() override;
2020-04-12 15:47:19 +02:00
virtual void executeCommands(const Array<Gfx::PRenderCommand>& commands) override;
2021-05-10 23:57:55 +02:00
virtual void executeCommands(const Array<Gfx::PComputeCommand>& commands) override;
2020-05-05 01:51:13 +02:00
2023-11-01 23:12:30 +01:00
virtual Gfx::OTexture2D createTexture2D(const TextureCreateInfo &createInfo) override;
virtual Gfx::OTexture3D createTexture3D(const TextureCreateInfo &createInfo) override;
virtual Gfx::OTextureCube createTextureCube(const TextureCreateInfo &createInfo) override;
virtual Gfx::OUniformBuffer createUniformBuffer(const UniformBufferCreateInfo &bulkData) override;
virtual Gfx::OShaderBuffer createShaderBuffer(const ShaderBufferCreateInfo &bulkData) override;
virtual Gfx::OVertexBuffer createVertexBuffer(const VertexBufferCreateInfo &bulkData) override;
virtual Gfx::OIndexBuffer createIndexBuffer(const IndexBufferCreateInfo &bulkData) override;
virtual Gfx::PRenderCommand createRenderCommand(const std::string& name) override;
virtual Gfx::PComputeCommand createComputeCommand(const std::string& name) override;
2023-11-01 23:12:30 +01:00
virtual Gfx::OVertexDeclaration createVertexDeclaration(const Array<Gfx::VertexElement>& element) override;
virtual Gfx::OVertexShader createVertexShader(const ShaderCreateInfo& createInfo) override;
virtual Gfx::OFragmentShader createFragmentShader(const ShaderCreateInfo& createInfo) override;
virtual Gfx::OComputeShader createComputeShader(const ShaderCreateInfo& createInfo) override;
virtual Gfx::OTaskShader createTaskShader(const ShaderCreateInfo& createInfo) override;
virtual Gfx::OMeshShader createMeshShader(const ShaderCreateInfo& createInfo) override;
2023-11-09 22:15:51 +01:00
virtual Gfx::PGraphicsPipeline createGraphicsPipeline(Gfx::LegacyPipelineCreateInfo createInfo) override;
virtual Gfx::PGraphicsPipeline createGraphicsPipeline(Gfx::MeshPipelineCreateInfo createInfo) override;
virtual Gfx::PComputePipeline createComputePipeline(Gfx::ComputePipelineCreateInfo createInfo) override;
2023-11-01 23:12:30 +01:00
virtual Gfx::OSamplerState createSamplerState(const SamplerCreateInfo& createInfo) override;
2020-04-12 15:47:19 +02:00
2023-11-01 23:12:30 +01:00
virtual Gfx::ODescriptorLayout createDescriptorLayout(const std::string& name = "") override;
virtual Gfx::OPipelineLayout createPipelineLayout(Gfx::PPipelineLayout baseLayout = nullptr) override;
2020-06-02 11:46:18 +02:00
virtual void copyTexture(Gfx::PTexture srcTexture, Gfx::PTexture dstTexture) override;
2023-11-05 10:36:01 +01:00
void vkCmdDrawMeshTasksEXT(VkCommandBuffer handle, uint32 groupX, uint32 groupY, uint32 groupZ);
2020-04-12 15:47:19 +02:00
protected:
2023-11-05 10:36:01 +01:00
PFN_vkCmdDrawMeshTasksEXT cmdDrawMeshTasks;
Array<const char *> getRequiredExtensions();
void initInstance(GraphicsInitializer initInfo);
void setupDebugCallback();
void pickPhysicalDevice();
void createDevice(GraphicsInitializer initInfo);
2020-04-12 15:47:19 +02:00
VkInstance instance;
VkDevice handle;
VkPhysicalDevice physicalDevice;
2020-04-12 15:47:19 +02:00
2023-11-01 23:12:30 +01:00
OQueue graphicsQueue;
OQueue computeQueue;
OQueue transferQueue;
OQueue dedicatedTransferQueue;
OPipelineCache pipelineCache;
2022-01-12 14:40:26 +01:00
std::mutex renderPassLock;
PRenderPass activeRenderPass;
PFramebuffer activeFramebuffer;
2023-11-01 23:12:30 +01:00
thread_local static OCommandBufferManager graphicsCommands;
thread_local static OCommandBufferManager computeCommands;
thread_local static OCommandBufferManager transferCommands;
thread_local static OCommandBufferManager dedicatedTransferCommands;
VkPhysicalDeviceProperties props;
2023-11-05 11:47:22 +01:00
VkPhysicalDeviceFeatures features;
VkDebugReportCallbackEXT callback;
std::mutex viewportLock;
Array<PViewport> viewports;
std::mutex allocatedFrameBufferLock;
2023-11-08 23:27:21 +01:00
Map<uint32, OFramebuffer> allocatedFramebuffers;
2023-11-01 23:12:30 +01:00
OAllocator allocator;
OStagingManager stagingManager;
2020-04-12 15:47:19 +02:00
friend class Window;
2020-04-12 15:47:19 +02:00
};
2021-04-01 16:40:14 +02:00
DEFINE_REF(Graphics)
2020-04-12 15:47:19 +02:00
} // namespace Vulkan
} // namespace Seele