Grindstone Game Engine v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
Core.hpp
1#pragma once
2
3#include <Common/Window/Window.hpp>
4
5#include "IndexBuffer.hpp"
6#include "RenderPass.hpp"
7#include "Framebuffer.hpp"
8#include "VertexBuffer.hpp"
9#include "UniformBuffer.hpp"
10#include "GraphicsPipeline.hpp"
11#include "ComputePipeline.hpp"
12#include "CommandBuffer.hpp"
13#include "VertexArrayObject.hpp"
14#include "DepthStencilTarget.hpp"
15#include "Texture.hpp"
16#include "DescriptorSet.hpp"
17#include "DescriptorSetLayout.hpp"
18
19namespace Grindstone {
20 class Window;
21}
22
23namespace Grindstone::GraphicsAPI {
24 enum class API {
25 OpenGL = 0,
26 Vulkan,
27 DirectX11,
28 DirectX12
29 };
30
31 class Core {
32 public:
33 struct CreateInfo {
34 Window* window;
35 bool debug;
36 };
37
38 virtual bool Initialize(const CreateInfo& createInfo) = 0;
39 virtual void RegisterWindow(Window* window) = 0;
40 API GetAPI() const {
41 return apiType;
42 }
43 public:
44 virtual const char* GetVendorName() const = 0;
45 virtual const char* GetAdapterName() const = 0;
46 virtual const char* GetAPIName() const = 0;
47 virtual const char* GetAPIVersion() const = 0;
48 virtual const char* GetDefaultShaderExtension() const = 0;
49
50 virtual void Clear(ClearMode mask, float clearColor[4] = nullptr, float clearDepth = 0, uint32_t clearStencil = 0) = 0;
51
52 virtual void AdjustPerspective(float *perspective) = 0;
53
54 virtual void DeleteRenderTarget(RenderTarget* ptr) = 0;
55 virtual void DeleteDepthStencilTarget(DepthStencilTarget* ptr) = 0;
56 virtual void DeleteFramebuffer(Framebuffer* ptr) = 0;
57 virtual void DeleteVertexBuffer(VertexBuffer* ptr) = 0;
58 virtual void DeleteIndexBuffer(IndexBuffer* ptr) = 0;
59 virtual void DeleteUniformBuffer(UniformBuffer* ptr) = 0;
60 virtual void DeleteGraphicsPipeline(GraphicsPipeline* ptr) = 0;
61 virtual void DeleteComputePipeline(ComputePipeline* ptr) = 0;
62 virtual void DeleteRenderPass(RenderPass* ptr) = 0;
63 virtual void DeleteTexture(Texture* ptr) = 0;
64 virtual void DeleteDescriptorSet(DescriptorSet* ptr) = 0;
65 virtual void DeleteDescriptorSetLayout(DescriptorSetLayout* ptr) = 0;
66 virtual void DeleteCommandBuffer(CommandBuffer* ptr) = 0;
67 virtual void DeleteVertexArrayObject(VertexArrayObject* ptr) = 0;
68
69 virtual Framebuffer* CreateFramebuffer(const Framebuffer::CreateInfo& ci) = 0;
70 virtual RenderPass* CreateRenderPass(const RenderPass::CreateInfo& ci) = 0;
71 virtual GraphicsPipeline* CreateGraphicsPipeline(const GraphicsPipeline::CreateInfo& ci) = 0;
72 virtual ComputePipeline* CreateComputePipeline(const ComputePipeline::CreateInfo& ci) = 0;
73 virtual CommandBuffer* CreateCommandBuffer(const CommandBuffer::CreateInfo& ci) = 0;
74 virtual VertexArrayObject* CreateVertexArrayObject(const VertexArrayObject::CreateInfo& ci) = 0;
75 virtual VertexBuffer* CreateVertexBuffer(const VertexBuffer::CreateInfo& ci) = 0;
76 virtual IndexBuffer* CreateIndexBuffer(const IndexBuffer::CreateInfo& ci) = 0;
77 virtual UniformBuffer* CreateUniformBuffer(const UniformBuffer::CreateInfo& ci) = 0;
78 virtual Texture* CreateCubemap(const Texture::CubemapCreateInfo& createInfo) = 0;
79 virtual Texture* CreateTexture(const Texture::CreateInfo& createInfo) = 0;
80 virtual DescriptorSet* CreateDescriptorSet(const DescriptorSet::CreateInfo& ci) = 0;
81 virtual DescriptorSetLayout* CreateDescriptorSetLayout(const DescriptorSetLayout::CreateInfo& ci) = 0;
82 virtual RenderTarget* CreateRenderTarget(const RenderTarget::CreateInfo& rt) = 0;
83 virtual RenderTarget* CreateRenderTarget(const RenderTarget::CreateInfo* rt, uint32_t rc, bool cube = false) = 0;
84 virtual DepthStencilTarget* CreateDepthStencilTarget(const DepthStencilTarget::CreateInfo& rt) = 0;
85
86 virtual void CopyDepthBufferFromReadToWrite(uint32_t srcWidth, uint32_t srcHeight, uint32_t dstWidth, uint32_t dstHeight) = 0;
87
88 virtual bool ShouldUseImmediateMode() const = 0;
89 virtual bool SupportsCommandBuffers() const = 0;
90 virtual bool SupportsTesselation() const = 0;
91 virtual bool SupportsGeometryShader() const = 0;
92 virtual bool SupportsComputeShader() const = 0;
93 virtual bool SupportsMultiDrawIndirect() const = 0;
94
95 virtual void BindDefaultFramebuffer() = 0;
96 virtual void BindDefaultFramebufferWrite() = 0;
97 virtual void BindDefaultFramebufferRead() = 0;
98
99 virtual void WaitUntilIdle() = 0;
100
101 virtual void BindGraphicsPipeline(GraphicsPipeline* pipeline) = 0;
102 virtual void BindVertexArrayObject(VertexArrayObject*) = 0;
103 virtual void DrawImmediateIndexed(GeometryType geom_type, bool largeBuffer, int32_t baseVertex, uint32_t indexOffsetPtr, uint32_t indexCount) = 0;
104 virtual void DrawImmediateVertices(GeometryType geom_type, uint32_t base, uint32_t count) = 0;
105 virtual void SetImmediateBlending(
106 BlendOperation colorOp, BlendFactor colorSrc, BlendFactor colorDst,
107 BlendOperation alphaOp, BlendFactor alphaSrc, BlendFactor alphaDst
108 ) = 0;
109 virtual void EnableDepthWrite(bool isDepthEnabled) = 0;
110 virtual void SetColorMask(ColorMask mask) = 0;
111 virtual void ResizeViewport(uint32_t w, uint32_t h) = 0;
112
113 const char* GetVendorNameFromID(uint32_t vendorID) {
114 switch (vendorID) {
115 case 0x1002:
116 return "Advanced Micro Devices (AMD)";
117 break;
118 case 0x1010:
119 return "Imagination Technologies";
120 break;
121 case 0x10DE:
122 return "NVIDIA Corporation";
123 break;
124 case 0x13B5:
125 return "Arm Limited";
126 break;
127 case 0x5143:
128 return "Qualcomm Technologies, Inc.";
129 break;
130 case 0x163C:
131 case 0x8086:
132 case 0x8087:
133 return "Intel Corporation";
134 break;
135 default:
136 return 0;
137 }
138 };
139 protected:
140 bool debug;
141 API apiType;
142 };
143}
Definition CommandBuffer.hpp:21
Definition ComputePipeline.hpp:18
Definition Core.hpp:31
Definition DepthStencilTarget.hpp:15
Definition DescriptorSetLayout.hpp:11
Definition DescriptorSet.hpp:11
Definition Framebuffer.hpp:19
Definition GraphicsPipeline.hpp:18
Definition IndexBuffer.hpp:11
Definition RenderPass.hpp:27
Definition RenderTarget.hpp:12
Definition Texture.hpp:40
Definition UniformBuffer.hpp:10
Definition VertexArrayObject.hpp:10
Definition VertexBuffer.hpp:130
Definition Window.cs:7