mitiru::gfx

Graphics abstraction layer (GAL). Backend-agnostic device, command buffer, resource, and pipeline types shared by the OpenGL, DX11, DX12, Vulkan and Null backends.

Graphics abstraction layer (GAL). Backend-agnostic device, command buffer, resource, and pipeline types shared by the OpenGL, DX11, DX12, Vulkan and Null backends.

NameKindItems
VertexFormatenum4
PixelFormatenum4
BlendModeenum7
ResourceStateenum8
DescriptorHeapTypeenum5
TextureDescstruct4
BufferDescstruct4
GpuDescriptorHandlestruct2
CpuDescriptorHandlestruct2
BufferTypeenum3
IBufferclass6
ICommandListclass18
IDescriptorHeapclass7
IDeviceclass20
IGpuFenceclass5
IPipelineclass3
IRenderTargetclass4
ShaderTypeenum3
IShaderclass2
ISwapChainclass6
ITextureclass4
Dx11Bufferclass7
Dx11CommandListclass16
Dx11Deviceclass17
Dx11OffscreenRTclass9
Dx11PipelineDescstruct5
Dx11Pipelineclass4
Dx11RenderTargetclass8
Dx11SwapChainclass7
Dx11Textureclass8
Dx12Bufferclass9
Dx12CommandListclass21
Dx12DescriptorHeapclass11
Dx12Fenceclass12
Dx12OffscreenRTclass6
Dx12PipelineDescstruct6
Dx12Pipelineclass6
Dx12RenderTargetclass10
Dx12SwapChainclass11
Dx12Textureclass11
NullBufferclass3
NullCommandListclass9
NullDeviceclass6
GlBufferclass11
GlCommandListclass11
GlDeviceclass19
GlFunctionsstruct59
DepthBufferConfigstruct3
VulkanDepthBufferclass12
DescriptorPoolConfigstruct5
VulkanDescriptorPoolclass12
VulkanBufferclass10
VulkanCommandListclass12
VulkanDeviceclass15
FramebufferConfigstruct6
VulkanFramebufferclass10
VulkanAppInfostruct5
VulkanValidationConfigstruct5
VulkanInstanceDescstruct6
VulkanInstanceclass9
QueueFamilyenum4
GpuTypeenum7
QueueFamilyIndicesstruct6
PhysicalDeviceInfostruct10
VulkanPhysicalDeviceclass4
PrimitiveTopologyenum5
PolygonModeenum3
CullModeenum3
FrontFaceenum2
CompareOpenum8
VertexInputAttributestruct4
VertexInputBindingstruct3
VertexInputStatestruct2
RasterizerStatestruct8
MultisampleStatestruct3
DepthStencilStatestruct4
ShaderStageDescstruct3
PushConstantRangestruct3
PipelineLayoutDescstruct2
GraphicsPipelineDescstruct10
VulkanGraphicsPipelineclass10
AttachmentLoadOpenum3
AttachmentStoreOpenum2
ImageLayoutenum7
AttachmentDescstruct8
AttachmentReferencestruct2
SubpassDescstruct6
SubpassDependencystruct7
RenderPassDescstruct5
VulkanRenderPassclass8
VulkanRenderTargetclass5
VulkanSwapChainclass7
TextureConfigstruct8
VulkanTextureclass13
WebGLCommandListclass10
WebGLDeviceclass21
WebGLBufferclass12
WebGLPipelineDescstruct7
WebGLPipelineclass13
WebGLShaderclass16
TextureFilterenum2
TextureWrapenum3
WebGLTextureclass17
WebGPUBufferclass12
WebGPUCommandListclass18
WebGPUDeviceclass23

Free functions and typedefs

[[nodiscard]] inline std::unique_ptr<IDevice> createDevice( Backend backend, [[maybe_unused]] IWindow* window = nullptr)
enum VertexFormat 4
Position2D
Position3D
PositionColor
PositionTexCoord
enum PixelFormat 4
RGBA8
BGRA8
R8
Depth24Stencil8
enum BlendMode 7
None
Alpha
Additive
Multiplicative
Screen
Overlay
ColorDodge
enum ResourceState : uint32_t 8
Common = 0
RenderTarget
Present
ShaderResource
DepthWrite
CopyDest
CopySrc
UnorderedAccess
enum DescriptorHeapType : uint8_t 5
CbvSrvUav
Rtv
Dsv
Sampler
using FenceValue = uint64_t;
struct TextureDesc 4
int width = 0
int height = 0
PixelFormat format = PixelFormat::RGBA8
bool renderTarget = false
struct BufferDesc 4
enum `Usage` { Vertex, Index, Constant }
Usage usage = Usage::Vertex
std::uint32_t sizeBytes = 0
bool dynamic = false
struct GpuDescriptorHandle 2
uint64_t ptr = 0
[[nodiscard]] constexpr bool isValid() const noexcept
struct CpuDescriptorHandle 2
uint64_t ptr = 0
[[nodiscard]] constexpr bool isValid() const noexcept
enum BufferType 3
Vertex
Index
Constant
class IBuffer 6
virtual ~IBuffer() = default
[[nodiscard]] virtual std::uint32_t size() const noexcept = 0
[[nodiscard]] virtual BufferType type() const noexcept = 0
[[nodiscard]] virtual bool isValid() const noexcept
virtual void update(const void* data, std::uint32_t sizeBytes)
[[nodiscard]] virtual uint64_t gpuVirtualAddress() const
class ICommandList 18
virtual ~ICommandList() = default
virtual void begin() = 0
virtual void end() = 0
virtual void setRenderTarget(IRenderTarget* target) = 0
virtual void clearRenderTarget(const sgc::Colorf& color) = 0
virtual void setPipeline(IPipeline* pipeline) = 0
virtual void setVertexBuffer(IBuffer* buffer) = 0
virtual void setIndexBuffer(IBuffer* buffer) = 0
virtual void drawIndexed(std::uint32_t indexCount, std::uint32_t startIndex = 0, std::int32_t baseVertex = 0) = 0
virtual void draw(std::uint32_t vertexCount, std::uint32_t startVertex = 0) = 0
virtual void setViewport(float width, float height)
virtual void reset()
virtual void close()
virtual void resourceBarrier( ITexture* resource, ResourceState before, ResourceState after)
virtual void setRootSignature(void* rootSignature)
virtual void setDescriptorHeaps( IDescriptorHeap* const* heaps, uint32_t count)
virtual void setGraphicsRootDescriptorTable( uint32_t paramIndex, GpuDescriptorHandle handle)
virtual void setGraphicsRootCBV( uint32_t paramIndex, uint64_t gpuVirtualAddress)
class IDescriptorHeap 7
virtual ~IDescriptorHeap() = default
[[nodiscard]] virtual DescriptorHeapType type() const = 0
[[nodiscard]] virtual uint32_t capacity() const = 0
[[nodiscard]] virtual uint32_t allocatedCount() const = 0
[[nodiscard]] virtual CpuDescriptorHandle allocate() = 0
virtual void free(CpuDescriptorHandle handle) = 0
[[nodiscard]] virtual GpuDescriptorHandle gpuHandle(CpuDescriptorHandle cpuHandle) const = 0
class IDevice 20
virtual ~IDevice() = default
[[nodiscard]] virtual std::vector<std::uint8_t> readPixels( int width, int height) const = 0
[[nodiscard]] virtual Backend backend() const noexcept = 0
virtual void setClearColor(float r, float g, float b, float a = 1.0f)
virtual void beginFrame() = 0
virtual void endFrame() = 0
[[nodiscard]] virtual float gpuFrameMs() const noexcept
[[nodiscard]] virtual std::unique_ptr<IBuffer> createBuffer( BufferType bufferType, std::uint32_t sizeBytes, bool dynamic = false, const void* initialData = nullptr) = 0
[[nodiscard]] virtual std::unique_ptr<ICommandList> createCommandList() = 0
[[nodiscard]] virtual uint32_t currentFrameIndex() const
[[nodiscard]] virtual uint32_t frameInFlightCount() const
[[nodiscard]] virtual std::unique_ptr<IGpuFence> createFence()
[[nodiscard]] virtual std::unique_ptr<IDescriptorHeap> createDescriptorHeap( DescriptorHeapType heapType, uint32_t capacity)
virtual void executeCommandLists( ICommandList* const* lists, uint32_t count)
virtual void waitForGpu()
virtual void onResize(int w, int h)
virtual void resetRenderTargetFor2D()
virtual void setPostProcessManager(void* )
virtual void beginPostProcess()
virtual void endPostProcess()
class IGpuFence 5
virtual ~IGpuFence() = default
[[nodiscard]] virtual FenceValue currentValue() const = 0
virtual void signal(FenceValue value) = 0
virtual void waitForValue(FenceValue value) = 0
[[nodiscard]] virtual bool isComplete(FenceValue value) const = 0
class IPipeline 3
virtual ~IPipeline() = default
[[nodiscard]] virtual bool isValid() const noexcept = 0
[[nodiscard]] virtual void* rootSignature() const
class IRenderTarget 4
virtual ~IRenderTarget() = default
[[nodiscard]] virtual int width() const noexcept = 0
[[nodiscard]] virtual int height() const noexcept = 0
[[nodiscard]] virtual ITexture* texture() noexcept = 0
enum ShaderType 3
Vertex
Pixel
Compute
class IShader 2
virtual ~IShader() = default
[[nodiscard]] virtual ShaderType type() const noexcept = 0
class ISwapChain 6
virtual ~ISwapChain() = default
virtual void present() = 0
virtual void resize(int width, int height) = 0
[[nodiscard]] virtual IRenderTarget* backBuffer() noexcept = 0
[[nodiscard]] virtual uint32_t currentBackBufferIndex() const
[[nodiscard]] virtual uint32_t bufferCount() const
class ITexture 4
virtual ~ITexture() = default
[[nodiscard]] virtual int width() const noexcept = 0
[[nodiscard]] virtual int height() const noexcept = 0
[[nodiscard]] virtual PixelFormat format() const noexcept = 0
class Dx11Buffer : public IBuffer 7
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>
Dx11Buffer(ID3D11Device* device, BufferType bufferType, std::uint32_t sizeBytes, bool dynamic, const void* initialData = nullptr)
bool update(ID3D11DeviceContext* context, const void* data, std::uint32_t dataSize)
[[nodiscard]] std::uint32_t size() const noexcept override
[[nodiscard]] BufferType type() const noexcept override
[[nodiscard]] bool isDynamic() const noexcept
[[nodiscard]] ID3D11Buffer* getD3DBuffer() const noexcept
class Dx11CommandList : public ICommandList 16
explicit Dx11CommandList(ID3D11DeviceContext* context)
void begin() override
void end() override
void setRenderTarget(IRenderTarget* target) override
void clearRenderTarget(const sgc::Colorf& color) override
void setPipeline(IPipeline* pipeline) override
void setVertexBuffer(IBuffer* buffer) override
void setIndexBuffer(IBuffer* buffer) override
void setViewport(float width, float height)
void setVSConstantBuffer(UINT slot, Dx11Buffer* buffer)
void drawIndexed(std::uint32_t indexCount, std::uint32_t startIndex, std::int32_t baseVertex) override
void draw(std::uint32_t vertexCount, std::uint32_t startVertex) override
void setPSConstantBuffer(UINT slot, Dx11Buffer* buffer)
void setScissorRect(int x, int y, int width, int height)
void resetScissorRect(int screenWidth, int screenHeight)
[[nodiscard]] ID3D11DeviceContext* getD3DContext() const noexcept
class Dx11Device : public IDevice 17
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>
explicit Dx11Device(mitiru::Win32Window* window, int bufferWidth = 0, int bufferHeight = 0)
[[nodiscard]] std::vector<std::uint8_t> readPixels( int width, int height) const override
[[nodiscard]] Backend backend() const noexcept override
void beginFrame() override
void endFrame() override
[[nodiscard]] float gpuFrameMs() const noexcept
[[nodiscard]] ID3D11Device* getD3DDevice() const noexcept
[[nodiscard]] ID3D11DeviceContext* getD3DContext() const noexcept
[[nodiscard]] Dx11SwapChain* getSwapChain() const noexcept
[[nodiscard]] std::unique_ptr<IBuffer> createBuffer( BufferType bufferType, std::uint32_t sizeBytes, bool dynamic, const void* initialData) override
[[nodiscard]] std::unique_ptr<ICommandList> createCommandList() override
void onResize(int w, int h) override
void resetRenderTargetFor2D() override
void setPostProcessManager(void* pp) override
void beginPostProcess() override
void endPostProcess() override
class Dx11OffscreenRT 9
bool create(ID3D11Device* device, unsigned int width, unsigned int height)
void bind(ID3D11DeviceContext* context, const float clearColor[4] = nullptr)
void unbind(ID3D11DeviceContext* context)
[[nodiscard]] void* srv() const noexcept
[[nodiscard]] ID3D11RenderTargetView* rtv() const noexcept
[[nodiscard]] unsigned int width() const noexcept
[[nodiscard]] unsigned int height() const noexcept
[[nodiscard]] bool isValid() const noexcept
void release()
struct Dx11PipelineDesc 5
Dx11Shader* vertexShader = nullptr
Dx11Shader* pixelShader = nullptr
BlendMode blendMode = BlendMode::Alpha
bool wireframe = false
bool scissorEnable = false
class Dx11Pipeline : public IPipeline 4
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>
explicit Dx11Pipeline(ID3D11Device* device, const Dx11PipelineDesc& desc)
[[nodiscard]] bool isValid() const noexcept override
void bind(ID3D11DeviceContext* context) const
class Dx11RenderTarget : public IRenderTarget 8
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>
[[nodiscard]] static Dx11RenderTarget createFromBackBuffer( ID3D11Device* device, ID3D11Texture2D* backBuffer, int width, int height)
[[nodiscard]] int width() const noexcept override
[[nodiscard]] int height() const noexcept override
[[nodiscard]] ITexture* texture() noexcept override
[[nodiscard]] ID3D11RenderTargetView* getRTV() const noexcept
void release() noexcept
#pragma once #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #ifndef NOMINMAX #define NOMINMAX #endif #include <Windows.h> #include <cstdint> #include <stdexcept> #include <string> #include <string_view> #include <vector> #include <d3d11.h> #include <d3dcompiler.h> #include <wrl/client.h> #pragma comment(lib, "d3dcompiler.lib") #include <mitiru/gfx/IShader.hpp> namespace mitiru::gfx
class Dx11SwapChain : public ISwapChain 7
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>
Dx11SwapChain( ID3D11Device* device, HWND hwnd, int width, int height)
void present() override
void resize(int width, int height) override
[[nodiscard]] IRenderTarget* backBuffer() noexcept override
[[nodiscard]] ID3D11RenderTargetView* getRenderTargetView() const noexcept
[[nodiscard]] IDXGISwapChain* getSwapChain() const noexcept
class Dx11Texture : public ITexture 8
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>
[[nodiscard]] static Dx11Texture createFromData( ID3D11Device* device, int width, int height, std::span<const std::uint8_t> data)
[[nodiscard]] static Dx11Texture createStaging( ID3D11Device* device, int width, int height)
[[nodiscard]] int width() const noexcept override
[[nodiscard]] int height() const noexcept override
[[nodiscard]] PixelFormat format() const noexcept override
[[nodiscard]] ID3D11Texture2D* getTexture() const noexcept
[[nodiscard]] ID3D11ShaderResourceView* getSRV() const noexcept
class Dx12Buffer : public IBuffer 9
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>
Dx12Buffer(ID3D12Device* device, BufferType bufferType, std::uint32_t sizeBytes, bool dynamic, const void* initialData = nullptr)
[[nodiscard]] std::uint32_t size() const noexcept override
[[nodiscard]] BufferType type() const noexcept override
[[nodiscard]] uint64_t gpuVirtualAddress() const override
[[nodiscard]] bool isDynamic() const noexcept
[[nodiscard]] uint32_t alignedSize() const noexcept
void update(const void* data, std::uint32_t dataSize) override
[[nodiscard]] ID3D12Resource* nativeResource() const noexcept
class Dx12CommandList : public ICommandList 21
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>
Dx12CommandList(ID3D12Device* device)
void reset() override
void begin() override
void end() override
void close() override
void setRenderTarget(IRenderTarget* target) override
void clearRenderTarget(const sgc::Colorf& color) override
void setPipeline(IPipeline* pipeline) override
void setVertexBuffer(IBuffer* buffer) override
void setIndexBuffer(IBuffer* buffer) override
void drawIndexed(std::uint32_t indexCount, std::uint32_t startIndex, std::int32_t baseVertex) override
void draw(std::uint32_t vertexCount, std::uint32_t startVertex) override
void setViewport(float width, float height) override
void resourceBarrier( ITexture* resource, ResourceState before, ResourceState after) override
void resourceBarrierDirect( ID3D12Resource* resource, D3D12_RESOURCE_STATES before, D3D12_RESOURCE_STATES after)
void setRootSignature(void* rootSignature) override
void setDescriptorHeaps( IDescriptorHeap* const* heaps, uint32_t count) override
void setGraphicsRootDescriptorTable( uint32_t paramIndex, GpuDescriptorHandle handle) override
void setGraphicsRootCBV( uint32_t paramIndex, uint64_t gpuVirtualAddress) override
[[nodiscard]] ID3D12GraphicsCommandList* nativeCommandList() const noexcept
class Dx12DescriptorHeap : public IDescriptorHeap 11
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>
Dx12DescriptorHeap(ID3D12Device* device, DescriptorHeapType heapType, uint32_t capacity)
[[nodiscard]] DescriptorHeapType type() const override
[[nodiscard]] uint32_t capacity() const override
[[nodiscard]] uint32_t allocatedCount() const override
[[nodiscard]] CpuDescriptorHandle allocate() override
void free(CpuDescriptorHandle handle) override
[[nodiscard]] GpuDescriptorHandle gpuHandle( CpuDescriptorHandle cpuHandle) const override
[[nodiscard]] ID3D12DescriptorHeap* nativeHeap() const noexcept
[[nodiscard]] uint32_t descriptorSize() const noexcept
#pragma once #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #ifndef NOMINMAX #define NOMINMAX #endif #include <Windows.h> #include <cstdint> #include <cstring> #include <deque> #include <memory> #include <stdexcept> #include <utility> #include <vector> #include <d3d12.h> #include <dxgi1_4.h> #include <wrl/client.h> #pragma comment(lib, "d3d12.lib") #pragma comment(lib, "dxgi.lib") #include <mitiru/gfx/IBuffer.hpp> #include <mitiru/gfx/ICommandList.hpp> #include <mitiru/gfx/IDevice.hpp> #include <mitiru/gfx/dx12/Dx12Buffer.hpp> #include <mitiru/gfx/dx12/Dx12CommandList.hpp> #include <mitiru/gfx/dx12/Dx12DescriptorHeap.hpp> #include <mitiru/gfx/dx12/Dx12Fence.hpp> #include <mitiru/gfx/dx12/Dx12SwapChain.hpp> #include <mitiru/platform/win32/Win32Window.hpp> namespace mitiru::gfx
class Dx12Fence : public IGpuFence 12
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>
Dx12Fence(ID3D12Device* device, ID3D12CommandQueue* commandQueue, FenceValue initialValue = 0)
~Dx12Fence() override
Dx12Fence(const Dx12Fence&) = delete
Dx12Fence& operator=(const Dx12Fence&) = delete
Dx12Fence(Dx12Fence&& other) noexcept
Dx12Fence& operator=(Dx12Fence&& other) noexcept
[[nodiscard]] FenceValue currentValue() const override
void signal(FenceValue value) override
void waitForValue(FenceValue value) override
[[nodiscard]] bool isComplete(FenceValue value) const override
[[nodiscard]] ID3D12Fence* nativeFence() const noexcept
class Dx12OffscreenRT 6
bool create(ID3D12Device* device, UINT w, UINT h, DXGI_FORMAT format, D3D12_CPU_DESCRIPTOR_HANDLE srvCpuHandle, D3D12_GPU_DESCRIPTOR_HANDLE srvGpuHandle)
void copyFrom(ID3D12GraphicsCommandList* cmdList, ID3D12Resource* src)
[[nodiscard]] bool isValid() const noexcept
[[nodiscard]] UINT width() const noexcept
[[nodiscard]] UINT height() const noexcept
void release()
struct Dx12PipelineDesc 6
Dx12Shader* vertexShader = nullptr
Dx12Shader* pixelShader = nullptr
BlendMode blendMode = BlendMode::Alpha
bool wireframe = false
DXGI_FORMAT rtvFormat = DXGI_FORMAT_R8G8B8A8_UNORM
uint32_t numRenderTargets = 1
class Dx12Pipeline : public IPipeline 6
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>
explicit Dx12Pipeline(ID3D12Device* device, const Dx12PipelineDesc& desc)
[[nodiscard]] bool isValid() const noexcept override
[[nodiscard]] void* rootSignature() const override
[[nodiscard]] ID3D12PipelineState* nativePSO() const noexcept
[[nodiscard]] ID3D12RootSignature* nativeRootSignature() const noexcept
class Dx12RenderTarget : public IRenderTarget 10
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>
Dx12RenderTarget() = default
[[nodiscard]] static Dx12RenderTarget createFromBackBuffer( ID3D12Device* device, ID3D12Resource* resource, D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle, int width, int height)
[[nodiscard]] int width() const noexcept override
[[nodiscard]] int height() const noexcept override
[[nodiscard]] ITexture* texture() noexcept override
[[nodiscard]] D3D12_CPU_DESCRIPTOR_HANDLE rtvHandle() const noexcept
[[nodiscard]] ID3D12Resource* nativeResource() const noexcept
void release() noexcept
#pragma once #ifdef _WIN32 #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #endif #ifndef NOMINMAX #define NOMINMAX #endif #include <Windows.h> #include <cstdint> #include <cstring> #include <span> #include <stdexcept> #include <string> #include <string_view> #include <vector> #include <d3dcompiler.h> #include <wrl/client.h> #pragma comment(lib, "d3dcompiler.lib") #include <mitiru/gfx/IShader.hpp> namespace mitiru::gfx
class Dx12SwapChain : public ISwapChain 11
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>
Dx12SwapChain(ID3D12Device* device, ID3D12CommandQueue* commandQueue, IDXGIFactory4* factory, HWND hwnd, int width, int height)
void present() override
void setVSync(bool enabled) noexcept
[[nodiscard]] bool isVSyncEnabled() const noexcept
void resize(int width, int height) override
[[nodiscard]] IRenderTarget* backBuffer() noexcept override
[[nodiscard]] uint32_t currentBackBufferIndex() const override
[[nodiscard]] uint32_t bufferCount() const override
[[nodiscard]] ID3D12Resource* getBackBufferResource(uint32_t index) const noexcept
[[nodiscard]] IDXGISwapChain3* getSwapChain() const noexcept
class Dx12Texture : public ITexture 11
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>
Dx12Texture() = default
Dx12Texture(ComPtr<ID3D12Resource> resource, int width, int height, PixelFormat format = PixelFormat::RGBA8)
[[nodiscard]] static Dx12Texture createEmpty( ID3D12Device* device, int width, int height, PixelFormat format = PixelFormat::RGBA8)
[[nodiscard]] static Dx12Texture createRenderTarget( ID3D12Device* device, int width, int height, PixelFormat format = PixelFormat::RGBA8)
[[nodiscard]] int width() const noexcept override
[[nodiscard]] int height() const noexcept override
[[nodiscard]] PixelFormat format() const noexcept override
[[nodiscard]] ID3D12Resource* nativeResource() const noexcept
void setSrvHandle(CpuDescriptorHandle handle) noexcept
[[nodiscard]] CpuDescriptorHandle srvHandle() const noexcept
class NullBuffer : public IBuffer 3
NullBuffer(BufferType bufferType, std::uint32_t sizeBytes) noexcept
[[nodiscard]] std::uint32_t size() const noexcept override
[[nodiscard]] BufferType type() const noexcept override
class NullCommandList : public ICommandList 9
void begin() override
void end() override
void setRenderTarget(IRenderTarget*) override
void clearRenderTarget(const sgc::Colorf&) override
void setPipeline(IPipeline*) override
void setVertexBuffer(IBuffer*) override
void setIndexBuffer(IBuffer*) override
void drawIndexed(std::uint32_t, std::uint32_t, std::int32_t) override
void draw(std::uint32_t, std::uint32_t) override
class NullDevice : public IDevice 6
[[nodiscard]] std::vector<std::uint8_t> readPixels( int width, int height) const override
[[nodiscard]] Backend backend() const noexcept override
void beginFrame() override
void endFrame() override
[[nodiscard]] std::unique_ptr<IBuffer> createBuffer( BufferType bufferType, std::uint32_t sizeBytes, bool , const void* ) override
[[nodiscard]] std::unique_ptr<ICommandList> createCommandList() override
class GlBuffer : public IBuffer 11
GlBuffer(GlFunctions* gl, BufferType bufferType, std::uint32_t sizeBytes, bool dynamic, const void* initialData = nullptr)
~GlBuffer() override
GlBuffer(const GlBuffer&) = delete
GlBuffer& operator=(const GlBuffer&) = delete
GlBuffer(GlBuffer&& other) noexcept
GlBuffer& operator=(GlBuffer&& other) noexcept
void update(const void* data, std::uint32_t sizeBytes) override
[[nodiscard]] std::uint32_t size() const noexcept override
[[nodiscard]] BufferType type() const noexcept override
[[nodiscard]] GLuint glBuffer() const noexcept
[[nodiscard]] GLenum glTarget() const noexcept
class GlCommandList : public ICommandList 11
GlCommandList(GlFunctions* gl, GLuint program, GLint projectionLoc, GLuint vao, const float* screenWidth, const float* screenHeight)
void begin() override
void end() override
void setRenderTarget(IRenderTarget*) override
void clearRenderTarget(const sgc::Colorf& color) override
void setPipeline(IPipeline*) override
void setVertexBuffer(IBuffer* buffer) override
void setIndexBuffer(IBuffer* buffer) override
void drawIndexed(std::uint32_t indexCount, std::uint32_t startIndex, std::int32_t baseVertex) override
void draw(std::uint32_t vertexCount, std::uint32_t startVertex) override
void setViewport(float width, float height) override
class GlDevice : public IDevice 19
explicit GlDevice(mitiru::Sdl2Window* window)
explicit GlDevice(mitiru::GlfwWindow* window)
~GlDevice() override
GlDevice(const GlDevice&) = delete
GlDevice& operator=(const GlDevice&) = delete
GlDevice(GlDevice&&) = delete
GlDevice& operator=(GlDevice&&) = delete
[[nodiscard]] std::vector<std::uint8_t> readPixels( int width, int height) const override
[[nodiscard]] Backend backend() const noexcept override
void beginFrame() override
void endFrame() override
[[nodiscard]] std::unique_ptr<IBuffer> createBuffer( BufferType bufferType, std::uint32_t sizeBytes, bool dynamic, const void* initialData) override
[[nodiscard]] std::unique_ptr<ICommandList> createCommandList() override
[[nodiscard]] GlFunctions& glFunctions() noexcept
[[nodiscard]] GLuint program() const noexcept
[[nodiscard]] GLuint vao() const noexcept
[[nodiscard]] float screenWidth() const noexcept
[[nodiscard]] float screenHeight() const noexcept
void updateScreenSize(float width, float height) noexcept
struct GlFunctions 59
using PFN_glCreateShader = GLuint (*)(GLenum);
using PFN_glShaderSource = void (*)(GLuint, GLsizei, const GLchar* const*, const GLint*);
using PFN_glCompileShader = void (*)(GLuint);
using PFN_glGetShaderiv = void (*)(GLuint, GLenum, GLint*);
using PFN_glGetShaderInfoLog = void (*)(GLuint, GLsizei, GLsizei*, GLchar*);
using PFN_glCreateProgram = GLuint (*)();
using PFN_glAttachShader = void (*)(GLuint, GLuint);
using PFN_glLinkProgram = void (*)(GLuint);
using PFN_glGetProgramiv = void (*)(GLuint, GLenum, GLint*);
using PFN_glUseProgram = void (*)(GLuint);
using PFN_glDeleteShader = void (*)(GLuint);
using PFN_glDeleteProgram = void (*)(GLuint);
using PFN_glGenVertexArrays = void (*)(GLsizei, GLuint*);
using PFN_glDeleteVertexArrays = void (*)(GLsizei, const GLuint*);
using PFN_glBindVertexArray = void (*)(GLuint);
using PFN_glGenBuffers = void (*)(GLsizei, GLuint*);
using PFN_glDeleteBuffers = void (*)(GLsizei, const GLuint*);
using PFN_glBindBuffer = void (*)(GLenum, GLuint);
using PFN_glBufferData = void (*)(GLenum, GLsizeiptr, const void*, GLenum);
using PFN_glBufferSubData = void (*)(GLenum, GLintptr, GLsizeiptr, const void*);
using PFN_glVertexAttribPointer = void (*)(GLuint, GLint, GLenum, GLboolean, GLsizei, const void*);
using PFN_glEnableVertexAttribArray = void (*)(GLuint);
using PFN_glGetUniformLocation = GLint (*)(GLuint, const GLchar*);
using PFN_glUniformMatrix4fv = void (*)(GLint, GLsizei, GLboolean, const GLfloat*);
using PFN_glDrawElements = void (*)(GLenum, GLsizei, GLenum, const void*);
using PFN_glEnable = void (*)(GLenum);
using PFN_glBlendFunc = void (*)(GLenum, GLenum);
using PFN_glDisable = void (*)(GLenum);
PFN_glCreateShader createShader = nullptr
PFN_glShaderSource shaderSource = nullptr
PFN_glCompileShader compileShader = nullptr
PFN_glGetShaderiv getShaderiv = nullptr
PFN_glGetShaderInfoLog getShaderInfoLog = nullptr
PFN_glCreateProgram createProgram = nullptr
PFN_glAttachShader attachShader = nullptr
PFN_glLinkProgram linkProgram = nullptr
PFN_glGetProgramiv getProgramiv = nullptr
PFN_glUseProgram useProgram = nullptr
PFN_glDeleteShader deleteShader = nullptr
PFN_glDeleteProgram deleteProgram = nullptr
PFN_glGenVertexArrays genVertexArrays = nullptr
PFN_glDeleteVertexArrays deleteVertexArrays = nullptr
PFN_glBindVertexArray bindVertexArray = nullptr
PFN_glGenBuffers genBuffers = nullptr
PFN_glDeleteBuffers deleteBuffers = nullptr
PFN_glBindBuffer bindBuffer = nullptr
PFN_glBufferData bufferData = nullptr
PFN_glBufferSubData bufferSubData = nullptr
PFN_glVertexAttribPointer vertexAttribPointer = nullptr
PFN_glEnableVertexAttribArray enableVertexAttribArray = nullptr
PFN_glGetUniformLocation getUniformLocation = nullptr
PFN_glUniformMatrix4fv uniformMatrix4fv = nullptr
PFN_glDrawElements drawElements = nullptr
PFN_glEnable enable = nullptr
PFN_glBlendFunc blendFunc = nullptr
PFN_glDisable disable = nullptr
void load()
constexpr const char* GL_VERTEX_SHADER_2D = R"glsl( #version 330 core layout(location = 0) in vec2 aPos; layout(location = 1) in vec2 aTexCoord; layout(location = 2) in vec4 aColor; uniform mat4 uProjection; out vec4 vColor; out vec2 vTexCoord; void main() { gl_Position = uProjection * vec4(aPos, 0.0, 1.0); vColor = aColor; vTexCoord = aTexCoord; } )glsl"
constexpr const char* GL_FRAGMENT_SHADER_2D = R"glsl( #version 330 core in vec4 vColor; in vec2 vTexCoord; out vec4 fragColor; void main() { fragColor = vColor; } )glsl"
struct DepthBufferConfig 3
uint32_t width = 0
uint32_t height = 0
[[nodiscard]] bool isValid() const noexcept
class VulkanDepthBuffer 12
VulkanDepthBuffer() = default
~VulkanDepthBuffer()
VulkanDepthBuffer(const VulkanDepthBuffer&) = delete
VulkanDepthBuffer& operator=(const VulkanDepthBuffer&) = delete
VulkanDepthBuffer(VulkanDepthBuffer&& other) noexcept
VulkanDepthBuffer& operator=(VulkanDepthBuffer&& other) noexcept
void initialize(VkDevice device, VkPhysicalDevice physDevice, uint32_t width, uint32_t height)
void destroy() noexcept
[[nodiscard]] VkImageView imageView() const noexcept
[[nodiscard]] VkFormat format() const noexcept
[[nodiscard]] bool isInitialized() const noexcept
[[nodiscard]] static VkFormat findSupportedFormat(VkPhysicalDevice physDevice)
struct DescriptorPoolConfig 5
uint32_t maxSets = 0
std::vector<VkDescriptorPoolSize> poolSizes
[[nodiscard]] bool isValid() const noexcept
[[nodiscard]] static DescriptorPoolConfig uniformBuffer(uint32_t maxSets, uint32_t count)
[[nodiscard]] static DescriptorPoolConfig combinedImageSampler(uint32_t maxSets, uint32_t count)
class VulkanDescriptorPool 12
VulkanDescriptorPool() = default
~VulkanDescriptorPool()
VulkanDescriptorPool(const VulkanDescriptorPool&) = delete
VulkanDescriptorPool& operator=(const VulkanDescriptorPool&) = delete
VulkanDescriptorPool(VulkanDescriptorPool&& other) noexcept
VulkanDescriptorPool& operator=(VulkanDescriptorPool&& other) noexcept
void initialize( VkDevice device, uint32_t maxSets, const std::vector<VkDescriptorPoolSize>& poolSizes)
[[nodiscard]] VkDescriptorSet allocateSet(VkDescriptorSetLayout layout)
void resetPool() noexcept
void destroy() noexcept
[[nodiscard]] VkDescriptorPool handle() const noexcept
[[nodiscard]] bool isInitialized() const noexcept
class VulkanBuffer : public IBuffer 10
VulkanBuffer(BufferType bufferType, std::uint32_t sizeBytes) noexcept
VulkanBuffer( VkDevice device, VkPhysicalDevice physDevice, BufferType bufferType, std::uint32_t sizeBytes, bool dynamic, const void* initialData)
~VulkanBuffer() override
VulkanBuffer(const VulkanBuffer&) = delete
VulkanBuffer& operator=(const VulkanBuffer&) = delete
VulkanBuffer(VulkanBuffer&&) = delete
VulkanBuffer& operator=(VulkanBuffer&&) = delete
[[nodiscard]] std::uint32_t size() const noexcept override
[[nodiscard]] BufferType type() const noexcept override
[[nodiscard]] VkBuffer handle() const noexcept
class VulkanCommandList : public ICommandList 12
VulkanCommandList() = default
explicit VulkanCommandList(VkCommandBuffer cmdBuf) noexcept
void begin() override
void end() override
void setRenderTarget(IRenderTarget*) override
void clearRenderTarget(const sgc::Colorf&) override
void setPipeline(IPipeline*) override
void setVertexBuffer(IBuffer* buffer) override
void setIndexBuffer(IBuffer* buffer) override
void drawIndexed(std::uint32_t indexCount, std::uint32_t startIndex, std::int32_t baseVertex) override
void draw(std::uint32_t vertexCount, std::uint32_t startVertex) override
[[nodiscard]] VkCommandBuffer handle() const noexcept
class VulkanDevice : public IDevice 15
explicit VulkanDevice(mitiru::GlfwWindow* window)
~VulkanDevice() override
VulkanDevice(const VulkanDevice&) = delete
VulkanDevice& operator=(const VulkanDevice&) = delete
VulkanDevice(VulkanDevice&&) = delete
VulkanDevice& operator=(VulkanDevice&&) = delete
[[nodiscard]] std::vector<std::uint8_t> readPixels( int width, int height) const override
[[nodiscard]] Backend backend() const noexcept override
void beginFrame() override
void endFrame() override
[[nodiscard]] std::unique_ptr<IBuffer> createBuffer( BufferType bufferType, std::uint32_t sizeBytes, bool dynamic, const void* initialData) override
[[nodiscard]] std::unique_ptr<ICommandList> createCommandList() override
[[nodiscard]] uint32_t currentFrameIndex() const override
[[nodiscard]] uint32_t frameInFlightCount() const override
void waitForGpu() override
struct FramebufferConfig 6
uint32_t width = 0
uint32_t height = 0
uint32_t attachmentCount = 0
[[nodiscard]] bool isValid() const noexcept
[[nodiscard]] static FramebufferConfig colorOnly(uint32_t w, uint32_t h)
[[nodiscard]] static FramebufferConfig colorDepth(uint32_t w, uint32_t h)
class VulkanFramebuffer 10
VulkanFramebuffer() = default
~VulkanFramebuffer()
VulkanFramebuffer(const VulkanFramebuffer&) = delete
VulkanFramebuffer& operator=(const VulkanFramebuffer&) = delete
VulkanFramebuffer(VulkanFramebuffer&& other) noexcept
VulkanFramebuffer& operator=(VulkanFramebuffer&& other) noexcept
void initialize( VkDevice device, VkRenderPass renderPass, const std::vector<VkImageView>& attachments, uint32_t width, uint32_t height)
void destroy() noexcept
[[nodiscard]] VkFramebuffer handle() const noexcept
[[nodiscard]] bool isInitialized() const noexcept
struct VulkanAppInfo 5
std::string appName = "MitiruApp"
std::uint32_t appVersion = 1
std::string engineName = "MitiruEngine"
std::uint32_t engineVersion = 1
std::uint32_t apiVersion = 0
struct VulkanValidationConfig 5
bool enableValidation = false
bool enableDebugMessenger = false
std::vector<std::string> requiredLayers
[[nodiscard]] static VulkanValidationConfig debug() noexcept
[[nodiscard]] static VulkanValidationConfig release() noexcept
struct VulkanInstanceDesc 6
VulkanAppInfo appInfo
VulkanValidationConfig validation
std::vector<std::string> requiredExtensions
[[nodiscard]] bool hasExtension(const std::string& extensionName) const noexcept
void addExtension(const std::string& extensionName)
void addSurfaceExtensions()
class VulkanInstance 9
explicit VulkanInstance(const VulkanInstanceDesc& desc)
~VulkanInstance()
VulkanInstance(const VulkanInstance&) = delete
VulkanInstance& operator=(const VulkanInstance&) = delete
VulkanInstance(VulkanInstance&&) = delete
VulkanInstance& operator=(VulkanInstance&&) = delete
[[nodiscard]] VkInstance handle() const noexcept
[[nodiscard]] const VulkanInstanceDesc& desc() const noexcept
[[nodiscard]] bool isValidationEnabled() const noexcept
enum QueueFamily : std::uint8_t 4
Graphics = 0
Compute
Transfer
Present
enum GpuType : std::uint8_t 7
Unknown = 0
IntegratedGpu
DiscreteGpu
VirtualGpu
Cpu
[[nodiscard]] inline int scorePhysicalDevice(const PhysicalDeviceInfo& info) noexcept
[[nodiscard]] inline std::optional<std::size_t> selectBestDevice( const std::vector<PhysicalDeviceInfo>& devices) noexcept
struct QueueFamilyIndices 6
std::optional<std::uint32_t> graphics
std::optional<std::uint32_t> compute
std::optional<std::uint32_t> transfer
std::optional<std::uint32_t> present
[[nodiscard]] bool isComplete() const noexcept
[[nodiscard]] bool hasAll() const noexcept
struct PhysicalDeviceInfo 10
std::string deviceName
std::uint32_t vendorId = 0
std::uint32_t deviceId = 0
GpuType gpuType = GpuType::Unknown
std::uint32_t apiVersion = 0
std::uint32_t driverVersion = 0
std::uint64_t dedicatedVideoMemory = 0
QueueFamilyIndices queueFamilies
std::vector<std::string> supportedExtensions
[[nodiscard]] bool supportsExtension(const std::string& extensionName) const noexcept
class VulkanPhysicalDevice 4
explicit VulkanPhysicalDevice(const PhysicalDeviceInfo& info)
[[nodiscard]] const PhysicalDeviceInfo& info() const noexcept
[[nodiscard]] const QueueFamilyIndices& queueFamilies() const noexcept
[[nodiscard]] int score() const noexcept
enum PrimitiveTopology : std::uint8_t 5
TriangleList = 0
TriangleStrip
LineList
LineStrip
PointList
enum PolygonMode : std::uint8_t 3
Fill = 0
Line
Point
enum CullMode : std::uint8_t 3
None = 0
Front
Back
enum FrontFace : std::uint8_t 2
CounterClockwise = 0
Clockwise
enum CompareOp : std::uint8_t 8
Never = 0
Less
Equal
LessOrEqual
Greater
NotEqual
GreaterOrEqual
Always
struct VertexInputAttribute 4
std::uint32_t location = 0
std::uint32_t binding = 0
PixelFormat format = PixelFormat::RGBA8
std::uint32_t offset = 0
struct VertexInputBinding 3
std::uint32_t binding = 0
std::uint32_t stride = 0
bool perInstance = false
struct VertexInputState 2
std::vector<VertexInputBinding> bindings
std::vector<VertexInputAttribute> attributes
struct RasterizerState 8
PolygonMode polygonMode = PolygonMode::Fill
CullMode cullMode = CullMode::Back
FrontFace frontFace = FrontFace::CounterClockwise
bool depthClampEnable = false
bool depthBiasEnable = false
float depthBiasConstant = 0.0f
float depthBiasSlope = 0.0f
float lineWidth = 1.0f
struct MultisampleState 3
std::uint32_t sampleCount = 1
bool sampleShadingEnable = false
float minSampleShading = 1.0f
struct DepthStencilState 4
bool depthTestEnable = true
bool depthWriteEnable = true
CompareOp depthCompareOp = CompareOp::Less
bool stencilTestEnable = false
struct ShaderStageDesc 3
ShaderType type = ShaderType::Vertex
std::vector<std::uint8_t> code
std::string entryPoint = "main"
struct PushConstantRange 3
ShaderType stageFlags = ShaderType::Vertex
std::uint32_t offset = 0
std::uint32_t size = 0
struct PipelineLayoutDesc 2
std::vector<PushConstantRange> pushConstantRanges
std::uint32_t descriptorSetLayoutCount = 0
struct GraphicsPipelineDesc 10
std::vector<ShaderStageDesc> shaderStages
VertexInputState vertexInput
PrimitiveTopology topology = PrimitiveTopology::TriangleList
RasterizerState rasterizer
MultisampleState multisample
DepthStencilState depthStencil
BlendMode blendMode = BlendMode::None
PipelineLayoutDesc layout
[[nodiscard]] static GraphicsPipelineDesc default2D()
[[nodiscard]] static GraphicsPipelineDesc default3D()
class VulkanGraphicsPipeline : public IPipeline 10
VulkanGraphicsPipeline(VkDevice device, VkRenderPass renderPass, const GraphicsPipelineDesc& desc)
~VulkanGraphicsPipeline() override
VulkanGraphicsPipeline(const VulkanGraphicsPipeline&) = delete
VulkanGraphicsPipeline& operator=(const VulkanGraphicsPipeline&) = delete
VulkanGraphicsPipeline(VulkanGraphicsPipeline&&) = delete
VulkanGraphicsPipeline& operator=(VulkanGraphicsPipeline&&) = delete
[[nodiscard]] bool isValid() const noexcept override
[[nodiscard]] VkPipeline handle() const noexcept
[[nodiscard]] VkPipelineLayout layout() const noexcept
[[nodiscard]] const GraphicsPipelineDesc& desc() const noexcept
enum AttachmentLoadOp : std::uint8_t 3
Load = 0
Clear
DontCare
enum AttachmentStoreOp : std::uint8_t 2
Store = 0
DontCare
enum ImageLayout : std::uint8_t 7
Undefined = 0
ColorAttachment
DepthStencilAttachment
ShaderReadOnly
PresentSrc
TransferSrc
TransferDst
struct AttachmentDesc 8
PixelFormat format = PixelFormat::RGBA8
std::uint32_t sampleCount = 1
AttachmentLoadOp loadOp = AttachmentLoadOp::Clear
AttachmentStoreOp storeOp = AttachmentStoreOp::Store
AttachmentLoadOp stencilLoadOp = AttachmentLoadOp::DontCare
AttachmentStoreOp stencilStoreOp = AttachmentStoreOp::DontCare
ImageLayout initialLayout = ImageLayout::Undefined
ImageLayout finalLayout = ImageLayout::PresentSrc
struct AttachmentReference 2
std::uint32_t attachmentIndex = 0
ImageLayout layout = ImageLayout::ColorAttachment
struct SubpassDesc 6
std::vector<AttachmentReference> colorAttachments
std::vector<AttachmentReference> inputAttachments
std::vector<AttachmentReference> resolveAttachments
std::uint32_t depthStencilAttachment = UINT32_MAX
ImageLayout depthStencilLayout = ImageLayout::DepthStencilAttachment
[[nodiscard]] bool hasDepthStencil() const noexcept
struct SubpassDependency 7
std::uint32_t srcSubpass = UINT32_MAX
std::uint32_t dstSubpass = 0
std::uint32_t srcStageMask = 0
std::uint32_t dstStageMask = 0
std::uint32_t srcAccessMask = 0
std::uint32_t dstAccessMask = 0
[[nodiscard]] static SubpassDependency externalToFirst() noexcept
struct RenderPassDesc 5
std::vector<AttachmentDesc> attachments
std::vector<SubpassDesc> subpasses
std::vector<SubpassDependency> dependencies
[[nodiscard]] static RenderPassDesc simpleColor( PixelFormat format = PixelFormat::BGRA8)
[[nodiscard]] static RenderPassDesc colorDepth( PixelFormat colorFormat = PixelFormat::BGRA8)
class VulkanRenderPass 8
VulkanRenderPass(VkDevice device, const RenderPassDesc& desc)
~VulkanRenderPass()
VulkanRenderPass(const VulkanRenderPass&) = delete
VulkanRenderPass& operator=(const VulkanRenderPass&) = delete
VulkanRenderPass(VulkanRenderPass&&) = delete
VulkanRenderPass& operator=(VulkanRenderPass&&) = delete
[[nodiscard]] VkRenderPass handle() const noexcept
[[nodiscard]] const RenderPassDesc& desc() const noexcept
class VulkanRenderTarget : public IRenderTarget 5
VulkanRenderTarget(int width, int height) noexcept
[[nodiscard]] int width() const noexcept override
[[nodiscard]] int height() const noexcept override
[[nodiscard]] ITexture* texture() noexcept override
void updateSize(int width, int height) noexcept
class VulkanSwapChain : public ISwapChain 7
VulkanSwapChain(int width, int height)
void present() override
void resize(int width, int height) override
[[nodiscard]] IRenderTarget* backBuffer() noexcept override
[[nodiscard]] bool needsRecreation() const noexcept
void setNeedsRecreation(bool needs) noexcept
void recreate( VkDevice , VkPhysicalDevice , VkSurfaceKHR , int width, int height)
struct TextureConfig 8
uint32_t width = 0
uint32_t height = 0
VkFormat format = VK_FORMAT_R8G8B8A8_UNORM
VkImageUsageFlags usage = VK_IMAGE_USAGE_SAMPLED_BIT
VkImageAspectFlags aspectMask = VK_IMAGE_ASPECT_COLOR_BIT
[[nodiscard]] bool isValid() const noexcept
[[nodiscard]] static TextureConfig color(uint32_t w, uint32_t h, VkFormat fmt = VK_FORMAT_R8G8B8A8_UNORM)
[[nodiscard]] static TextureConfig depth(uint32_t w, uint32_t h, VkFormat fmt = VK_FORMAT_D32_SFLOAT)
class VulkanTexture 13
VulkanTexture() = default
~VulkanTexture()
VulkanTexture(const VulkanTexture&) = delete
VulkanTexture& operator=(const VulkanTexture&) = delete
VulkanTexture(VulkanTexture&& other) noexcept
VulkanTexture& operator=(VulkanTexture&& other) noexcept
void initialize( VkDevice device, VkPhysicalDevice physDevice, uint32_t width, uint32_t height, VkFormat format, VkImageUsageFlags usage, VkImageAspectFlags aspectMask = VK_IMAGE_ASPECT_COLOR_BIT)
void destroy() noexcept
[[nodiscard]] VkImage image() const noexcept
[[nodiscard]] VkImageView imageView() const noexcept
[[nodiscard]] VkSampler sampler() const noexcept
[[nodiscard]] VkFormat format() const noexcept
[[nodiscard]] bool isInitialized() const noexcept
class WebGLCommandList : public ICommandList 10
void begin() override
void end() override
void setRenderTarget(IRenderTarget*) override
void clearRenderTarget(const sgc::Colorf& color) override
void setPipeline(IPipeline* pipeline) override
void setVertexBuffer(IBuffer* buffer) override
void setIndexBuffer(IBuffer* buffer) override
void drawIndexed(std::uint32_t indexCount, std::uint32_t startIndex, std::int32_t) override
void draw(std::uint32_t vertexCount, std::uint32_t startVertex) override
void setViewport(float width, float height) override
class WebGLDevice : public IDevice 21
explicit WebGLDevice(const char* canvasId = "#canvas")
~WebGLDevice() override
WebGLDevice(const WebGLDevice&) = delete
WebGLDevice& operator=(const WebGLDevice&) = delete
WebGLDevice(WebGLDevice&&) = delete
WebGLDevice& operator=(WebGLDevice&&) = delete
[[nodiscard]] std::vector<std::uint8_t> readPixels( int width, int height) const override
[[nodiscard]] Backend backend() const noexcept override
void beginFrame() override
void endFrame() override
void checkGLError(const char* context) const noexcept
[[nodiscard]] std::unique_ptr<IBuffer> createBuffer( BufferType bufferType, std::uint32_t sizeBytes, bool dynamic, const void* initialData) override
[[nodiscard]] std::unique_ptr<ICommandList> createCommandList() override
[[nodiscard]] WebGLShader createShaderProgram( std::string_view vertexSource, std::string_view fragmentSource) const
[[nodiscard]] WebGLShader createDefaultShader2D() const
[[nodiscard]] WebGLTexture createTexture( int width, int height, PixelFormat pixelFormat, std::span<const std::uint8_t> data) const
[[nodiscard]] WebGLTexture createEmptyTexture( int width, int height, PixelFormat pixelFormat = PixelFormat::RGBA8) const
[[nodiscard]] WebGLPipeline createPipeline(const WebGLPipelineDesc& desc) const
[[nodiscard]] int canvasWidth() const noexcept
[[nodiscard]] int canvasHeight() const noexcept
void setViewport(int x, int y, int width, int height) const noexcept
class WebGLBuffer : public IBuffer 12
WebGLBuffer( BufferType bufferType, std::uint32_t sizeBytes, bool dynamic, const void* initialData)
~WebGLBuffer() override
WebGLBuffer(const WebGLBuffer&) = delete
WebGLBuffer& operator=(const WebGLBuffer&) = delete
WebGLBuffer(WebGLBuffer&&) = delete
WebGLBuffer& operator=(WebGLBuffer&&) = delete
void update(const void* data, std::uint32_t sizeBytes) override
[[nodiscard]] std::uint32_t size() const noexcept override
[[nodiscard]] BufferType type() const noexcept override
[[nodiscard]] bool isDynamic() const noexcept
[[nodiscard]] GLuint handle() const noexcept
[[nodiscard]] GLenum bufferTarget() const noexcept
struct WebGLPipelineDesc 7
WebGLShader* shader = nullptr
VertexFormat vertexFormat = VertexFormat::PositionTexCoord
BlendMode blendMode = BlendMode::Alpha
bool depthTest = true
bool depthWrite = true
bool cullFace = false
bool wireframe = false
class WebGLPipeline : public IPipeline 13
explicit WebGLPipeline(const WebGLPipelineDesc& desc)
~WebGLPipeline() override
WebGLPipeline(const WebGLPipeline&) = delete
WebGLPipeline& operator=(const WebGLPipeline&) = delete
WebGLPipeline(WebGLPipeline&& other) noexcept
WebGLPipeline& operator=(WebGLPipeline&& other) noexcept
[[nodiscard]] bool isValid() const noexcept override
[[nodiscard]] WebGLShader* shader() const noexcept
[[nodiscard]] GLuint vao() const noexcept
void bind() const noexcept
static void unbind() noexcept
constexpr const char* WEBGL_VERTEX_SHADER_2D = R"glsl(#version 300 es precision highp float; layout(location = 0) in vec2 aPos; layout(location = 1) in vec2 aTexCoord; layout(location = 2) in vec4 aColor; uniform mat4 uProjection; out vec4 vColor; out vec2 vTexCoord; void main() { gl_Position = uProjection * vec4(aPos, 0.0, 1.0); vColor = aColor; vTexCoord = aTexCoord; } )glsl"
constexpr const char* WEBGL_FRAGMENT_SHADER_2D = R"glsl(#version 300 es precision highp float; in vec4 vColor; in vec2 vTexCoord; uniform sampler2D uTexture; uniform int uUseTexture; out vec4 fragColor; void main() { if (uUseTexture != 0) { fragColor = texture(uTexture, vTexCoord) * vColor; } else { fragColor = vColor; } } )glsl"
class WebGLShader : public IShader 16
[[nodiscard]] static WebGLShader createProgram( std::string_view vertexSource, std::string_view fragmentSource)
[[nodiscard]] static WebGLShader createVertexShader(std::string_view source)
[[nodiscard]] static WebGLShader createFragmentShader(std::string_view source)
~WebGLShader() override
WebGLShader(const WebGLShader&) = delete
WebGLShader& operator=(const WebGLShader&) = delete
WebGLShader(WebGLShader&& other) noexcept
WebGLShader& operator=(WebGLShader&& other) noexcept
[[nodiscard]] ShaderType type() const noexcept override
[[nodiscard]] GLuint program() const noexcept
[[nodiscard]] GLuint vertexShader() const noexcept
[[nodiscard]] GLuint fragmentShader() const noexcept
[[nodiscard]] bool isValid() const noexcept
[[nodiscard]] GLint getUniformLocation(const char* name) const noexcept
[[nodiscard]] GLint getAttribLocation(const char* name) const noexcept
void use() const noexcept
enum TextureFilter 2
Nearest
Linear
enum TextureWrap 3
Repeat
ClampToEdge
MirroredRepeat
class WebGLTexture : public ITexture 17
[[nodiscard]] static WebGLTexture createFromData( int width, int height, PixelFormat pixelFormat, std::span<const std::uint8_t> data)
[[nodiscard]] static WebGLTexture createEmpty( int width, int height, PixelFormat pixelFormat = PixelFormat::RGBA8)
~WebGLTexture() override
WebGLTexture(const WebGLTexture&) = delete
WebGLTexture& operator=(const WebGLTexture&) = delete
WebGLTexture(WebGLTexture&& other) noexcept
WebGLTexture& operator=(WebGLTexture&& other) noexcept
[[nodiscard]] int width() const noexcept override
[[nodiscard]] int height() const noexcept override
[[nodiscard]] PixelFormat format() const noexcept override
[[nodiscard]] GLuint handle() const noexcept
void bind(GLuint unit = 0) const noexcept
static void unbind(GLuint unit = 0) noexcept
void updateSubImage( int x, int y, int w, int h, const void* data) noexcept
void setFilter(TextureFilter minFilter, TextureFilter magFilter) noexcept
void setWrap(TextureWrap wrapS, TextureWrap wrapT) noexcept
void generateMipmaps() noexcept
class WebGPUBuffer : public IBuffer 12
WebGPUBuffer( WGPUDevice device, BufferType bufferType, std::uint32_t sizeBytes, bool dynamic, const void* initialData)
~WebGPUBuffer() override
WebGPUBuffer(const WebGPUBuffer&) = delete
WebGPUBuffer& operator=(const WebGPUBuffer&) = delete
WebGPUBuffer(WebGPUBuffer&& other) noexcept
WebGPUBuffer& operator=(WebGPUBuffer&& other) noexcept
[[nodiscard]] std::uint32_t size() const noexcept override
void update(WGPUQueue queue, const void* data, std::uint32_t sizeBytes, std::uint32_t offset = 0) const
[[nodiscard]] WGPUBuffer handle() const noexcept
[[nodiscard]] BufferType bufferType() const noexcept
constexpr const char* WEBGPU_VERTEX_SHADER_2D = R"wgsl( struct Uniforms { projection: mat4x4<f32>, }; @binding(0) @group(0) var<uniform> uniforms: Uniforms; struct VertexInput { @location(0) position: vec2<f32>, @location(1) texCoord: vec2<f32>, @location(2) color: vec4<f32>, }; struct VertexOutput { @builtin(position) position: vec4<f32>, @location(0) color: vec4<f32>, @location(1) texCoord: vec2<f32>, }; @vertex fn main(input: VertexInput) -> VertexOutput { var output: VertexOutput; output.position = uniforms.projection * vec4<f32>(input.position, 0.0, 1.0); output.color = input.color; output.texCoord = input.texCoord; return output; } )wgsl"
constexpr const char* WEBGPU_FRAGMENT_SHADER_2D = R"wgsl( @group(1) @binding(0) var texSampler: sampler; @group(1) @binding(1) var texColor: texture_2d<f32>; struct Params { useTexture: f32, }; @group(1) @binding(2) var<uniform> params: Params; struct FragmentInput { @location(0) color: vec4<f32>, @location(1) texCoord: vec2<f32>, }; @fragment fn main(input: FragmentInput) -> @location(0) vec4<f32> { if (params.useTexture > 0.5) { let texColor = textureSample(texColor, texSampler, input.texCoord); return texColor * input.color; } return input.color; } )wgsl"
class WebGPUCommandList : public ICommandList 18
explicit WebGPUCommandList(WGPUDevice device)
~WebGPUCommandList() override
WebGPUCommandList(const WebGPUCommandList&) = delete
WebGPUCommandList& operator=(const WebGPUCommandList&) = delete
WebGPUCommandList(WebGPUCommandList&&) = delete
WebGPUCommandList& operator=(WebGPUCommandList&&) = delete
void begin() override
void end() override
void setRenderTarget(IRenderTarget*) override
void clearRenderTarget(const sgc::Colorf& color) override
void setPipeline(IPipeline*) override
void setVertexBuffer(IBuffer* buffer) override
void setIndexBuffer(IBuffer* buffer) override
void drawIndexed(std::uint32_t indexCount, std::uint32_t startIndex, std::int32_t) override
void draw(std::uint32_t vertexCount, std::uint32_t startVertex) override
void setViewport(float width, float height) override
void beginRenderPass(WGPUTextureView textureView)
void submit(WGPUQueue queue)
class WebGPUDevice : public IDevice 23
explicit WebGPUDevice(const char* canvasId = "#canvas")
~WebGPUDevice() override
WebGPUDevice(const WebGPUDevice&) = delete
WebGPUDevice& operator=(const WebGPUDevice&) = delete
WebGPUDevice(WebGPUDevice&&) = delete
WebGPUDevice& operator=(WebGPUDevice&&) = delete
void init(std::function<void(bool)> callback)
[[nodiscard]] std::vector<std::uint8_t> readPixels( int width, int height) const override
[[nodiscard]] Backend backend() const noexcept override
void beginFrame() override
void endFrame() override
[[nodiscard]] std::unique_ptr<IBuffer> createBuffer( BufferType bufferType, std::uint32_t sizeBytes, bool dynamic, const void* initialData) override
[[nodiscard]] std::unique_ptr<ICommandList> createCommandList() override
void waitForGpu() override
[[nodiscard]] WGPUShaderModule createShaderModule( std::string_view wgslSource) const
[[nodiscard]] WGPUShaderModule createDefaultVertexShader2D() const
[[nodiscard]] WGPUShaderModule createDefaultFragmentShader2D() const
[[nodiscard]] bool isInitialized() const noexcept
[[nodiscard]] WGPUDevice deviceHandle() const noexcept
[[nodiscard]] WGPUQueue queue() const noexcept
[[nodiscard]] WGPUTextureView currentTextureView() const noexcept
[[nodiscard]] int canvasWidth() const noexcept
[[nodiscard]] int canvasHeight() const noexcept

Sourced from docs/API_CATALOG.md, auto-generated by tools/generate_api_catalog.py.