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.
Free functions and typedefs
[[nodiscard]] inline std::unique_ptr<IDevice> createDevice( Backend backend, [[maybe_unused]] IWindow* window = nullptr)enum VertexFormat 4
Position2DPosition3DPositionColorPositionTexCoordenum PixelFormat 4
RGBA8BGRA8R8Depth24Stencil8enum BlendMode 7
NoneAlphaAdditiveMultiplicativeScreenOverlayColorDodgeenum ResourceState : uint32_t 8
Common = 0RenderTargetPresentShaderResourceDepthWriteCopyDestCopySrcUnorderedAccessenum DescriptorHeapType : uint8_t 5
CbvSrvUavRtvDsvSamplerusing FenceValue = uint64_t;struct TextureDesc 4
int width = 0int height = 0PixelFormat format = PixelFormat::RGBA8bool renderTarget = falsestruct BufferDesc 4
enum `Usage` { Vertex, Index, Constant }Usage usage = Usage::Vertexstd::uint32_t sizeBytes = 0bool dynamic = falsestruct GpuDescriptorHandle 2
uint64_t ptr = 0[[nodiscard]] constexpr bool isValid() const noexceptstruct CpuDescriptorHandle 2
uint64_t ptr = 0[[nodiscard]] constexpr bool isValid() const noexceptenum BufferType 3
VertexIndexConstantclass 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 noexceptvirtual void update(const void* data, std::uint32_t sizeBytes)[[nodiscard]] virtual uint64_t gpuVirtualAddress() constclass ICommandList 18
virtual ~ICommandList() = defaultvirtual void begin() = 0virtual void end() = 0virtual void setRenderTarget(IRenderTarget* target) = 0virtual void clearRenderTarget(const sgc::Colorf& color) = 0virtual void setPipeline(IPipeline* pipeline) = 0virtual void setVertexBuffer(IBuffer* buffer) = 0virtual void setIndexBuffer(IBuffer* buffer) = 0virtual void drawIndexed(std::uint32_t indexCount, std::uint32_t startIndex = 0, std::int32_t baseVertex = 0) = 0virtual void draw(std::uint32_t vertexCount, std::uint32_t startVertex = 0) = 0virtual 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() = 0virtual void free(CpuDescriptorHandle handle) = 0[[nodiscard]] virtual GpuDescriptorHandle gpuHandle(CpuDescriptorHandle cpuHandle) const = 0class 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 = 0virtual void setClearColor(float r, float g, float b, float a = 1.0f)virtual void beginFrame() = 0virtual 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 = 0virtual void signal(FenceValue value) = 0virtual void waitForValue(FenceValue value) = 0[[nodiscard]] virtual bool isComplete(FenceValue value) const = 0class IPipeline 3
virtual ~IPipeline() = default[[nodiscard]] virtual bool isValid() const noexcept = 0[[nodiscard]] virtual void* rootSignature() constclass IRenderTarget 4
virtual ~IRenderTarget() = default[[nodiscard]] virtual int width() const noexcept = 0[[nodiscard]] virtual int height() const noexcept = 0[[nodiscard]] virtual ITexture* texture() noexcept = 0enum ShaderType 3
VertexPixelComputeclass IShader 2
virtual ~IShader() = default[[nodiscard]] virtual ShaderType type() const noexcept = 0class ISwapChain 6
virtual ~ISwapChain() = defaultvirtual void present() = 0virtual void resize(int width, int height) = 0[[nodiscard]] virtual IRenderTarget* backBuffer() noexcept = 0[[nodiscard]] virtual uint32_t currentBackBufferIndex() const[[nodiscard]] virtual uint32_t bufferCount() constclass 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 = 0class 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 noexceptclass Dx11CommandList : public ICommandList 16
explicit Dx11CommandList(ID3D11DeviceContext* context)void begin() overridevoid end() overridevoid setRenderTarget(IRenderTarget* target) overridevoid clearRenderTarget(const sgc::Colorf& color) overridevoid setPipeline(IPipeline* pipeline) overridevoid setVertexBuffer(IBuffer* buffer) overridevoid setIndexBuffer(IBuffer* buffer) overridevoid 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) overridevoid draw(std::uint32_t vertexCount, std::uint32_t startVertex) overridevoid 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 noexceptclass 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 overridevoid beginFrame() overridevoid 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() overridevoid onResize(int w, int h) overridevoid resetRenderTargetFor2D() overridevoid setPostProcessManager(void* pp) overridevoid beginPostProcess() overridevoid endPostProcess() overrideclass 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 noexceptvoid release()struct Dx11PipelineDesc 5
Dx11Shader* vertexShader = nullptrDx11Shader* pixelShader = nullptrBlendMode blendMode = BlendMode::Alphabool wireframe = falsebool scissorEnable = falseclass 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 overridevoid bind(ID3D11DeviceContext* context) constclass 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 noexceptvoid 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::gfxclass Dx11SwapChain : public ISwapChain 7
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>Dx11SwapChain( ID3D11Device* device, HWND hwnd, int width, int height)void present() overridevoid resize(int width, int height) override[[nodiscard]] IRenderTarget* backBuffer() noexcept override[[nodiscard]] ID3D11RenderTargetView* getRenderTargetView() const noexcept[[nodiscard]] IDXGISwapChain* getSwapChain() const noexceptclass 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 noexceptclass 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 noexceptvoid update(const void* data, std::uint32_t dataSize) override[[nodiscard]] ID3D12Resource* nativeResource() const noexceptclass Dx12CommandList : public ICommandList 21
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>Dx12CommandList(ID3D12Device* device)void reset() overridevoid begin() overridevoid end() overridevoid close() overridevoid setRenderTarget(IRenderTarget* target) overridevoid clearRenderTarget(const sgc::Colorf& color) overridevoid setPipeline(IPipeline* pipeline) overridevoid setVertexBuffer(IBuffer* buffer) overridevoid setIndexBuffer(IBuffer* buffer) overridevoid drawIndexed(std::uint32_t indexCount, std::uint32_t startIndex, std::int32_t baseVertex) overridevoid draw(std::uint32_t vertexCount, std::uint32_t startVertex) overridevoid setViewport(float width, float height) overridevoid resourceBarrier( ITexture* resource, ResourceState before, ResourceState after) overridevoid resourceBarrierDirect( ID3D12Resource* resource, D3D12_RESOURCE_STATES before, D3D12_RESOURCE_STATES after)void setRootSignature(void* rootSignature) overridevoid setDescriptorHeaps( IDescriptorHeap* const* heaps, uint32_t count) overridevoid setGraphicsRootDescriptorTable( uint32_t paramIndex, GpuDescriptorHandle handle) overridevoid setGraphicsRootCBV( uint32_t paramIndex, uint64_t gpuVirtualAddress) override[[nodiscard]] ID3D12GraphicsCommandList* nativeCommandList() const noexceptclass 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() overridevoid 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::gfxclass Dx12Fence : public IGpuFence 12
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>Dx12Fence(ID3D12Device* device, ID3D12CommandQueue* commandQueue, FenceValue initialValue = 0)~Dx12Fence() overrideDx12Fence(const Dx12Fence&) = deleteDx12Fence& operator=(const Dx12Fence&) = deleteDx12Fence(Dx12Fence&& other) noexceptDx12Fence& operator=(Dx12Fence&& other) noexcept[[nodiscard]] FenceValue currentValue() const overridevoid signal(FenceValue value) overridevoid waitForValue(FenceValue value) override[[nodiscard]] bool isComplete(FenceValue value) const override[[nodiscard]] ID3D12Fence* nativeFence() const noexceptclass 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 noexceptvoid release()struct Dx12PipelineDesc 6
Dx12Shader* vertexShader = nullptrDx12Shader* pixelShader = nullptrBlendMode blendMode = BlendMode::Alphabool wireframe = falseDXGI_FORMAT rtvFormat = DXGI_FORMAT_R8G8B8A8_UNORMuint32_t numRenderTargets = 1class 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 noexceptclass 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 noexceptvoid 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::gfxclass 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() overridevoid setVSync(bool enabled) noexcept[[nodiscard]] bool isVSyncEnabled() const noexceptvoid 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 noexceptclass Dx12Texture : public ITexture 11
template <typename T> using ComPtr = Microsoft::WRL::ComPtr<T>Dx12Texture() = defaultDx12Texture(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 noexceptvoid setSrvHandle(CpuDescriptorHandle handle) noexcept[[nodiscard]] CpuDescriptorHandle srvHandle() const noexceptclass 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 overrideclass NullCommandList : public ICommandList 9
void begin() overridevoid end() overridevoid setRenderTarget(IRenderTarget*) overridevoid clearRenderTarget(const sgc::Colorf&) overridevoid setPipeline(IPipeline*) overridevoid setVertexBuffer(IBuffer*) overridevoid setIndexBuffer(IBuffer*) overridevoid drawIndexed(std::uint32_t, std::uint32_t, std::int32_t) overridevoid draw(std::uint32_t, std::uint32_t) overrideclass NullDevice : public IDevice 6
[[nodiscard]] std::vector<std::uint8_t> readPixels( int width, int height) const override[[nodiscard]] Backend backend() const noexcept overridevoid beginFrame() overridevoid endFrame() override[[nodiscard]] std::unique_ptr<IBuffer> createBuffer( BufferType bufferType, std::uint32_t sizeBytes, bool , const void* ) override[[nodiscard]] std::unique_ptr<ICommandList> createCommandList() overrideclass GlBuffer : public IBuffer 11
GlBuffer(GlFunctions* gl, BufferType bufferType, std::uint32_t sizeBytes, bool dynamic, const void* initialData = nullptr)~GlBuffer() overrideGlBuffer(const GlBuffer&) = deleteGlBuffer& operator=(const GlBuffer&) = deleteGlBuffer(GlBuffer&& other) noexceptGlBuffer& operator=(GlBuffer&& other) noexceptvoid 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 noexceptclass GlCommandList : public ICommandList 11
GlCommandList(GlFunctions* gl, GLuint program, GLint projectionLoc, GLuint vao, const float* screenWidth, const float* screenHeight)void begin() overridevoid end() overridevoid setRenderTarget(IRenderTarget*) overridevoid clearRenderTarget(const sgc::Colorf& color) overridevoid setPipeline(IPipeline*) overridevoid setVertexBuffer(IBuffer* buffer) overridevoid setIndexBuffer(IBuffer* buffer) overridevoid drawIndexed(std::uint32_t indexCount, std::uint32_t startIndex, std::int32_t baseVertex) overridevoid draw(std::uint32_t vertexCount, std::uint32_t startVertex) overridevoid setViewport(float width, float height) overrideclass GlDevice : public IDevice 19
explicit GlDevice(mitiru::Sdl2Window* window)explicit GlDevice(mitiru::GlfwWindow* window)~GlDevice() overrideGlDevice(const GlDevice&) = deleteGlDevice& operator=(const GlDevice&) = deleteGlDevice(GlDevice&&) = deleteGlDevice& operator=(GlDevice&&) = delete[[nodiscard]] std::vector<std::uint8_t> readPixels( int width, int height) const override[[nodiscard]] Backend backend() const noexcept overridevoid beginFrame() overridevoid 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 noexceptvoid updateScreenSize(float width, float height) noexceptstruct 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 = nullptrPFN_glShaderSource shaderSource = nullptrPFN_glCompileShader compileShader = nullptrPFN_glGetShaderiv getShaderiv = nullptrPFN_glGetShaderInfoLog getShaderInfoLog = nullptrPFN_glCreateProgram createProgram = nullptrPFN_glAttachShader attachShader = nullptrPFN_glLinkProgram linkProgram = nullptrPFN_glGetProgramiv getProgramiv = nullptrPFN_glUseProgram useProgram = nullptrPFN_glDeleteShader deleteShader = nullptrPFN_glDeleteProgram deleteProgram = nullptrPFN_glGenVertexArrays genVertexArrays = nullptrPFN_glDeleteVertexArrays deleteVertexArrays = nullptrPFN_glBindVertexArray bindVertexArray = nullptrPFN_glGenBuffers genBuffers = nullptrPFN_glDeleteBuffers deleteBuffers = nullptrPFN_glBindBuffer bindBuffer = nullptrPFN_glBufferData bufferData = nullptrPFN_glBufferSubData bufferSubData = nullptrPFN_glVertexAttribPointer vertexAttribPointer = nullptrPFN_glEnableVertexAttribArray enableVertexAttribArray = nullptrPFN_glGetUniformLocation getUniformLocation = nullptrPFN_glUniformMatrix4fv uniformMatrix4fv = nullptrPFN_glDrawElements drawElements = nullptrPFN_glEnable enable = nullptrPFN_glBlendFunc blendFunc = nullptrPFN_glDisable disable = nullptrvoid 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 = 0uint32_t height = 0[[nodiscard]] bool isValid() const noexceptclass VulkanDepthBuffer 12
VulkanDepthBuffer() = default~VulkanDepthBuffer()VulkanDepthBuffer(const VulkanDepthBuffer&) = deleteVulkanDepthBuffer& operator=(const VulkanDepthBuffer&) = deleteVulkanDepthBuffer(VulkanDepthBuffer&& other) noexceptVulkanDepthBuffer& operator=(VulkanDepthBuffer&& other) noexceptvoid 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 = 0std::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&) = deleteVulkanDescriptorPool& operator=(const VulkanDescriptorPool&) = deleteVulkanDescriptorPool(VulkanDescriptorPool&& other) noexceptVulkanDescriptorPool& operator=(VulkanDescriptorPool&& other) noexceptvoid initialize( VkDevice device, uint32_t maxSets, const std::vector<VkDescriptorPoolSize>& poolSizes)[[nodiscard]] VkDescriptorSet allocateSet(VkDescriptorSetLayout layout)void resetPool() noexceptvoid destroy() noexcept[[nodiscard]] VkDescriptorPool handle() const noexcept[[nodiscard]] bool isInitialized() const noexceptclass VulkanBuffer : public IBuffer 10
VulkanBuffer(BufferType bufferType, std::uint32_t sizeBytes) noexceptVulkanBuffer( VkDevice device, VkPhysicalDevice physDevice, BufferType bufferType, std::uint32_t sizeBytes, bool dynamic, const void* initialData)~VulkanBuffer() overrideVulkanBuffer(const VulkanBuffer&) = deleteVulkanBuffer& operator=(const VulkanBuffer&) = deleteVulkanBuffer(VulkanBuffer&&) = deleteVulkanBuffer& operator=(VulkanBuffer&&) = delete[[nodiscard]] std::uint32_t size() const noexcept override[[nodiscard]] BufferType type() const noexcept override[[nodiscard]] VkBuffer handle() const noexceptclass VulkanCommandList : public ICommandList 12
VulkanCommandList() = defaultexplicit VulkanCommandList(VkCommandBuffer cmdBuf) noexceptvoid begin() overridevoid end() overridevoid setRenderTarget(IRenderTarget*) overridevoid clearRenderTarget(const sgc::Colorf&) overridevoid setPipeline(IPipeline*) overridevoid setVertexBuffer(IBuffer* buffer) overridevoid setIndexBuffer(IBuffer* buffer) overridevoid drawIndexed(std::uint32_t indexCount, std::uint32_t startIndex, std::int32_t baseVertex) overridevoid draw(std::uint32_t vertexCount, std::uint32_t startVertex) override[[nodiscard]] VkCommandBuffer handle() const noexceptclass VulkanDevice : public IDevice 15
explicit VulkanDevice(mitiru::GlfwWindow* window)~VulkanDevice() overrideVulkanDevice(const VulkanDevice&) = deleteVulkanDevice& operator=(const VulkanDevice&) = deleteVulkanDevice(VulkanDevice&&) = deleteVulkanDevice& operator=(VulkanDevice&&) = delete[[nodiscard]] std::vector<std::uint8_t> readPixels( int width, int height) const override[[nodiscard]] Backend backend() const noexcept overridevoid beginFrame() overridevoid 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 overridevoid waitForGpu() overridestruct FramebufferConfig 6
uint32_t width = 0uint32_t height = 0uint32_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&) = deleteVulkanFramebuffer& operator=(const VulkanFramebuffer&) = deleteVulkanFramebuffer(VulkanFramebuffer&& other) noexceptVulkanFramebuffer& operator=(VulkanFramebuffer&& other) noexceptvoid 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 noexceptstruct VulkanAppInfo 5
std::string appName = "MitiruApp"std::uint32_t appVersion = 1std::string engineName = "MitiruEngine"std::uint32_t engineVersion = 1std::uint32_t apiVersion = 0struct VulkanValidationConfig 5
bool enableValidation = falsebool enableDebugMessenger = falsestd::vector<std::string> requiredLayers[[nodiscard]] static VulkanValidationConfig debug() noexcept[[nodiscard]] static VulkanValidationConfig release() noexceptstruct VulkanInstanceDesc 6
VulkanAppInfo appInfoVulkanValidationConfig validationstd::vector<std::string> requiredExtensions[[nodiscard]] bool hasExtension(const std::string& extensionName) const noexceptvoid addExtension(const std::string& extensionName)void addSurfaceExtensions()class VulkanInstance 9
explicit VulkanInstance(const VulkanInstanceDesc& desc)~VulkanInstance()VulkanInstance(const VulkanInstance&) = deleteVulkanInstance& operator=(const VulkanInstance&) = deleteVulkanInstance(VulkanInstance&&) = deleteVulkanInstance& operator=(VulkanInstance&&) = delete[[nodiscard]] VkInstance handle() const noexcept[[nodiscard]] const VulkanInstanceDesc& desc() const noexcept[[nodiscard]] bool isValidationEnabled() const noexceptenum QueueFamily : std::uint8_t 4
Graphics = 0ComputeTransferPresentenum GpuType : std::uint8_t 7
Unknown = 0IntegratedGpuDiscreteGpuVirtualGpuCpu[[nodiscard]] inline int scorePhysicalDevice(const PhysicalDeviceInfo& info) noexcept[[nodiscard]] inline std::optional<std::size_t> selectBestDevice( const std::vector<PhysicalDeviceInfo>& devices) noexceptstruct QueueFamilyIndices 6
std::optional<std::uint32_t> graphicsstd::optional<std::uint32_t> computestd::optional<std::uint32_t> transferstd::optional<std::uint32_t> present[[nodiscard]] bool isComplete() const noexcept[[nodiscard]] bool hasAll() const noexceptstruct PhysicalDeviceInfo 10
std::string deviceNamestd::uint32_t vendorId = 0std::uint32_t deviceId = 0GpuType gpuType = GpuType::Unknownstd::uint32_t apiVersion = 0std::uint32_t driverVersion = 0std::uint64_t dedicatedVideoMemory = 0QueueFamilyIndices queueFamiliesstd::vector<std::string> supportedExtensions[[nodiscard]] bool supportsExtension(const std::string& extensionName) const noexceptclass VulkanPhysicalDevice 4
explicit VulkanPhysicalDevice(const PhysicalDeviceInfo& info)[[nodiscard]] const PhysicalDeviceInfo& info() const noexcept[[nodiscard]] const QueueFamilyIndices& queueFamilies() const noexcept[[nodiscard]] int score() const noexceptenum PrimitiveTopology : std::uint8_t 5
TriangleList = 0TriangleStripLineListLineStripPointListenum PolygonMode : std::uint8_t 3
Fill = 0LinePointenum CullMode : std::uint8_t 3
None = 0FrontBackenum FrontFace : std::uint8_t 2
CounterClockwise = 0Clockwiseenum CompareOp : std::uint8_t 8
Never = 0LessEqualLessOrEqualGreaterNotEqualGreaterOrEqualAlwaysstruct VertexInputAttribute 4
std::uint32_t location = 0std::uint32_t binding = 0PixelFormat format = PixelFormat::RGBA8std::uint32_t offset = 0struct VertexInputBinding 3
std::uint32_t binding = 0std::uint32_t stride = 0bool perInstance = falsestruct VertexInputState 2
std::vector<VertexInputBinding> bindingsstd::vector<VertexInputAttribute> attributesstruct RasterizerState 8
PolygonMode polygonMode = PolygonMode::FillCullMode cullMode = CullMode::BackFrontFace frontFace = FrontFace::CounterClockwisebool depthClampEnable = falsebool depthBiasEnable = falsefloat depthBiasConstant = 0.0ffloat depthBiasSlope = 0.0ffloat lineWidth = 1.0fstruct MultisampleState 3
std::uint32_t sampleCount = 1bool sampleShadingEnable = falsefloat minSampleShading = 1.0fstruct DepthStencilState 4
bool depthTestEnable = truebool depthWriteEnable = trueCompareOp depthCompareOp = CompareOp::Lessbool stencilTestEnable = falsestruct ShaderStageDesc 3
ShaderType type = ShaderType::Vertexstd::vector<std::uint8_t> codestd::string entryPoint = "main"struct PushConstantRange 3
ShaderType stageFlags = ShaderType::Vertexstd::uint32_t offset = 0std::uint32_t size = 0struct PipelineLayoutDesc 2
std::vector<PushConstantRange> pushConstantRangesstd::uint32_t descriptorSetLayoutCount = 0struct GraphicsPipelineDesc 10
std::vector<ShaderStageDesc> shaderStagesVertexInputState vertexInputPrimitiveTopology topology = PrimitiveTopology::TriangleListRasterizerState rasterizerMultisampleState multisampleDepthStencilState depthStencilBlendMode blendMode = BlendMode::NonePipelineLayoutDesc layout[[nodiscard]] static GraphicsPipelineDesc default2D()[[nodiscard]] static GraphicsPipelineDesc default3D()class VulkanGraphicsPipeline : public IPipeline 10
VulkanGraphicsPipeline(VkDevice device, VkRenderPass renderPass, const GraphicsPipelineDesc& desc)~VulkanGraphicsPipeline() overrideVulkanGraphicsPipeline(const VulkanGraphicsPipeline&) = deleteVulkanGraphicsPipeline& operator=(const VulkanGraphicsPipeline&) = deleteVulkanGraphicsPipeline(VulkanGraphicsPipeline&&) = deleteVulkanGraphicsPipeline& operator=(VulkanGraphicsPipeline&&) = delete[[nodiscard]] bool isValid() const noexcept override[[nodiscard]] VkPipeline handle() const noexcept[[nodiscard]] VkPipelineLayout layout() const noexcept[[nodiscard]] const GraphicsPipelineDesc& desc() const noexceptenum AttachmentLoadOp : std::uint8_t 3
Load = 0ClearDontCareenum AttachmentStoreOp : std::uint8_t 2
Store = 0DontCareenum ImageLayout : std::uint8_t 7
Undefined = 0ColorAttachmentDepthStencilAttachmentShaderReadOnlyPresentSrcTransferSrcTransferDststruct AttachmentDesc 8
PixelFormat format = PixelFormat::RGBA8std::uint32_t sampleCount = 1AttachmentLoadOp loadOp = AttachmentLoadOp::ClearAttachmentStoreOp storeOp = AttachmentStoreOp::StoreAttachmentLoadOp stencilLoadOp = AttachmentLoadOp::DontCareAttachmentStoreOp stencilStoreOp = AttachmentStoreOp::DontCareImageLayout initialLayout = ImageLayout::UndefinedImageLayout finalLayout = ImageLayout::PresentSrcstruct AttachmentReference 2
std::uint32_t attachmentIndex = 0ImageLayout layout = ImageLayout::ColorAttachmentstruct SubpassDesc 6
std::vector<AttachmentReference> colorAttachmentsstd::vector<AttachmentReference> inputAttachmentsstd::vector<AttachmentReference> resolveAttachmentsstd::uint32_t depthStencilAttachment = UINT32_MAXImageLayout depthStencilLayout = ImageLayout::DepthStencilAttachment[[nodiscard]] bool hasDepthStencil() const noexceptstruct SubpassDependency 7
std::uint32_t srcSubpass = UINT32_MAXstd::uint32_t dstSubpass = 0std::uint32_t srcStageMask = 0std::uint32_t dstStageMask = 0std::uint32_t srcAccessMask = 0std::uint32_t dstAccessMask = 0[[nodiscard]] static SubpassDependency externalToFirst() noexceptstruct RenderPassDesc 5
std::vector<AttachmentDesc> attachmentsstd::vector<SubpassDesc> subpassesstd::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&) = deleteVulkanRenderPass& operator=(const VulkanRenderPass&) = deleteVulkanRenderPass(VulkanRenderPass&&) = deleteVulkanRenderPass& operator=(VulkanRenderPass&&) = delete[[nodiscard]] VkRenderPass handle() const noexcept[[nodiscard]] const RenderPassDesc& desc() const noexceptclass 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 overridevoid updateSize(int width, int height) noexceptclass VulkanSwapChain : public ISwapChain 7
VulkanSwapChain(int width, int height)void present() overridevoid resize(int width, int height) override[[nodiscard]] IRenderTarget* backBuffer() noexcept override[[nodiscard]] bool needsRecreation() const noexceptvoid setNeedsRecreation(bool needs) noexceptvoid recreate( VkDevice , VkPhysicalDevice , VkSurfaceKHR , int width, int height)struct TextureConfig 8
uint32_t width = 0uint32_t height = 0VkFormat format = VK_FORMAT_R8G8B8A8_UNORMVkImageUsageFlags usage = VK_IMAGE_USAGE_SAMPLED_BITVkImageAspectFlags 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&) = deleteVulkanTexture& operator=(const VulkanTexture&) = deleteVulkanTexture(VulkanTexture&& other) noexceptVulkanTexture& operator=(VulkanTexture&& other) noexceptvoid 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 noexceptclass WebGLCommandList : public ICommandList 10
void begin() overridevoid end() overridevoid setRenderTarget(IRenderTarget*) overridevoid clearRenderTarget(const sgc::Colorf& color) overridevoid setPipeline(IPipeline* pipeline) overridevoid setVertexBuffer(IBuffer* buffer) overridevoid setIndexBuffer(IBuffer* buffer) overridevoid drawIndexed(std::uint32_t indexCount, std::uint32_t startIndex, std::int32_t) overridevoid draw(std::uint32_t vertexCount, std::uint32_t startVertex) overridevoid setViewport(float width, float height) overrideclass WebGLDevice : public IDevice 21
explicit WebGLDevice(const char* canvasId = "#canvas")~WebGLDevice() overrideWebGLDevice(const WebGLDevice&) = deleteWebGLDevice& operator=(const WebGLDevice&) = deleteWebGLDevice(WebGLDevice&&) = deleteWebGLDevice& operator=(WebGLDevice&&) = delete[[nodiscard]] std::vector<std::uint8_t> readPixels( int width, int height) const override[[nodiscard]] Backend backend() const noexcept overridevoid beginFrame() overridevoid endFrame() overridevoid 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 noexceptvoid setViewport(int x, int y, int width, int height) const noexceptclass WebGLBuffer : public IBuffer 12
WebGLBuffer( BufferType bufferType, std::uint32_t sizeBytes, bool dynamic, const void* initialData)~WebGLBuffer() overrideWebGLBuffer(const WebGLBuffer&) = deleteWebGLBuffer& operator=(const WebGLBuffer&) = deleteWebGLBuffer(WebGLBuffer&&) = deleteWebGLBuffer& operator=(WebGLBuffer&&) = deletevoid 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 noexceptstruct WebGLPipelineDesc 7
WebGLShader* shader = nullptrVertexFormat vertexFormat = VertexFormat::PositionTexCoordBlendMode blendMode = BlendMode::Alphabool depthTest = truebool depthWrite = truebool cullFace = falsebool wireframe = falseclass WebGLPipeline : public IPipeline 13
explicit WebGLPipeline(const WebGLPipelineDesc& desc)~WebGLPipeline() overrideWebGLPipeline(const WebGLPipeline&) = deleteWebGLPipeline& operator=(const WebGLPipeline&) = deleteWebGLPipeline(WebGLPipeline&& other) noexceptWebGLPipeline& operator=(WebGLPipeline&& other) noexcept[[nodiscard]] bool isValid() const noexcept override[[nodiscard]] WebGLShader* shader() const noexcept[[nodiscard]] GLuint vao() const noexceptvoid bind() const noexceptstatic void unbind() noexceptconstexpr 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() overrideWebGLShader(const WebGLShader&) = deleteWebGLShader& operator=(const WebGLShader&) = deleteWebGLShader(WebGLShader&& other) noexceptWebGLShader& 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 noexceptvoid use() const noexceptenum TextureFilter 2
NearestLinearenum TextureWrap 3
RepeatClampToEdgeMirroredRepeatclass 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() overrideWebGLTexture(const WebGLTexture&) = deleteWebGLTexture& operator=(const WebGLTexture&) = deleteWebGLTexture(WebGLTexture&& other) noexceptWebGLTexture& 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 noexceptvoid bind(GLuint unit = 0) const noexceptstatic void unbind(GLuint unit = 0) noexceptvoid updateSubImage( int x, int y, int w, int h, const void* data) noexceptvoid setFilter(TextureFilter minFilter, TextureFilter magFilter) noexceptvoid setWrap(TextureWrap wrapS, TextureWrap wrapT) noexceptvoid generateMipmaps() noexceptclass WebGPUBuffer : public IBuffer 12
WebGPUBuffer( WGPUDevice device, BufferType bufferType, std::uint32_t sizeBytes, bool dynamic, const void* initialData)~WebGPUBuffer() overrideWebGPUBuffer(const WebGPUBuffer&) = deleteWebGPUBuffer& operator=(const WebGPUBuffer&) = deleteWebGPUBuffer(WebGPUBuffer&& other) noexceptWebGPUBuffer& operator=(WebGPUBuffer&& other) noexcept[[nodiscard]] std::uint32_t size() const noexcept overridevoid 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 noexceptconstexpr 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() overrideWebGPUCommandList(const WebGPUCommandList&) = deleteWebGPUCommandList& operator=(const WebGPUCommandList&) = deleteWebGPUCommandList(WebGPUCommandList&&) = deleteWebGPUCommandList& operator=(WebGPUCommandList&&) = deletevoid begin() overridevoid end() overridevoid setRenderTarget(IRenderTarget*) overridevoid clearRenderTarget(const sgc::Colorf& color) overridevoid setPipeline(IPipeline*) overridevoid setVertexBuffer(IBuffer* buffer) overridevoid setIndexBuffer(IBuffer* buffer) overridevoid drawIndexed(std::uint32_t indexCount, std::uint32_t startIndex, std::int32_t) overridevoid draw(std::uint32_t vertexCount, std::uint32_t startVertex) overridevoid setViewport(float width, float height) overridevoid beginRenderPass(WGPUTextureView textureView)void submit(WGPUQueue queue)class WebGPUDevice : public IDevice 23
explicit WebGPUDevice(const char* canvasId = "#canvas")~WebGPUDevice() overrideWebGPUDevice(const WebGPUDevice&) = deleteWebGPUDevice& operator=(const WebGPUDevice&) = deleteWebGPUDevice(WebGPUDevice&&) = deleteWebGPUDevice& operator=(WebGPUDevice&&) = deletevoid init(std::function<void(bool)> callback)[[nodiscard]] std::vector<std::uint8_t> readPixels( int width, int height) const override[[nodiscard]] Backend backend() const noexcept overridevoid beginFrame() overridevoid 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() overridevoid 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 noexceptSourced from docs/API_CATALOG.md, auto-generated by tools/generate_api_catalog.py.