Estella 0.113.0
A fast 2D and 3D game engine powered by WebAssembly and ECS
Loading...
Searching...
No Matches
DrawParams.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
25#pragma once
26
27#include "../../core/Types.hpp"
28
29#include <string>
30#include <vector>
31
32namespace esengine {
33
36inline constexpr u32 DRAW_PARAMS_BINDING = 4;
37
39inline constexpr const char* DRAW_PARAMS_BLOCK = "DrawParams";
40
50inline constexpr u32 DRAW_PARAMS_FALLBACK_SIZE = 4096;
51
53enum class DrawParamType : u8 { Float, Int, Vec2, Vec3, Vec4, Mat3, Mat4 };
54
61
64 std::vector<DrawParamSlot> slots;
66
67 bool empty() const { return blockSize == 0; }
68 const DrawParamSlot* find(const std::string& name) const;
69};
70
72void drawParamSizeAlign(DrawParamType t, u32& size, u32& align);
73
80
93DrawParamsRewrite rewriteLooseUniforms(const std::string& vertexSrc, const std::string& fragmentSrc);
94
95} // namespace esengine
Core type definitions and utilities for ESEngine.
DrawParamType
GLSL type of one lifted uniform (the subset the rewriter supports).
constexpr u32 DRAW_PARAMS_FALLBACK_SIZE
Size of the zeroed fallback UBO RenderContext binds at DRAW_PARAMS_BINDING each frame.
std::uint32_t u32
Unsigned 32-bit integer.
Definition Types.hpp:45
DrawParamsRewrite rewriteLooseUniforms(const std::string &vertexSrc, const std::string &fragmentSrc)
Lifts loose non-sampler uniform declarations out of both stages into one shared std140 DrawParams blo...
std::uint8_t u8
Unsigned 8-bit integer.
Definition Types.hpp:41
constexpr const char * DRAW_PARAMS_BLOCK
GLSL block name; must match the rewriter's generated block + Shader::compile lookup.
constexpr u32 DRAW_PARAMS_BINDING
Indexed UBO binding point for the per-draw DrawParams block. (0 = FrameConstants, 1 = MaterialConstan...
void drawParamSizeAlign(DrawParamType t, u32 &size, u32 &align)
std140 size/base-alignment of a supported param type.
One lifted uniform's slot in a shader's std140 DrawParams block.
u32 offset
std140 byte offset within the block.
A shader's DrawParams layout: lifted members + 16-aligned block size.
const DrawParamSlot * find(const std::string &name) const
u32 blockSize
0 ⇒ the shader has no DrawParams block.
std::vector< DrawParamSlot > slots
Result of rewriteLooseUniforms; layout.empty() ⇒ sources unchanged.