11#include <Utility/INoCopyAndMove.h>
12#include <Common/logging.h>
13#include <Common/assertion.h>
14#include <Common/primitive_type.h>
15#include <Math/math_fwd.h>
16#include <Utility/TSpan.h>
20#include <source_location>
34class GHI :
private INoCopyAndMove
61 virtual void setViewport(uint32 xPx, uint32 yPx, uint32 widthPx, uint32 heightPx) = 0;
76 TSpanView<std::byte> pixelData,
82 const math::Vector2UI& regionOriginPx,
83 const math::Vector2UI& regionSizePx,
84 TSpanView<std::byte> pixelData,
98 std::string shaderSource) = 0;
106 std::size_t numVertices,
111 std::size_t numIndices,
116 TSpanView<std::shared_ptr<VertexStorage>> vertexStorages,
117 const std::shared_ptr<IndexStorage>& indexStorage) = 0;
121 template<EGraphicsAPI API_TYPE,
typename CommandCallingFunctor>
123 CommandCallingFunctor functor,
124 std::source_location srcLocation = std::source_location::current());
132 virtual void beginRawCommand() = 0;
133 virtual void endRawCommand() = 0;
139template<EGraphicsAPI API_TYPE,
typename CommandCallingFunctor>
141 CommandCallingFunctor functor,
142 const std::source_location srcLocation)
144 static_assert(std::is_invocable_v<CommandCallingFunctor>,
145 "must be callable without any argument");
147 if(API_TYPE != m_apiType)
150 "cannot call raw command of type {} under current GHI type {}, "
151 "skipping command at {}({}:{})",
152 toString(API_TYPE),
toString(m_apiType), srcLocation.file_name(), srcLocation.line(), srcLocation.column());
Definition ghi_infos.h:88
Graphics API abstraction.
Definition GHI.h:35
virtual std::shared_ptr< IndexStorage > createIndexStorage(EStorageElement indexType, std::size_t numIndices, EStorageUsage usage)=0
virtual void setClearColor(const math::Vector4F &color)=0
void rawCommand(CommandCallingFunctor functor, std::source_location srcLocation=std::source_location::current())
Definition GHI.h:140
virtual void attachTextureToFramebuffer(uint32 attachmentIdx, TextureHandle textureHandle, FramebufferHandle framebufferHandle)=0
virtual TextureNativeHandle tryGetTextureNativeHandle(TextureHandle handle)=0
virtual DeviceCapabilityInfo getDeviceCapabilities()
Definition GHI.cpp:28
virtual std::shared_ptr< Shader > createShader(std::string name, EShadingStage shadingStage, std::string shaderSource)=0
virtual void load()=0
Load and initiate the GHI. load() and unload() must be called on the same thread. All remaining metho...
virtual std::shared_ptr< Mesh > createMesh(const MeshVertexLayoutInfo &layout, TSpanView< std::shared_ptr< VertexStorage > > vertexStorages, const std::shared_ptr< IndexStorage > &indexStorage)=0
virtual bool tryUploadPixelDataTo2DRegion(TextureHandle handle, const math::Vector2UI ®ionOriginPx, const math::Vector2UI ®ionSizePx, TSpanView< std::byte > pixelData, EPixelFormat pixelFormat, EPixelComponent pixelComponent)=0
virtual void swapBuffers()=0
static std::string toString(EGraphicsAPI apiType)
Definition GHI.cpp:9
virtual void clearBuffer(EClearTarget target)=0
virtual void unload()=0
Unload and clean up the GHI. Must be called on the same thread as load(). See load() for more informa...
virtual void draw(Mesh &mesh, EMeshDrawMode drawMode)=0
GHI(EGraphicsAPI apiType)
Definition GHI.cpp:22
virtual std::shared_ptr< VertexStorage > createVertexStorage(const VertexGroupFormatInfo &format, std::size_t numVertices, EStorageUsage usage)=0
virtual std::shared_ptr< ShaderProgram > createShaderProgram(std::string name, const ShaderSetInfo &shaders)=0
virtual bool tryUploadPixelData(TextureHandle handle, TSpanView< std::byte > pixelData, EPixelFormat pixelFormat, EPixelComponent pixelComponent)=0
Try to upload pixel data to a texture.
virtual void setViewport(uint32 xPx, uint32 yPx, uint32 widthPx, uint32 heightPx)=0
Set how NDC corresponds to pixels on the display.
Definition ghi_infos.h:46
Definition PlatformDisplay.h:13
EPixelFormat
Definition ghi_enums.h:31
std::variant< std::monostate, uint64 > TextureNativeHandle
Definition ghi_fwd.h:52
EStorageElement
Definition ghi_enums.h:70
EClearTarget
Definition EClearTarget.h:11
EShadingStage
Definition ghi_enums.h:104
EStorageUsage
Definition ghi_enums.h:86
EMeshDrawMode
Definition ghi_enums.h:93
EGraphicsAPI
Definition EGraphicsAPI.h:7
EPixelComponent
Definition ghi_enums.h:42
PH_DECLARE_LOG_GROUP(GHI)