API Reference#
-
namespace Hush#
-
Enums
-
enum class EEditorState : uint16_t#
Values:
-
enumerator None#
-
enumerator FreeLook#
-
enumerator CommandMode#
-
enumerator JumpMode#
-
enumerator None#
-
enum class EComponentObserverType : int32_t#
Values:
-
enumerator Add#
-
enumerator Remove#
-
enumerator Set#
-
enumerator Add#
-
enum class EFileOpenMode#
Values:
-
enumerator None#
The file has not been opened yet.
-
enumerator Read#
-
enumerator Write#
-
enumerator ReadWrite#
-
enumerator None#
-
enum class EFileFlags : uint16_t#
Values:
-
enumerator Directory#
-
enumerator File#
-
enumerator Metadata#
-
enumerator Directory#
-
enum class EFileExtension : uint32_t#
Values:
-
enumerator UNKNOWN#
-
enumerator PNG#
-
enumerator META#
-
enumerator JPEG#
-
enumerator TXT#
-
enumerator PDF#
-
enumerator CSHARP#
-
enumerator CPP#
-
enumerator GLB#
-
enumerator GLTF#
-
enumerator FBX#
-
enumerator UNKNOWN#
-
enum class ELogLevel : uint32_t#
Log level.
Values:
-
enumerator Trace#
-
enumerator Debug#
-
enumerator Info#
-
enumerator Warn#
-
enumerator Error#
-
enumerator Critical#
-
enumerator Trace#
-
enum class ERenderingBackend#
Renderer type enumeration Currently, Hush uses wgpu on desktop as its backend implementation. This means that we rely on wgpu for every renderer (except Vulkan).
Values:
-
enumerator Vulkan#
Vulkan renderer.
-
enumerator D3D12#
DirectX 12 renderer.
-
enumerator Metal#
Metal renderer.
-
enumerator WebGL#
WebGL renderer.
-
enumerator WebGPU#
WebGPU renderer.
-
enumerator Vulkan#
-
enum class EAlphaBlendMode : uint32_t#
Values:
-
enumerator None#
-
enumerator OneMinusSrcAlpha#
-
enumerator OneMinusDestAlpha#
-
enumerator ConstAlpha#
-
enumerator DestAlpha#
-
enumerator SrcAlpha#
-
enumerator None#
Functions
-
std::unique_ptr<IApplication> LoadApplication(HushEngine *engine)#
Loads an application. The method to load an application depends on each platform and if shared library loading is enabled.
If HUSH_STATIC_APP definition is set to true, Hush won’t try to load an application hosted in a shared library. This only applies on platforms that support shared libraries.
If a static application is bundled with the engine, it won’t attempt to load a shared library.
- Returns:
A pointer to the loaded application.
-
void Log(ELogLevel logLevel, std::string_view message)#
Logs a message.
- Parameters:
logLevel – level to log the message
message – message to log
-
template<class ...Args>
void LogFormat(ELogLevel logLevel, fmt::format_string<Args...> format, Args&&... args)# Logs a message with a given format.
-
inline void LogTrace(std::string_view message)#
Logs a trace message.
- Parameters:
message – message to log
-
inline void LogDebug(std::string_view message)#
Logs a debug message.
- Parameters:
message – message to log
-
inline void LogInfo(std::string_view message)#
Logs an info message.
- Parameters:
message – message to log
-
inline void LogWarn(std::string_view message)#
Logs a warning message.
- Parameters:
message – message to log
-
inline void LogError(std::string_view message)#
Logs an error message.
- Parameters:
message – message to log
-
inline void LogCritical(std::string_view message)#
Logs a critical message.
- Parameters:
message – message to log
-
inline void ClearLogs()#
-
void Serialize(DirectionalLight *component)#
-
void Serialize(MeshReference *component, const char *entityName)#
-
template<BitMaskEnum Enum>
constexpr bool HasFlag(Enum value, Enum flag)# Check if an enum value has a flag.
- Template Parameters:
Enum – Enum type.
- Parameters:
value – Value to check.
flag – Flag to check.
- Returns:
True if the value has the flag, false otherwise.
-
template<BitMaskEnum Enum>
constexpr bool HasAnyFlag(Enum value, Enum flag)# Check if an enum value has any of the flags.
- Template Parameters:
Enum – Enum type.
- Parameters:
value – Value to check.
flag – Flag to check.
- Returns:
True if the value has any of the flags, false otherwise.
-
template<BitMaskEnum Enum>
constexpr bool HasAllFlags(Enum value, Enum flags)# Check if an enum value has all the flags.
- Template Parameters:
Enum – Enum type.
- Parameters:
value – Value to check.
flags – Flags to check.
- Returns:
True if the value has all the flags, false otherwise.
-
inline auto Success()#
Variables
-
template<typename Enum>
constexpr bool HAS_BIT_MASK_OPERATORS = EnableBitMaskOperators<Enum>::value# Helper variable template to check if an enum has bit mask operators.
- Template Parameters:
Enum – Enum type to check if it has bit mask operators.
-
class Camera#
Subclassed by Hush::EditorCamera
Public Functions
-
Camera() = default#
-
Camera(const glm::mat4 &projectionMat, const glm::mat4 &unreversedProjectionMat) noexcept#
-
Camera(float degFov, float width, float height, float nearP, float farP) noexcept#
-
virtual ~Camera() = default#
-
inline glm::mat4 GetProjectionMatrix() const noexcept#
-
const glm::mat4 &GetUnreversedProjectionMatrix() const noexcept#
-
void SetProjectionMatrix(glm::mat4 projection, glm::mat4 unReversedProjection)#
-
void SetPerspectiveProjectionMatrix(const float radFov, const float width, const float height, const float nearP, const float farP)#
-
float GetFarPlane() const noexcept#
-
Camera() = default#
-
class CFile : public Hush::IFile#
Public Functions
-
~CFile() override#
-
virtual Result<std::size_t> Read(std::span<std::byte> data) override#
Reads the file.
- Parameters:
data – Span to the buffer to read the data into.
- Returns:
Result with the number of bytes read.
-
virtual Result<std::span<std::byte>> Read(std::size_t size) override#
Specialized read function that reads a specific amount of bytes. This is used when reading mmaped files. This might not be supported by all implementations.
- Parameters:
size – Size to read.
- Returns:
Result with the data read.
-
virtual Result<void> Write(std::span<const std::byte> data) override#
Writes the file.
- Parameters:
data – Data to write to the file.
- Returns:
Result with the error that occurred.
-
virtual Result<void> Seek(std::size_t position) override#
Seeks to a specific position in the file.
- Parameters:
position – Position to seek to.
- Returns:
Result with the error that occurred.
-
virtual void Close() override#
Closes the file.
-
~CFile() override#
-
class CFileSystem : public Hush::IFileSystem#
- #include <CFileSystem.hpp>
Loads data using C APIs. This, however, is not efficient as it loads the whole file into memory. For more complex scenarios, look at memory mapped sources.
Public Functions
-
CFileSystem(std::string_view root)#
-
CFileSystem(const CFileSystem&) = delete#
-
inline CFileSystem(CFileSystem &&rhs) noexcept#
-
CFileSystem &operator=(const CFileSystem&) = delete#
-
inline CFileSystem &operator=(CFileSystem &&rhs) noexcept#
-
~CFileSystem() override = default#
-
virtual Result<std::unique_ptr<IFile>, IFile::EError> OpenFile(std::filesystem::path vfsPath, std::filesystem::path path, EFileOpenMode mode) override#
Opens a file from a specific path.
- Parameters:
path – Path of the file to open
mode – Mode to open the file
- Returns:
A result with a pointer to the file.
-
CFileSystem(std::string_view root)#
-
class Color#
Public Types
-
enum class EFormat : uint32_t#
Values:
-
enumerator Unknown#
-
enumerator R8Unorm#
-
enumerator RG8Unorm#
-
enumerator RGB8Unorm#
-
enumerator RGBA8Unorm#
-
enumerator R16Float#
-
enumerator RG16Float#
-
enumerator RGB16Float#
-
enumerator RGBA16Float#
-
enumerator R32Float#
-
enumerator RG32Float#
-
enumerator RGB32Float#
-
enumerator RGBA32Float#
-
enumerator D32Float#
-
enumerator D24S8Unorm#
-
enumerator Unknown#
Public Functions
-
Color() = default#
-
inline constexpr Color(float red, float green, float blue, float alpha)#
-
inline constexpr Color(float red, float green, float blue)#
-
inline constexpr Color(glm::vec3 rgb)#
-
inline constexpr Color(glm::vec4 rgba)#
-
inline constexpr const glm::vec4 &GetRGBA32F() const#
-
inline glm::vec4 &GetRGBA32F()#
-
inline constexpr uint32_t ToColor32() const#
-
inline constexpr uint32_t ToColor32RGBA() const#
-
inline constexpr uint32_t ToColor32ABGR() const#
-
enum class EFormat : uint32_t#
-
class CommandPanel : public Hush::IEditorPanel#
Public Types
-
class CommandSystem : public Hush::ISystem#
Public Functions
-
virtual void OnShutdown() override#
OnShutdown() is called when the system is shutting down.
-
virtual void OnUpdate(float delta) override#
OnRender() is called when the system should render.
- Parameters:
delta – Time since last frame
-
virtual void OnFixedUpdate(float delta) override#
OnFixedUpdate() is called when the system should update its state.
- Parameters:
delta – Time since last fixed frame
-
virtual void OnRender() override#
OnRender() is called when the system should render.
-
virtual void OnPreRender() override#
OnPreRender() is called before rendering.
-
virtual void OnPostRender() override#
OnPostRender() is called after rendering.
-
virtual void OnShutdown() override#
-
class ContentPanel : public Hush::IEditorPanel#
-
class DebugTooltip : public Hush::IEditorPanel#
Public Functions
-
virtual void OnRender(float deltaTime) noexcept override#
-
const glm::vec3 &GetScale() const#
-
const glm::vec3 &GetRotation() const#
-
const glm::vec3 &GetTranslation() const#
Public Static Attributes
-
static DebugTooltip *s_debugTooltip = nullptr#
-
virtual void OnRender(float deltaTime) noexcept override#
-
class DebugUI : public Hush::IEditorPanel#
-
class DefaultImageProvider#
Public Functions
-
inline const GpuAllocatedImage &GetWhiteImage() const#
-
inline const GpuAllocatedImage &GetBlackImage() const#
-
inline const GpuAllocatedImage &GetNormalImage() const#
-
inline const GpuAllocatedImage &GetTransparentImage() const#
-
inline const GpuAllocatedImage &GetWhiteImage() const#
-
struct DirectionalLight#
-
class DotnetHost#
- #include <DotnetHost.hpp>
hold references to all .NET function pointers with a valid initialization, to pass onto ScriptingManager
Public Functions
-
DotnetHost(const char *dotnetPath)#
Creates a new .NET host using hostfxr with the provided path of the runtime.
-
DotnetHost(const DotnetHost &other) = default#
-
DotnetHost(DotnetHost &&other) = default#
-
DotnetHost &operator=(const DotnetHost&) = default#
-
DotnetHost &operator=(DotnetHost&&) = default#
-
~DotnetHost()#
-
get_function_pointer_fn GetFunctionGetterFuncPtr()#
-
DotnetHost(const char *dotnetPath)#
-
class EditorCamera : public Hush::Camera#
Public Functions
-
EditorCamera() = default#
-
EditorCamera(float degFov, float width, float height, float nearP, float farP)#
-
glm::mat4 GetViewMatrix() const noexcept#
-
glm::mat4 GetOrientationMatrix() const noexcept#
-
const glm::vec3 &GetPosition() const noexcept#
-
glm::vec3 &GetPosition() noexcept#
-
float &GetPitch() noexcept#
-
float &GetYaw() noexcept#
-
EditorCamera() = default#
-
class EditorCameraSystem : public Hush::ISystem#
Public Functions
-
EditorCameraSystem(const EditorCameraSystem&) = delete#
-
EditorCameraSystem(EditorCameraSystem&&) = delete#
-
EditorCameraSystem &operator=(const EditorCameraSystem&) = delete#
-
EditorCameraSystem &operator=(EditorCameraSystem&&) = delete#
-
~EditorCameraSystem() override = default#
-
virtual void OnShutdown() override#
OnShutdown() is called when the system is shutting down.
-
virtual void OnUpdate(float delta) override#
OnRender() is called when the system should render.
- Parameters:
delta – Time since last frame
-
virtual void OnFixedUpdate(float delta) override#
OnFixedUpdate() is called when the system should update its state.
- Parameters:
delta – Time since last fixed frame
-
virtual void OnRender() override#
OnRender() is called when the system should render.
-
virtual void OnPreRender() override#
OnPreRender() is called before rendering.
-
virtual void OnPostRender() override#
OnPostRender() is called after rendering.
-
EditorCameraSystem(const EditorCameraSystem&) = delete#
-
struct EditorInfo#
Public Members
-
EEditorState currentState = EEditorState::None#
-
EEditorState currentState = EEditorState::None#
-
template<typename Enum>
struct EnableBitMaskOperators : public std::false_type# - #include <EnumFlags.hpp>
Trait to enable bit mask operators for an enum. To implement this trait, specialize the EnableBitMaskOperators struct for the enum. There’s a helper macro to do this in the EnumFlags.hpp file. Use HUSH_ENABLE_BITMASK_OPERATORS(Enum) However, we recommend implementing it manually to avoid macros.
-
template<>
struct EnableBitMaskOperators<ComponentTraits::EComponentOpsFlags> : public std::true_type#
-
class Entity#
- #include <Entity.hpp>
Describes an entity in the scene. An entity is something that exists in the scene. It can have components attached to it. Entities are not meant to be created directly, but through the scene.
Creating components requires the component to be registered in the scene. This is done automatically when any of the component functions are called. If the component is not registered, it will be registered in the scene.
For scripting, this class exposes
*ComponentRawfunctions that are used to interact with components using raw component ids. These functions are not meant to be used directly, and, while you can, they’re inconvenient. The*Componentfunctions are the ones that should be used.Public Types
-
using EntityId = std::uint64_t#
Public Functions
-
~Entity() noexcept = default#
Entity destructor. It does not destroy the entity. For that, use
Scene::DestroyEntity.
-
template<typename T>
inline bool HasComponent()# Checks if the entity has a component of the given type.
- Template Parameters:
T – Type of the component.
- Returns:
True if the entity has the component, false otherwise.
-
template<typename T>
inline std::remove_cvref_t<T> &AddComponent()# Add a component to the entity. If the component is already added, it will return a reference to the existing component.
- Template Parameters:
T – Type of the component.
- Returns:
Reference to the added component.
-
template<typename T, typename ...Args>
inline std::remove_cvref_t<T> &EmplaceComponent(Args&&... args)# Emplace a component to the entity. If the component is already added, it will return a reference to the existing component.
- Template Parameters:
T – Type of the component.
Args – Arguments to pass to the constructor of the component.
- Parameters:
args – Arguments to pass to the constructor of the component.
- Returns:
Reference to the added component.
-
template<typename T>
inline std::remove_cvref_t<T> *GetComponent()# Get a component from the entity.
- Template Parameters:
T – Type of the component.
- Returns:
Pointer to the component, or nullptr if the component is not found.
-
template<typename T>
inline const std::remove_cvref_t<T> *GetComponent() const# Get a component from the entity.
- Template Parameters:
T – Type of the component.
- Returns:
Pointer to the component, or nullptr if the component is not found.
-
template<typename T>
inline bool RemoveComponent()# Remove a component from the entity.
- Template Parameters:
T – Type of the component.
- Returns:
True if the component was removed, false otherwise.
-
template<typename T>
inline void RegisterComponent() const# Register a component to the entity.
- Template Parameters:
T – Type to register.
-
EntityId RegisterComponentRaw(const ComponentTraits::ComponentInfo &desc) const#
Register a component.
- Parameters:
desc – Component description.
- Returns:
Id of the component.
-
void *AddComponentRaw(EntityId componentId)#
Add a component to the entity.
- Parameters:
componentId – Id of the component.
- Returns:
Pointer to the component.
-
void *GetComponentRaw(EntityId componentId)#
Get a component from the entity.
- Parameters:
componentId – Id of the component.
- Returns:
Pointer to the component.
-
void *GetComponentRaw(EntityId componentId) const#
Get a component from the entity.
- Parameters:
componentId – Id of the component.
- Returns:
Pointer to the component.
-
bool HasComponentRaw(EntityId componentId)#
Check if the entity has a component.
- Parameters:
componentId – Id of the component.
- Returns:
True if the entity has the component, false otherwise.
-
void *EmplaceComponentRaw(EntityId componentId, size_t componentSize, bool &isNew)#
Emplace a component to the entity. If the component is already added, it will return a reference to the existing component. If the component is new, the user is in charge of constructing it. Not constructing it is undefined behavior.
- Parameters:
componentId – Id of the component.
isNew – Flag to indicate if the component is new. If it is new, user is in charge of constructing it.
componentSize – Size of the component.
- Returns:
Pointer to the component.
-
bool RemoveComponentRaw(EntityId componentId)#
Remove a component from the entity.
- Parameters:
componentId – Id of the component.
- Returns:
True if the component was removed, false otherwise.
-
Entity GetChildAt(int32_t index) const#
Gets the child at the specified index, returns an invalid entity if none is found.
- Parameters:
index – Index of the child to get
- Returns:
The child entity at the index or INVALID_ENTITY
-
int32_t GetChildCount() const#
-
inline bool IsValid() const#
Public Static Functions
Public Static Attributes
-
static constexpr size_t MAX_ENTITY_NAME_LENGTH = 32#
-
struct Name#
- #include <Entity.hpp>
Component that holds the name of an entity.
Public Members
-
std::array<char, MAX_ENTITY_NAME_LENGTH + 1> name = {}#
-
std::array<char, MAX_ENTITY_NAME_LENGTH + 1> name = {}#
-
using EntityId = std::uint64_t#
-
struct FileInfo#
- #include <IFile.hpp>
Metadata for a file.
Public Functions
-
inline bool IsCodeFile() const#
-
inline bool IsModelFile() const#
-
inline bool ShouldGenerateMetaFile() const#
Public Members
-
std::filesystem::path path#
-
std::size_t size#
-
std::uint64_t lastModified#
-
EFileOpenMode mode = EFileOpenMode::None#
-
EFileFlags flags = EFileFlags::File#
-
EFileExtension extension = EFileExtension::UNKNOWN#
-
inline bool IsCodeFile() const#
-
struct FileMetadata#
- #include <FileMetadata.hpp>
Describes the contents of a metadata file that links the resources.
Public Functions
-
template<class T>
inline Serialization::ESerializationError Serialize(T &serializer) const#
Public Static Attributes
-
static constexpr uint16_t VERSION = 1#
-
template<class T>
-
struct GeoSurface#
-
class GpuAllocatedBuffer#
Public Types
Public Functions
-
GpuAllocatedBuffer() = default#
-
GpuAllocatedBuffer(size_t size, EBufferUsage usage, EMemoryUsage memoryUsage, void *allocator)#
-
void Dispose(void *allocator)#
-
size_t GetSize() const noexcept#
-
const OpaqueAllocationData *GetAllocationData()#
-
void *GetBuffer()#
-
void *GetMappedData()#
-
GpuAllocatedBuffer() = default#
-
struct GpuAllocatedImage#
Public Members
-
ImageExtent3D imageExtent#
-
ImageExtent3D imageExtent#
-
class HierarchyPanel : public Hush::IEditorPanel#
-
class HushEngine#
Public Functions
-
HushEngine()#
Initializes the HushEngine with all its properties.
-
HushEngine(const HushEngine&) = delete#
-
HushEngine &operator=(const HushEngine&) = delete#
-
HushEngine(HushEngine&&) noexcept = delete#
-
HushEngine &operator=(HushEngine&&) noexcept = delete#
-
void AddSystem(ISystem *system)#
Intended to be used for engine systems, user-defined systems should be added using
Hush::Scene::AddSystem()
-
~HushEngine()#
-
void Quit()#
Disposes of the HushEngine.
-
inline Threading::Executors::ThreadPool *GetEngineThreadPool() noexcept#
Returns the engine’s default thread pool. The default threadpool contains a number of threads equal to the number of hardware threads available on the system, and each thread is pinned to a core.
- Returns:
A pointer to the engine’s thread pool.
-
Hush::WindowRenderer *GetWindowRenderer() noexcept#
-
VirtualFilesystem *GetVirtualFilesystem() noexcept#
-
ResourceManager *GetResourceManager() noexcept#
-
struct HushEngineInternal#
Public Members
-
Hush::VirtualFilesystem vfs#
-
Hush::ResourceManager resourceManager#
-
std::unique_ptr<Graphics::RenderGraphSystem> renderGraphSystem#
-
std::unique_ptr<Hush::Renderer::ResourceUploadSystem> resourceUploadSystem#
-
std::unique_ptr<WindowRenderer> windowRenderer = nullptr#
-
Hush::VirtualFilesystem vfs#
-
HushEngine()#
-
class IApplication#
Subclassed by EditorApp
Public Functions
-
IApplication() = default#
-
IApplication(const IApplication&) = delete#
-
IApplication(IApplication&&) = delete#
-
IApplication &operator=(const IApplication&) = default#
-
IApplication &operator=(IApplication&&) = default#
-
virtual ~IApplication() = default#
-
virtual void Init() = 0#
-
virtual void Update(float delta) = 0#
-
virtual void FixedUpdate(float delta) = 0#
-
virtual void OnPreRender() = 0#
-
virtual void OnRender(float delta) = 0#
-
virtual void OnPostRender() = 0#
-
virtual void DisposeFrame() = 0#
-
virtual std::string_view GetAppName() const noexcept = 0#
-
IApplication() = default#
-
class IEditorPanel#
Subclassed by Hush::CommandPanel, Hush::ContentPanel, Hush::DebugTooltip, Hush::DebugUI, Hush::HierarchyPanel, Hush::InspectorPanel, Hush::NotificationPanel, Hush::ScenePanel, Hush::StatsPanel, Hush::TitleBarMenuPanel
Public Functions
-
IEditorPanel() noexcept = default#
-
IEditorPanel(const IEditorPanel &other) = default#
-
IEditorPanel(IEditorPanel &&other) = default#
-
IEditorPanel &operator=(const IEditorPanel&) = default#
-
IEditorPanel &operator=(IEditorPanel&&) = default#
-
virtual ~IEditorPanel() = default#
-
virtual void OnRender(float deltaTime) = 0#
-
IEditorPanel() noexcept = default#
-
class IFile#
- #include <IFile.hpp>
File interface for the VFS. A file is a resource that maps to a specific path in the VFS. Files support reading, writing, and reading metadata. Not all the VFS implementations will support all the operations, and, in those cases, the implementation will return a “OperationNotSupported” error. TODO: async interfaces.
Subclassed by Hush::CFile
Public Types
Public Functions
-
IFile() = default#
-
virtual ~IFile() = default#
-
virtual Result<void> Write(std::span<const std::byte> data) = 0#
Writes the file.
- Parameters:
data – Data to write to the file.
- Returns:
Result with the error that occurred.
-
virtual Result<std::size_t> Read(std::span<std::byte> data) = 0#
Reads the file.
- Parameters:
data – Span to the buffer to read the data into.
- Returns:
Result with the number of bytes read.
-
virtual Result<std::span<std::byte>> Read(std::size_t size) = 0#
Specialized read function that reads a specific amount of bytes. This is used when reading mmaped files. This might not be supported by all implementations.
- Parameters:
size – Size to read.
- Returns:
Result with the data read.
-
virtual Result<void> Seek(std::size_t position) = 0#
Seeks to a specific position in the file.
- Parameters:
position – Position to seek to.
- Returns:
Result with the error that occurred.
-
virtual void Close() = 0#
Closes the file.
-
IFile() = default#
-
class IFileSystem#
- #include <FileSystem.hpp>
A resource loader is an interface meant to be implemented by classes that load things from a specific source (i.e. a ZIP file). This means that they must implement a way to load resources from an underlying sources, both in an async and a sync way. Some resource sources do not support a Resource sources must live until all of their children are deleted.
Subclassed by Hush::CFileSystem
Public Types
Public Functions
-
IFileSystem() = default#
-
IFileSystem(const IFileSystem&) = delete#
-
IFileSystem(IFileSystem&&) = default#
-
IFileSystem &operator=(const IFileSystem&) = delete#
-
IFileSystem &operator=(IFileSystem&&) = default#
-
virtual ~IFileSystem() = default#
-
virtual Result<std::unique_ptr<IFile>, IFile::EError> OpenFile(std::filesystem::path vfsPath, std::filesystem::path path, EFileOpenMode mode = EFileOpenMode::Read) = 0#
Opens a file from a specific path.
- Parameters:
path – Path of the file to open
mode – Mode to open the file
- Returns:
A result with a pointer to the file.
-
virtual Result<std::vector<FileInfo>, IFile::EError> ListPath(const std::string_view &path) = 0#
Lists all the contents of a specific path.
-
inline EFileExtension ToKnownExtension(const std::string_view &extensionUppercase)#
-
IFileSystem() = default#
-
struct Image#
- #include <Image.hpp>
ECS component that manages an image resource.
An image is a CPU-side resource that holds raw pixel data and metadata (dimensions, format). It is used as an intermediate representation when loading textures from disk or other sources.
See TextureComponent for the GPU-side texture resource that is created from an Image.
Public Types
Public Functions
-
Image() = default#
-
inline explicit Image(std::vector<std::byte> rawData, uint32_t width, uint32_t height, uint32_t depth, Graphics::ETextureFormat format)#
-
~Image() = default#
-
inline std::span<const std::byte> GetTextureData() const#
-
inline uint32_t GetWidth() const#
-
inline uint32_t GetHeight() const#
-
inline uint32_t GetDepth() const#
-
inline Graphics::ETextureFormat GetFormat() const#
-
Image() = default#
-
struct ImageExtent3D#
-
class ImageTexture#
-
class IMaterial3D#
- #include <IMaterial3D.hpp>
Abstract interface for all material types in the engine.
This is the base class that the mesh system (GeoSurface) stores via std::shared_ptr<IMaterial3D>. Concrete implementations include:
ShaderMaterial (legacy Vulkan-specific, SPIR-V reflection based)
Graphics::Material3D (new RHI-agnostic, Slang/ShaderCompiler based)
GLTFMetallicRoughness (PBR material loaded from glTF assets)
Subclassed by Hush::ShaderMaterial
Public Functions
-
IMaterial3D() = default#
-
virtual ~IMaterial3D() = default#
-
IMaterial3D(const IMaterial3D&) = default#
-
IMaterial3D &operator=(const IMaterial3D&) = default#
-
IMaterial3D(IMaterial3D&&) = default#
-
IMaterial3D &operator=(IMaterial3D&&) = default#
-
virtual EAlphaBlendMode GetAlphaBlendMode() const noexcept = 0#
-
virtual void SetAlphaBlendMode(EAlphaBlendMode blendMode) noexcept = 0#
-
virtual EMaterialPass GetMaterialPass() const noexcept = 0#
-
virtual void SetMaterialPass(EMaterialPass pass) = 0#
-
virtual Graphics::GraphicsApiMaterialInstance *GetInternalMaterial() = 0#
Returns the low-level, graphics-API-specific material instance that holds the pipeline and bind group (or descriptor set) pointers needed for rendering.
Implementations that do not use the RHI MaterialInstance path may return nullptr.
-
virtual void SetName(const std::string_view &name) = 0#
-
virtual const std::string &GetName() const noexcept = 0#
-
class IModelLoader#
Subclassed by Hush::VulkanLoader
Public Types
Public Functions
-
IModelLoader(const IModelLoader&) = default#
-
IModelLoader(IModelLoader&&) = default#
-
IModelLoader &operator=(const IModelLoader&) = default#
-
IModelLoader &operator=(IModelLoader&&) = default#
-
virtual ~IModelLoader() = default#
-
IModelLoader() = default#
-
virtual void SetResourceManager(ResourceManager *resourceManager) = 0#
-
virtual ResourceManager *GetResourceManager() const = 0#
-
virtual Result<std::vector<Entity>, EError> LoadMeshes(IRenderer *engine, const std::filesystem::path &filePath, Scene *activeScene) = 0#
-
virtual GpuAllocatedImage LoadTexture(IRenderer *engine, const ImageTexture &texture) = 0#
-
IModelLoader(const IModelLoader&) = default#
-
class InputManager#
Public Static Functions
-
static bool IsKeyDown(EKeyCode key)#
Evaluates to true whilst the key is pressed down.
-
static bool IsKeyDownThisFrame(EKeyCode key)#
Evaluates to true the frame the key is identified as EKeyState::Pressed.
-
static bool IsKeyUp(EKeyCode key)#
Evaluates to true the frame the key is identified as EKeyState::Release.
-
static bool IsKeyHeld(EKeyCode key)#
Evaluates to true as long as the key is identified asEKeyState::Held.
-
static bool GetMouseButtonPressed(EMouseButton button)#
Evaluates to true for as long as the mouse button is pressed.
-
static bool FetchCharThisFrame(char *outChar)#
-
static glm::vec2 GetMousePosition()#
Gets the vector of the mouse’s position in pixels.
-
static glm::vec2 GetMouseAcceleration()#
Gets the vector of the mouse’s acceleration in pixels/s^2.
-
static const glm::vec2 &GetMouseScrollAcceleration()#
-
static void SendKeyEvent(KeyCode key, EKeyState state)#
-
static void SendMouseButtonEvent(MouseButton mouseButton, EKeyState state)#
-
static void SendMouseMovementEvent(int32_t posX, int32_t posY, int32_t accelerationX, int32_t accelerationY)#
-
static void SendWheelEvent(float posX, float posY)#
-
static void ResetMouseAcceleration()#
-
static void ResetCharData()#
-
static void SendCharEvent(char pressedChar)#
-
static void SetCursorLock(ECursorLockMode lockMode)#
-
static bool IsKeyDown(EKeyCode key)#
-
class InspectorPanel : public Hush::IEditorPanel#
-
class IRenderer#
- #include <Renderer.hpp>
A common interface for renderers, Hush supports many graphics APIs, and this is the interface that allows us to standardize all of them… All renderers MUST bind to SDL and ImGUI, the latter can be done through the IImGuiForwarder interface.
Public Functions
-
inline IRenderer(void *windowContext, ERenderingBackend type)#
-
virtual ~IRenderer() = default#
-
virtual void CreateSwapChain(uint32_t width, uint32_t height) = 0#
-
virtual void InitImGui() = 0#
-
virtual void ClearDrawContext() = 0#
Must be called before every new frame to clear out all the stale mesh and transform data (this is the responsibility of the RenderingSystem)
-
virtual void PushMesh(const WorldTransform *xform, const Mesh *mesh) = 0#
-
virtual void DestroyMesh(const std::string_view &name) = 0#
-
virtual void Draw(float delta) = 0#
-
virtual void UpdateSceneObjects(float delta) = 0#
Each renderer will have to implement a way of updating all the objects inside of the scene, these are instances of the IRenderableNode, which is a common interface for all renderers, but additional render data (i.e drawContext) might be needed by their underlying implementation (see VulkanMeshNode for an example)
-
virtual void InitRendering() = 0#
Initializes all the internal structures needed to begin rendering, call after a swapchain has been created!
-
virtual void NewUIFrame() const noexcept = 0#
-
virtual void EndUIFrame() const noexcept = 0#
-
virtual void HandleEvent(const SDL_Event *event) noexcept = 0#
-
virtual GpuAllocatedImage CreateImage(const void *data, const ImageExtent3D &size, Color::EFormat format, uint32_t usage, bool mipmapped = false) = 0#
-
virtual void DestroyImage(GpuAllocatedImage *image) = 0#
-
virtual void AddToDeletionQueue(std::function<void()> &&deleteFunc) = 0#
-
virtual const DefaultImageProvider *GetDefaultImageProvider() const noexcept = 0#
-
virtual void *GetWindowContext() const noexcept = 0#
-
virtual const EditorCamera &GetEditorCamera() const noexcept = 0#
-
virtual EditorCamera *GetEditorCamera() noexcept = 0#
-
inline IRenderer(void *windowContext, ERenderingBackend type)#
-
class IResourceManager#
Subclassed by Hush::ResourceManager
Public Functions
-
IResourceManager() = default#
-
IResourceManager(const IResourceManager&) = default#
-
IResourceManager(IResourceManager&&) = default#
-
IResourceManager &operator=(const IResourceManager&) = default#
-
IResourceManager &operator=(IResourceManager&&) = delete#
-
virtual ~IResourceManager() = default#
-
virtual RefCounted *IncreaseRefCount(const HandleId &handle) = 0#
-
virtual RefCounted *DecreaseRefCount(const HandleId &handle) = 0#
-
virtual const RefCounted &GetRefCount(const HandleId &handle) = 0#
-
virtual void FreePending() = 0#
-
IResourceManager() = default#
-
class ISystem#
- #include <ISystem.hpp>
ISystem is the base interface for all systems in the engine It implements helper functions that all systems should implement.
The lifecycle of a system is as follows:
Constructor: Called when the system is created, could be used for some early initialization
Init: Called when the system is initialized, at this point all the systems are created.
OnUpdate: Called every frame, this is where the system should update its state.
OnFixedUpdate: Called every fixed frame, this is where the system should update its state. Usually helpful for physics.
OnShutdown: Called when the system is shutting down, could be used for some cleanup.
OnRender: Called when the system should render, could be used for rendering.
Destructor: Called when the system is destroyed, could be used for some cleanup.
Hooks are provided for all the lifecycle events, so the system can implement them as needed.
Systems provide a member function called
Orderthat should return the order in which the system should be updated. The game engine will sort the systems based on this value. Every time a new system is added, the engine will sort the systems based on this value. The engine provides 255 order slots, so the system can return any value between 0 and 255. Systems that belong to the same order will be updated concurrently.The systems will be bucketed BEFORE init is called, so the order of the systems should be set in the constructor.
Subclassed by Hush::CommandSystem, Hush::EditorCameraSystem, Hush::Graphics::RenderGraphSystem, Hush::Renderer::ResourceUploadSystem, Hush::RenderingSystem, Hush::TransformationSystem
Public Functions
-
virtual ~ISystem() = default#
-
virtual void OnShutdown() = 0#
OnShutdown() is called when the system is shutting down.
-
virtual void OnUpdate(float delta) = 0#
OnRender() is called when the system should render.
- Parameters:
delta – Time since last frame
-
virtual void OnFixedUpdate(float delta) = 0#
OnFixedUpdate() is called when the system should update its state.
- Parameters:
delta – Time since last fixed frame
-
virtual void OnRender() = 0#
OnRender() is called when the system should render.
-
virtual void OnPreRender() = 0#
OnPreRender() is called before rendering.
-
virtual void OnPostRender() = 0#
OnPostRender() is called after rendering.
-
inline std::uint16_t Order() const#
Order() is used to get the order in which the system should be updated
- Returns:
Order in which the system should be updated
Public Static Attributes
-
static constexpr std::uint16_t MAX_ORDER = 255#
-
struct LocalTransform : public Hush::Transform#
Public Functions
-
Transform() = default#
-
Transform(const glm::vec3 &position, const glm::vec3 &scale = Vector3Math::ONE, const glm::quat &rotation = {})#
-
Transform() = default#
-
class Mesh#
- #include <Mesh.hpp>
Simple CPU representation of a mesh “component”, holds index and vertex buffers, as well as the RenderingAPI specific buffer data.
Public Functions
-
inline std::vector<uint32_t> &GetIndexBuffer()#
-
void CalculateTangentBasis()#
-
inline const std::vector<GeoSurface> &GetSurfaces() const#
-
inline void AddSurface(GeoSurface &&surface)#
-
inline void SetName(const std::string_view &name)#
-
inline const std::string &GetName() const#
-
inline void SetMeshBuffers(GPUMeshBuffers buffers)#
-
inline GPUMeshBuffers &GetMeshBuffers()#
-
inline const GPUMeshBuffers &GetMeshBuffers() const#
-
void CalculateNormals()#
-
struct Vertex#
-
inline std::vector<uint32_t> &GetIndexBuffer()#
-
class MeshReference#
- #include <MeshReference.hpp>
Small wrapper around the
Meshdata structure, internally, this is useful for caching using our reference counting system.Public Functions
-
inline Graphics::IGraphicsBuffer *GetGpuVertexBuffer() const#
Get the GPU vertex buffer for this mesh (may be nullptr before upload).
-
inline void SetGpuVertexBuffer(std::unique_ptr<Graphics::IGraphicsBuffer> buffer)#
Set the GPU vertex buffer. Called by ResourceUploadSystem after staging.
-
inline Graphics::IGraphicsBuffer *GetGpuIndexBuffer() const#
Get the GPU index buffer for this mesh (may be nullptr before upload).
-
inline void SetGpuIndexBuffer(std::unique_ptr<Graphics::IGraphicsBuffer> buffer)#
Set the GPU index buffer. Called by ResourceUploadSystem after staging.
-
inline Graphics::IGraphicsBuffer *GetGpuVertexBuffer() const#
-
struct MouseData#
-
class NotificationPanel : public Hush::IEditorPanel#
-
template<typename ...Components>
class Query : public Hush::impl::QueryImpl# - #include <Query.hpp>
Query for entities. This wraps the raw query and allows getting components in a type-safe way.
It allows iterating using two methods:
Accessing directly to the component arrays, to do this, use the
beginandendfunctions. This also can be iterated using range-based for loops.Using the
Eachfunction, which allows applying a function to each entity in the query. This is a simple way of iterating over the entities.
Example using the first method:
Query<Position, Velocity> query = scene.CreateQuery<Position, Velocity>(); auto it = query.begin(); for (; it != query.end(); ++it) { auto [positions, velocities] = *it; for (auto position : positions) { // Do something with the position } for (auto velocity : velocities) { // Do something with the velocity } // Or for (std::size_t i = 0; i < it.Size(); ++i) { Position& position = positions[i]; Velocity& velocity = velocities[i]; Hush::Entity entity = it.GetEntity(i); } }
Example using the second method:
Query<Position, Velocity> query = scene.CreateQuery<Position, Velocity>(); query.Each([](Position &position, Velocity &velocity) { }); query.Each([](Entity::EntityId entityId, Position &position, Velocity &velocity) { }); query.Each([](Hush::Entity &entity, Position &position, Velocity &velocity) { });
- Template Parameters:
Components – Components to query.
Public Types
-
using ECacheMode = RawQuery::ECacheMode#
-
using ComponentTuple = std::tuple<std::span<std::remove_reference_t<Components>>...>#
-
using ConstComponentTuple = std::tuple<std::span<std::add_const_t<std::remove_reference_t<Components>>>...>#
Public Functions
-
Query() = default#
-
inline QueryIterator begin()#
Get an iterator to iterate over the entities in the query.
- Returns:
Iterator to iterate over the entities in the query.
-
inline SentinelQueryIterator end()#
Get the sentinel iterator. This is used to check if the iterator is finished.
- Returns:
-
inline QueryIterator begin() const#
Const version of the begin function.
- Returns:
Const query iterator
-
inline SentinelQueryIterator end() const#
Const version of the end function.
- Returns:
-
template<typename Func>
inline void Each(Func &&func)# Apply a function to each entity in the query. This version of the function will only pass the components as arguments. Order is as the query was created.
- Template Parameters:
Func – Function type.
- Parameters:
func – Function to apply to each entity.
-
template<typename Func>
inline void Each(Func &&func) Apply a function to each entity in the query. This version of the function also provides the entity id as the first argument.
- Template Parameters:
Func – Function type.
- Parameters:
func – Function to apply to each entity.
-
template<typename Func>
inline void Each(Func &&func) Apply a function to each entity in the query. This version of the function will pass the entity as the first argument.
- Template Parameters:
Func – Function type.
- Parameters:
func – Function to apply to each entity.
-
struct QueryIterator#
- #include <Query.hpp>
Query iterator. This allows using for-range loops to iterate over the array of components.
Public Functions
-
inline QueryIterator(RawQuery::QueryIterator iter)#
-
QueryIterator(const QueryIterator&) = delete#
-
QueryIterator &operator=(const QueryIterator&) = delete#
-
inline QueryIterator(QueryIterator &&rhs) noexcept#
-
inline QueryIterator &operator=(QueryIterator &&rhs) noexcept#
-
~QueryIterator() = default#
-
inline QueryIterator &operator++()#
Move to the next table.
- Returns:
self
-
inline ComponentTuple operator*()#
Get the next table of components. For instance, for a Query<Position, Velocity>, this will return a std::tuple<std::span<Position>, std::span<Velocity>>.
- Returns:
A std::tuple of spans of the components.
-
inline ConstComponentTuple operator*() const#
Get the next table of components. For instance, for a const Query<Position, Velocity>, this will return a std::tuple<std::span<const
Position>, std::span<const Velocity>>.
- Returns:
A std::tuple of spans of the components.
-
inline bool operator==(const SentinelQueryIterator&) const#
Returns true if the iterator is finished.
- Returns:
True if the iterator is finished, false otherwise.
-
inline bool operator!=(const SentinelQueryIterator&) const#
Returns true if the iterator is not finished.
- Returns:
True if the iterator is not finished, false otherwise.
-
inline RawQuery::QueryIterator &GetRawIterator()#
Get the underlying raw iterator.
Note: Advancing the raw iterator will also advance this iterator.
- Returns:
The raw iterator.
-
inline std::size_t Size() const#
Get the number of entities in the current table.
- Returns:
The number of entities in the current table.
-
inline QueryIterator(RawQuery::QueryIterator iter)#
-
struct SentinelQueryIterator#
- #include <Query.hpp>
This is a sentinel iterator that is used to signal the end of the query.
-
template<typename ...Components>
class QueryBuilder# Public Functions
-
inline QueryBuilder &WithRelationship(const Entity &relationship)#
Adds a relationship filter to the query.
Matched entities will be related to any other entity by the specified relationship paramter, using this function is equivalent to WithRelationship(relationship, EcsTerms::WILDCARD)
- Parameters:
relationship – Relationship to filter entities by
-
inline QueryBuilder &WithRelationship(const Entity &relationship, const Entity &target)#
-
inline Query<Components...> Build()#
-
inline QueryBuilder &WithRelationship(const Entity &relationship)#
-
class RawQuery#
- #include <Query.hpp>
Low-level query for entities. This allows getting raw void pointers to components. To iterate, this class provides a Hush::RawQuery::GetIterator function that returns an iterator. For more information about the iterator, see QueryIterator.
Public Types
Public Functions
-
RawQuery(Scene *scene, void *query)#
For internals only, this function is not intended to be used outside of the Scene and QueryBuilder classes.
-
RawQuery() = default#
-
RawQuery &operator=(RawQuery &&rhs) noexcept#
Move assignment operator.
- Parameters:
rhs – Other query to move from.
- Returns:
self
-
~RawQuery() noexcept#
-
Scene *GetScene() const noexcept#
Get the scene where the query is running.
- Returns:
Scene where the query is running.
-
QueryIterator GetIterator()#
Get an iterator to iterate over the entities in the query.
- Returns:
Iterator to iterate over the entities in the query.
Public Static Attributes
-
static constexpr std::uint32_t MAX_COMPONENTS = 32#
-
struct QueryIterator#
- #include <Query.hpp>
Raw query iterator. This allows iterating over the entities in the query.
This iterator works by giving direct access to the arrays of components in the query. So, this doesn’t give an array of |Component1, Component2, …|, but instead gives n arrays of |Component1, Component1, …|, |Component2, Component2, …|, etc. Keep this in mind when using this iterator.
For end-users (not scripting), it is recommended to use the Hush::Query class instead.
Public Functions
-
QueryIterator(const QueryIterator&) = delete#
-
QueryIterator &operator=(const QueryIterator&) = delete#
-
QueryIterator(QueryIterator &&rhs) noexcept#
-
QueryIterator &operator=(QueryIterator &&rhs) noexcept#
-
~QueryIterator()#
-
bool Next()#
Move to the next entity.
- Returns:
True if there is a next entity, false otherwise.
-
void Skip()#
Skip the current entity.
-
bool Finished() const#
Check if the iterator has been finished.
- Returns:
True if the iterator has been finished. False otherwise.
-
std::size_t Size() const#
Gives the number of entities in the current table. This number is updated when using Next.
- Returns:
The number of entities in the query.
-
void *GetComponentAt(std::int8_t index, std::size_t size) const#
Get an array of components at the given index. Index is given by the order of the components in the query. For instance, if the query was creating with a list of components [Position, Velocity], then Position would be at index 0 and Velocity at index 1.
The length of the array is given by Size.
- Parameters:
index – Index of the component.
size – Size of the component.
- Returns:
Pointer to the component.
-
std::uint64_t GetEntityAt(std::size_t index) const#
Get the entity id at the given index.
-
QueryIterator(const QueryIterator&) = delete#
-
RawQuery(Scene *scene, void *query)#
-
template<class T>
class Ref#
-
struct RefCounted#
-
class RenderingSystem : public Hush::ISystem#
Public Functions
-
virtual void OnShutdown() override#
OnShutdown() is called when the system is shutting down.
-
virtual void OnUpdate(float delta) override#
OnRender() is called when the system should render.
- Parameters:
delta – Time since last frame
-
virtual void OnFixedUpdate(float delta) override#
OnFixedUpdate() is called when the system should update its state.
- Parameters:
delta – Time since last fixed frame
-
virtual void OnRender() override#
OnRender() is called when the system should render.
-
virtual void OnPreRender() override#
OnPreRender() is called before rendering.
-
virtual void OnPostRender() override#
OnPostRender() is called after rendering.
-
virtual void OnShutdown() override#
-
class ResourceManager : public Hush::IResourceManager#
Public Types
Public Functions
-
ResourceManager() = default#
-
ResourceManager(const ResourceManager&) = delete#
-
inline ResourceManager(ResourceManager &&other) noexcept#
-
ResourceManager &operator=(const ResourceManager&) = delete#
-
ResourceManager &operator=(ResourceManager&&) = delete#
-
void Init(VirtualFilesystem *filesystem)#
-
virtual RefCounted *IncreaseRefCount(const HandleId &handle) override#
-
virtual RefCounted *DecreaseRefCount(const HandleId &handle) override#
-
virtual const RefCounted &GetRefCount(const HandleId &handle) override#
-
Result<Ref<TextureComponent>, EError> LoadTexture(std::string_view path, TextureComponent::ECpuUnloadStrategy unloadStrategy = TextureComponent::ECpuUnloadStrategy::UnloadAfterUpload)#
Loads a texture from the given path. The path is relative to the virtual filesystem root.
If the texture has already been loaded, returns a reference to the existing texture. Otherwise, loads the texture from the filesystem, stores it in the resource manager, and returns a reference to the new texture.
The Ref<TextureComponent> returned by this function does not have the texture data uploaded to the GPU yet. To do the actual GPU upload, the ResourceUploadSystem must be run, which will process all pending texture uploads and create the corresponding GPU resources. Until then, the TextureComponent will hold a pointer to a “placeholder”. This allows the caller to reference the texture immediately after loading, even if the GPU upload is deferred to a later stage.
You can check if the texture has been uploaded to the GPU by checking if the TextureComponent’s IsLoaded() method returns true.
As part of this member function, another Ref<> will be created, but it will store the
- Parameters:
path – The path to the texture file, relative to the virtual filesystem root.
- Returns:
A reference to the loaded texture, or an error if the texture could not be loaded.
-
Result<Ref<TextureComponent>, EError> LoadTextureFromData(std::string_view name, std::span<const std::byte> data)#
Loads a texture from the given raw data.
If a texture with the same name has already been loaded, returns a reference to the existing texture. Otherwise, creates a new texture from the raw data, stores it in the resource manager, and returns a reference to the new texture.
- Parameters:
name – The unique name for the texture. This is used to identify the texture in the resource manager.
data – The raw texture data. It is expected to be in a format that the graphics device can consume directly (e.g. RGBA8 pixel data). The resource manager does not perform any decoding or format conversion on the data.
- Returns:
A reference to the loaded texture, or an error if the texture could not be created.
-
virtual void FreePending() override#
-
ResourceManager() = default#
-
class Scene#
Public Functions
-
Scene(HushEngine *engine, Hush::Threading::Executors::ThreadPool *threadPool)#
Constructor.
- Parameters:
engine – Game engine
-
~Scene()#
-
void Init()#
Init is called when the scene is initialized.
-
void Update(float delta)#
Update is called every frame.
-
void FixedUpdate(float delta)#
FixedUpdate is called every fixed frame.
-
void PreRender()#
PreRender is called before rendering.
-
void Render()#
Render is called when the scene should render.
-
void PostRender()#
PostRender is called after rendering.
-
void Shutdown()#
Shutdown is called when the scene is shutting down.
-
template<typename S>
inline void AddSystem()# - Template Parameters:
S – Add a system to the scene
-
void RemoveSystem(std::string_view name)#
Remove a system from the scene by name.
- Parameters:
name – Name of the system to remove.
-
Entity CreateEntityWithName(std::string_view name)#
Creates an entity with a name
- Parameters:
name – Unique name of the entity
- Returns:
-
template<class T, class Func>
inline void AddComponentObserver(EComponentObserverType observerType, Func &&callback)# Registers a callback that gets called whenever a component receives the specified event.
-
std::optional<std::uint64_t> GetRegisteredComponentId(std::string_view name)#
Get the component registered id by name
- Parameters:
name – Component name
- Returns:
The component id if it exists, std::nullopt otherwise
-
void RegisterComponentId(std::string_view name, Entity::EntityId id)#
Register a component id
- Parameters:
name – Name of the component
id – Id of the component
-
EntityId RegisterComponentRaw(const ComponentTraits::ComponentInfo &desc) const#
-
template<typename ...Components>
inline Query<Components...> CreateQuery(RawQuery::ECacheMode cacheMode = RawQuery::ECacheMode::Default)#
-
template<typename ...Components>
inline QueryBuilder<Components...> CreateQueryBuilder(RawQuery::ECacheMode cacheMode = RawQuery::ECacheMode::Default)#
-
void AddEngineSystem(ISystem *system)#
Add an engine system to the scene
- Parameters:
system – System to add
-
RawQuery CreateRawQuery(std::span<Entity::EntityId> components, RawQuery::ECacheMode cacheMode = RawQuery::ECacheMode::Default)#
Friends
- friend class impl::QueryImpl
-
Scene(HushEngine *engine, Hush::Threading::Executors::ThreadPool *threadPool)#
-
class ScenePanel : public Hush::IEditorPanel#
-
class ScriptingManager#
- #include <ScriptingManager.hpp>
Class for bridging with .NET using hostfxr.
Public Functions
Creates a new scripting manager to invoke C# methods.
- Parameters:
host – The host connected to the C# runtime
m_targetAssembly – The desired assembly this manager is going to invoke methods from, THIS SHOULD BE CONSTANT WHEN POSSIBLE
-
struct ShaderBindings#
Public Types
-
enum class EBindingType#
Values:
-
enumerator Unknown#
-
enumerator PushConstant#
-
enumerator InputVariable#
-
enumerator UniformBuffer#
-
enumerator StorageBuffer#
-
enumerator Sampler#
-
enumerator Texture#
-
enumerator CombinedImageSampler#
-
enumerator StorageImage#
-
enumerator UniformTexelBuffer#
-
enumerator StorageTexelBuffer#
-
enumerator UniformBufferDynamic#
-
enumerator StorageBufferDynamic#
-
enumerator InputAttachment#
-
enumerator InlineUniformBlock#
-
enumerator AccelerationStructure#
-
enumerator UniformBufferMember#
-
enumerator Unknown#
Public Members
-
uint32_t bindingIndex = {}#
-
uint32_t size = {}#
-
uint32_t offset = {}#
-
uint32_t stageFlags = {}#
-
uint32_t setIndex = {}#
-
EBindingType type = EBindingType::Unknown#
-
enum class EBindingType#
-
class ShaderMaterial : public Hush::IMaterial3D#
- #include <ShaderMaterial.hpp>
Represents a material created by a custom shader with dynamic mappings and reflections The performance impact of this class is considerable since it needs to keep track of the bindings in both RAM and GPU, as well as process the shader initially with Reflection (initialization cost) This class’s interface is Rendering API agnostic.
Public Types
Public Functions
-
ShaderMaterial() = default#
-
~ShaderMaterial()#
-
EError LoadShaders(IRenderer *renderer, const std::filesystem::path &fragmentShaderPath, const std::filesystem::path &vertexShaderPath)#
Will create and bind pipelines for both shaders.
-
void GenerateMaterialInstance(OpaqueDescriptorAllocator *descriptorAllocator)#
-
OpaqueMaterialData *GetMaterialData()#
-
virtual EAlphaBlendMode GetAlphaBlendMode() const noexcept override#
-
virtual void SetAlphaBlendMode(EAlphaBlendMode blendMode) noexcept override#
-
virtual EMaterialPass GetMaterialPass() const noexcept override#
-
virtual void SetMaterialPass(EMaterialPass pass) override#
-
inline virtual void SetName(const std::string_view &name) override#
-
inline virtual const std::string &GetName() const noexcept override#
-
virtual GraphicsApiMaterialInstance *GetInternalMaterial() override#
Returns the low-level, graphics-API-specific material instance that holds the pipeline and bind group (or descriptor set) pointers needed for rendering.
Implementations that do not use the RHI MaterialInstance path may return nullptr.
-
ShaderMaterial() = default#
Public Types
SharedLibrary error.
Values:
Public Functions
Gets a pointer to a symbol. This call does not check if the pointer is null.
- Template Parameters:
T – Type of the symbol
- Parameters:
symbolName – Name of the symbol
- Returns:
A pointer to the symbol
Gets a pointer to a symbol.
- Template Parameters:
T – Type of the symbol
- Parameters:
symbolName – Name of the symbol
- Returns:
A result with the symbol, or an error if it can’t be found
Public Static Functions
Opens a shared library and returns a handle to it.
- Parameters:
libraryName – Shared Library name.
- Returns:
A handle to the shared library
-
class StatsPanel : public Hush::IEditorPanel#
-
struct TextureComponent#
- #include <TextureComponent.hpp>
ECS component intended to be used by entities.
This component owns the GPU and CPU resources for a texture. It is designed to be attached to entities that need to reference a texture resource, such as materials or renderable objects.
Public Types
-
enum class ECpuUnloadStrategy : uint8_t#
Values:
-
enumerator UnloadAfterUpload#
Unload the CPU image after uploading it to the GPU. This is the default strategy, as it minimizes memory usage by keeping only the GPU texture resident after upload. However, it means that the CPU image will not be available for readback or re-upload without reloading from disk.
-
enumerator KeepResident#
Keep the CPU image resident in memory even after uploading to the GPU. This allows for readback or re-upload without needing to reload from disk, but increases memory usage by keeping both the CPU image and GPU texture resident.
-
enumerator UnloadAfterUpload#
Public Functions
-
TextureComponent() = default#
-
inline explicit TextureComponent(std::unique_ptr<Graphics::IGraphicsTexture> texture, std::unique_ptr<Image> cpuImage, ECpuUnloadStrategy cpuUnloadStrategy = ECpuUnloadStrategy::UnloadAfterUpload)#
-
TextureComponent(const TextureComponent&) = delete#
-
TextureComponent &operator=(const TextureComponent&) = delete#
-
TextureComponent(TextureComponent&&) = default#
-
TextureComponent &operator=(TextureComponent&&) = default#
-
~TextureComponent() = default#
-
inline Graphics::IGraphicsTexture *GetTexture() const#
-
inline uint32_t GetWidth() const#
-
inline uint32_t GetHeight() const#
-
inline uint32_t GetDepth() const#
-
inline Graphics::ETextureFormat GetFormat() const#
-
inline bool IsValid() const#
-
inline Graphics::IGraphicsTexture *GetGpuTexture() const#
-
inline bool IsCpuImageValid() const#
-
inline void SetGpuTexture(std::unique_ptr<Graphics::IGraphicsTexture> texture)#
Set a new GPU texture for this component. This replaces the existing GPU texture, if any.
It is not encouraged to call this method directly from user code. Instead, the GPU texture should be set by the ResourceUploadSystem
-
inline ECpuUnloadStrategy GetCpuUnloadStrategy() const#
Friends
- friend class ResourceManager
-
enum class ECpuUnloadStrategy : uint8_t#
-
class Timer#
- #include <Timer.hpp>
Measures REAL TIME differences.
-
class TitleBarMenuPanel : public Hush::IEditorPanel#
-
struct ToastNotification#
Public Types
Public Functions
-
inline ToastNotification(std::string_view text, float remainingTime, EToastType type)#
Public Static Attributes
-
static constexpr size_t NOTIFICATION_MAX_LENGTH = 64#
-
inline ToastNotification(std::string_view text, float remainingTime, EToastType type)#
-
struct Transform#
Subclassed by Hush::LocalTransform, Hush::WorldTransform
Public Functions
-
Transform() = default#
-
Transform(const glm::vec3 &position, const glm::vec3 &scale = Vector3Math::ONE, const glm::quat &rotation = {})#
-
void SetPosition(const glm::vec3 &position) noexcept#
-
const glm::vec3 *GetPosition() const noexcept#
-
glm::vec3 *GetPosition() noexcept#
-
void SetScale(const glm::vec3 &scale) noexcept#
-
const glm::vec3 &GetScale() const noexcept#
-
glm::vec3 &GetScale() noexcept#
-
void SetRotationQuat(const glm::quat &rotationQuat) noexcept#
-
glm::quat GetRotationQuat() const noexcept#
-
void SetEulerAngles(const glm::vec3 &euler) noexcept#
-
glm::vec3 GetEulerAngles() const noexcept#
-
glm::mat3 GetRotationMatrix() const noexcept#
-
glm::vec3 Forward() const noexcept#
-
glm::vec3 Up() const noexcept#
-
glm::vec3 Right() const noexcept#
-
void SetTransformationMatrix(const glm::mat4 &xform)#
-
glm::mat4 GetTransformationMatrix() const#
-
Transform() = default#
-
class TransformationSystem : public Hush::ISystem#
Public Functions
-
virtual void OnShutdown() override#
OnShutdown() is called when the system is shutting down.
-
virtual void OnUpdate(float delta) override#
OnRender() is called when the system should render.
- Parameters:
delta – Time since last frame
-
virtual void OnFixedUpdate(float delta) override#
OnFixedUpdate() is called when the system should update its state.
- Parameters:
delta – Time since last fixed frame
-
virtual void OnRender() override#
OnRender() is called when the system should render.
-
virtual void OnPreRender() override#
OnPreRender() is called before rendering.
-
virtual void OnPostRender() override#
OnPostRender() is called after rendering.
-
virtual void OnShutdown() override#
-
class UI#
Public Types
Public Static Functions
-
static bool Spinner(const char *label, float radius, int thickness, const uint32_t &color = 3435973836u)#
-
static bool InputTextWithHint(const char *label, const char *hint, char *buffer, size_t size, bool focusOnInput)#
-
static bool BeginCenterPopup(const char *label, bool transparent = false)#
-
static bool CustomSelectable(const char *label, bool *isHovered, ImDrawList *drawList, bool forceHover = false)#
-
static bool BeginToolBar()#
-
static ImGuiID DockSpace(const char *dockspaceId, const char *name, ImGuiDockNodeFlags additionalFlags = 0)#
Public Static Attributes
-
static bool S_INITIALIZED = false#
-
static bool Spinner(const char *label, float radius, int thickness, const uint32_t &color = 3435973836u)#
-
class VirtualFilesystem#
- #include <VirtualFilesystem.hpp>
The VFS allows to manage paths as virtual locations (that might not refer to the real filesystem). For instance, to access an asset, we could use rs://myasset.txt, instead of referring to the physical location of the file. This, while introducing overhead, allows to manage more complex scenarios such as having the game files in a ZIP or a tar file. Or some other format. To use it, you must instantiate it
Public Types
Public Functions
-
VirtualFilesystem()#
-
~VirtualFilesystem()#
-
VirtualFilesystem(const VirtualFilesystem&) = delete#
-
VirtualFilesystem &operator=(const VirtualFilesystem&) = delete#
-
VirtualFilesystem(VirtualFilesystem &&rhs) noexcept#
-
VirtualFilesystem &operator=(VirtualFilesystem &&rhs) noexcept#
-
void Unmount(std::string_view virtualPath)#
-
std::vector<FileInfo> ListPath(std::string_view virtualPath, EListOptions options = EListOptions::None)#
-
Result<std::unique_ptr<IFile>, IFile::EError> OpenFile(std::string_view virtualPath, EFileOpenMode mode = EFileOpenMode::Read)#
-
VirtualFilesystem()#
-
class VulkanLoader : public Hush::IModelLoader#
Public Functions
-
VulkanLoader() = default#
-
virtual void SetResourceManager(ResourceManager *resourceManager) override#
-
virtual Result<std::vector<Entity>, EError> LoadMeshes(IRenderer *engine, const std::filesystem::path &filePath, Scene *activeScene) override#
-
virtual GpuAllocatedImage LoadTexture(IRenderer *engine, const ImageTexture &texture) override#
-
virtual ResourceManager *GetResourceManager() const override#
-
VulkanLoader() = default#
-
class WindowManager#
Public Static Functions
-
static inline WindowRenderer *GetMainWindow()#
-
static inline void SetMainWindow(WindowRenderer *window)#
-
static inline WindowRenderer *GetMainWindow()#
-
class WindowRenderer#
Public Functions
-
WindowRenderer(WindowRenderer &&other) = delete#
-
WindowRenderer(const WindowRenderer &other) = delete#
-
WindowRenderer &operator=(const WindowRenderer&) = delete#
-
WindowRenderer &operator=(WindowRenderer&&) = delete#
-
void HandleEvents(bool *applicationRunning)#
-
~WindowRenderer()#
-
bool IsActive() const noexcept#
-
glm::u32vec2 GetWindowSize() noexcept#
-
inline Hush::RenderGraph::RenderGraph &GetRenderGraph()#
-
inline Hush::RenderGraph::RenderDevice &GetRenderDevice()#
-
inline Hush::Graphics::IGraphicsDevice *GetGraphicsDevice() noexcept#
-
WindowRenderer(WindowRenderer &&other) = delete#
-
struct WorldTransform : public Hush::Transform#
Public Functions
-
Transform() = default#
-
Transform(const glm::vec3 &position, const glm::vec3 &scale = Vector3Math::ONE, const glm::quat &rotation = {})#
-
Transform() = default#
-
namespace ArrayUtils#
Provides utility functions for handling Arrays and collection types.
Functions
-
template<class ArrayType, class ElementType>
inline std::vector<ElementType> FuzzyFind(const ArrayType &candidates, const std::string &query)#
-
template<class ArrayType, class ElementType>
-
namespace Bitwise#
Definitions and all that just to make everything type safe.
-
namespace ComponentTraits#
Typedefs
-
using ComponentCtor = void (*)(void *array, std::int32_t count, const void *componentInfo)#
-
using ComponentDtor = void (*)(void *array, std::int32_t count, const void *componentInfo)#
-
using ComponentCopy = void (*)(void *dst, const void *src, std::int32_t count, const void *componentInfo)#
-
using ComponentMove = void (*)(void *dst, void *src, std::int32_t count, const void *componentInfo)#
-
using ComponentCopyCtor = void (*)(void *dst, const void *src, std::int32_t count, const void *componentInfo)#
-
using ComponentMoveCtor = void (*)(void *dst, void *src, std::int32_t count, const void *componentInfo)#
Enums
-
enum class EComponentOpsFlags : std::uint32_t#
Values:
-
enumerator None#
-
enumerator HasCtor#
-
enumerator HasDtor#
-
enumerator HasCopy#
-
enumerator HasMove#
-
enumerator HasCopyCtor#
-
enumerator HasMoveCtor#
-
enumerator HasMoveDtor#
-
enumerator HasMoveAssignDtor#
-
enumerator NoCtor#
-
enumerator NoDtor#
-
enumerator NoCopy#
-
enumerator NoMove#
-
enumerator NoCopyCtor#
-
enumerator NoMoveCtor#
-
enumerator NoMoveDtor#
-
enumerator NoMoveAssignDtor#
-
enumerator None#
Functions
-
template<typename T>
void CtorImpl(void *array, std::int32_t count, const void*)#
-
template<typename T>
void DtorImpl(void *array, std::int32_t count, const void*)#
-
template<typename T>
void CopyImpl(void *dst, const void *src, std::int32_t count, const void*)#
-
template<typename T>
void MoveImpl(void *dst, void *src, std::int32_t count, const void*)#
-
template<typename T>
void CopyCtorImpl(void *dst, const void *src, std::int32_t count, const void*)#
-
template<typename T>
void MoveCtorImpl(void *dst, void *src, std::int32_t count, const void*)#
-
template<typename T>
void MoveCtorDtorImpl(void *dst, void *src, std::int32_t count, const void*)#
-
template<typename T>
void MoveAssignDtorImpl(void *dst, void *src, std::int32_t count, const void*)#
-
template<typename T>
constexpr ComponentCtor GetCtorImpl(EComponentOpsFlags&)# Get the constructor function for a component.
- Template Parameters:
T – Type of the component.
- Returns:
Function pointer to the function that will construct the component.
-
template<typename T>
constexpr ComponentCtor GetCtorImpl(EComponentOpsFlags&) Get the constructor function for a component that does not have a trivial constructor.
- Template Parameters:
T – Type of the component.
- Returns:
Nullptr
-
template<typename T>
constexpr ComponentCtor GetCtorImpl(EComponentOpsFlags &flags)
-
template<typename T>
constexpr ComponentDtor GetDtorImpl(EComponentOpsFlags&)#
-
template<typename T>
constexpr ComponentDtor GetDtorImpl(EComponentOpsFlags&)
-
template<typename T>
constexpr ComponentDtor GetDtorImpl(EComponentOpsFlags &flags)
-
template<typename T>
constexpr ComponentCopy GetCopyImpl(EComponentOpsFlags&)#
-
template<typename T>
constexpr ComponentCopy GetCopyImpl(EComponentOpsFlags&)
-
template<typename T>
constexpr ComponentCopy GetCopyImpl(EComponentOpsFlags &flags)
-
template<typename T>
constexpr ComponentMove GetMoveImpl(EComponentOpsFlags&)#
-
template<typename T>
constexpr ComponentMove GetMoveImpl(EComponentOpsFlags&)
-
template<typename T>
constexpr ComponentMove GetMoveImpl(EComponentOpsFlags &flags)
-
template<typename T>
constexpr ComponentCopyCtor GetCopyCtorImpl(EComponentOpsFlags&)#
-
template<typename T>
constexpr ComponentCopyCtor GetCopyCtorImpl(EComponentOpsFlags&)
-
template<typename T>
constexpr ComponentCopyCtor GetCopyCtorImpl(EComponentOpsFlags &flags)
-
template<typename T>
constexpr ComponentMoveCtor GetMoveCtorImpl(EComponentOpsFlags&)#
-
template<typename T>
constexpr ComponentMoveCtor GetMoveCtorImpl(EComponentOpsFlags&)
-
template<typename T>
constexpr ComponentMoveCtor GetMoveCtorImpl(EComponentOpsFlags &flags)
-
template<typename T>
constexpr ComponentMoveCtor GetMoveDtorImpl(EComponentOpsFlags&)#
-
template<typename T>
constexpr ComponentMoveCtor GetMoveDtorImpl(EComponentOpsFlags&)
-
template<typename T>
constexpr ComponentMoveCtor GetMoveDtorImpl(EComponentOpsFlags &flags)
-
template<typename T>
constexpr ComponentMoveCtor GetMoveAssignDtorImpl(EComponentOpsFlags&)#
-
template<typename T>
constexpr ComponentMoveCtor GetMoveAssignDtorImpl(EComponentOpsFlags &flags)
-
template<typename T>
constexpr ComponentMoveCtor GetMoveAssignDtorImpl(EComponentOpsFlags&)
-
template<typename T>
constexpr ComponentOps GetOps(EComponentOpsFlags &flags)# Get the operations for a component.
- Template Parameters:
T – Type of the component.
- Returns:
Operations for the component.
-
template<typename T>
ComponentInfo GetComponentInfo()#
-
struct ComponentInfo#
Public Members
-
std::size_t size#
-
std::size_t alignment#
-
const char *name#
-
ComponentOps ops#
-
EComponentOpsFlags opsFlags#
-
void *userCtx#
-
void (*userCtxFree)(void*)#
-
std::size_t size#
-
struct ComponentOps#
Public Members
-
ComponentCtor ctor#
-
ComponentDtor dtor#
-
ComponentCopy copy#
-
ComponentMove move#
-
ComponentCopyCtor copyCtor#
-
ComponentMoveCtor moveCtor#
-
ComponentMoveCtor moveDtor#
-
ComponentMoveCtor moveAssignDtor#
-
ComponentCtor ctor#
-
namespace detail#
-
Functions
-
template<typename T>
static std::pair<EEntityRegisterStatus, std::uint64_t*> GetEntityIdImpl(const void *worldPtr)# Get the entity id for a given entity type.
- Template Parameters:
T – Type of the entity, without cvref.
- Parameters:
worldPtr – Pointer to the world.
- Returns:
Pair with the status of the entity and the entity id.
-
template<typename T>
static std::pair<EEntityRegisterStatus, std::uint64_t*> GetEntityId(const void *worldPtr)# Get the entity id for a given entity type.
- Template Parameters:
T – Type of the entity.
- Parameters:
worldPtr – Pointer to the world.
- Returns:
Pair with the status of the entity and the entity id.
-
template<typename T>
-
using ComponentCtor = void (*)(void *array, std::int32_t count, const void *componentInfo)#
-
namespace DefaultObjects#
-
Functions
-
Entity::EntityId MakeDefault(Scene *activeScene, EDefaultObjectType objectType)#
-
Entity::EntityId MakeDefault(Scene *activeScene, EDefaultObjectType objectType)#
-
namespace EcsTerms#
-
namespace Export#
Functions
-
template<std::size_t N>
constexpr void name(const char (&name)[N])# Renames a class or struct.
- Parameters:
name – The new name of the class or struct. For instance, given the following class: class [[hush::export(Hush::Export::name(“MyExportedClass”))]] MyClass2 { public: int myVariable; }; The generated C code will be: typedef struct MyExportedClass MyExportedClass;
Variables
-
constexpr bool asHandle = true#
Export a class or struct as a handle. This will generate a typedef for the class or struct. If not defined, the class or struct will be exported as a struct with all the members.
For instance, given the following class: class [[hush::export(Hush::Export::asHandle)]] MyClass { public: int myVariable; }; The generated C code will be: typedef struct MyClass MyClass;
-
constexpr bool ignore = true#
Ignores a member of a class or struct. It, however, will be exported as a buffer. For instance, given the following class: class [[hush::export(Hush::Export::ignore)]] MyClass { public: int myVariable; [[hush::export(Hush::Export::ignore)]] int myVariable2; }; The generated C code will be: typedef struct MyClass MyClass { int myVariable; alignas(4) char myVariable2[4]; };
-
template<std::size_t N>
-
namespace GltfLoadFunctions#
Enums
Functions
-
fastgltf::Expected<fastgltf::Asset> GetAssetFromFile(const std::filesystem::path &file)#
-
glm::mat4 GetNodeTransform(const fastgltf::Node &node)#
-
EMaterialPass GetMaterialPassFromFastGltfPass(fastgltf::AlphaMode pass)#
-
std::span<const std::byte> ExtractImageBuffer(const fastgltf::Image &image, const fastgltf::Asset &asset, fastgltf::MimeType *outMimeType)#
-
std::shared_ptr<ImageTexture> TextureFromImageDataSource(const fastgltf::Asset &asset, const fastgltf::Image &image)#
-
EError SetMaterialTextures(void *outMaterialResources, const fastgltf::Asset &asset, const fastgltf::Material &material, const void *loadedTextures)#
-
template<class BufferType>
inline std::vector<BufferType> FindAttributeByName(const fastgltf::Primitive &primitive, const fastgltf::Asset &asset, const std::string_view &attributeName)#
-
fastgltf::Expected<fastgltf::Asset> GetAssetFromFile(const std::filesystem::path &file)#
-
namespace Graphics#
Enums
-
enum class EGraphicsAPI#
Graphics API backend type.
Values:
-
enumerator Vulkan#
-
enumerator D3D12#
-
enumerator Metal#
-
enumerator WebGPU#
-
enumerator Vulkan#
-
enum class EBufferUsage : uint32_t#
Buffer usage flags.
Values:
-
enumerator None#
-
enumerator Vertex#
-
enumerator Index#
-
enumerator Uniform#
-
enumerator Storage#
-
enumerator CopySource#
-
enumerator CopyDestination#
-
enumerator Indirect#
-
enumerator None#
-
enum class ETextureUsage : uint32_t#
Texture usage flags.
Values:
-
enumerator None#
-
enumerator Sampled#
-
enumerator Storage#
-
enumerator RenderTarget#
-
enumerator DepthStencil#
-
enumerator CopySource#
-
enumerator CopyDestination#
-
enumerator None#
-
enum class ETextureFormat#
Texture format.
Values:
-
enumerator R8_UNORM#
-
enumerator R8_SNORM#
-
enumerator R8_UINT#
-
enumerator R8_SINT#
-
enumerator R16_UNORM#
-
enumerator R16_SNORM#
-
enumerator R16_UINT#
-
enumerator R16_SINT#
-
enumerator R16_FLOAT#
-
enumerator R32_UINT#
-
enumerator R32_SINT#
-
enumerator R32_FLOAT#
-
enumerator RG8_UNORM#
-
enumerator RG8_SNORM#
-
enumerator RG16_FLOAT#
-
enumerator RG32_FLOAT#
-
enumerator RGB8_UNORM#
-
enumerator RGB8_SRGB#
-
enumerator RGBA8_UNORM#
-
enumerator RGBA8_SRGB#
-
enumerator RGBA16_FLOAT#
-
enumerator RGBA32_FLOAT#
-
enumerator BGRA8_UNORM#
-
enumerator BGRA8_SRGB#
-
enumerator D16_UNORM#
-
enumerator D24_UNORM#
-
enumerator D32_FLOAT#
-
enumerator D24_UNORM_S8_UINT#
-
enumerator D32_FLOAT_S8_UINT#
-
enumerator BC1_UNORM#
-
enumerator BC1_SRGB#
-
enumerator BC3_UNORM#
-
enumerator BC3_SRGB#
-
enumerator BC4_UNORM#
-
enumerator BC5_UNORM#
-
enumerator BC7_UNORM#
-
enumerator BC7_SRGB#
-
enumerator R8_UNORM#
-
enum class EMemoryAccess#
Memory access flags.
Values:
-
enumerator CPUNone#
-
enumerator CPUWrite#
-
enumerator CPURead#
-
enumerator CPUReadWrite#
-
enumerator CPUNone#
-
enum class ECompareFunction : uint32_t#
Comparison function used for depth/stencil tests and comparison samplers.
When used with a sampler, Undefined means “no comparison” (regular filtering sampler). For depth/stencil state, use one of the concrete comparison functions (Never..Always).
Values:
-
enumerator Undefined#
No comparison — used for regular filtering samplers.
-
enumerator Never#
Comparison never passes.
-
enumerator Less#
Passes if reference < fetched value.
-
enumerator Equal#
Passes if reference == fetched value.
-
enumerator LessEqual#
Passes if reference <= fetched value.
-
enumerator Greater#
Passes if reference > fetched value.
-
enumerator NotEqual#
Passes if reference != fetched value.
-
enumerator GreaterEqual#
Passes if reference >= fetched value.
-
enumerator Always#
Comparison always passes.
-
enumerator Undefined#
-
enum class EQueueType#
Queue type for command submission.
Values:
-
enumerator Graphics#
-
enumerator Compute#
-
enumerator Transfer#
-
enumerator Graphics#
-
enum class EResourceState : uint32_t#
Resource state flags for barrier transitions.
These represent the logical usage state of a GPU resource. A resource can be in a combined read state (multiple read flags OR’d together), but only one write state at a time.
Modeled after D3D12 resource states / Vulkan image layouts.
Values:
-
enumerator Undefined#
-
enumerator VertexBuffer#
-
enumerator IndexBuffer#
-
enumerator ConstantBuffer#
-
enumerator NonPixelShaderAccess#
-
enumerator PixelShaderAccess#
-
enumerator IndirectArgument#
-
enumerator CopySource#
-
enumerator DepthStencilRead#
-
enumerator Present#
-
enumerator RenderTarget#
-
enumerator DepthStencilWrite#
-
enumerator UnorderedAccess#
-
enumerator CopyDestination#
-
enumerator AnyShaderAccess#
-
enumerator GenericRead#
-
enumerator Undefined#
-
enum class EShaderStageFlags : uint32_t#
Bitmask flags indicating which shader stages can access a binding.
Values:
-
enumerator None#
-
enumerator Vertex#
-
enumerator Fragment#
-
enumerator Compute#
-
enumerator All#
-
enumerator None#
-
enum class EBindingType : uint32_t#
The type of resource bound at a particular binding slot.
Values:
-
enumerator UniformBuffer#
Uniform / constant buffer (read-only, small, frequently updated)
-
enumerator StorageBuffer#
Storage buffer (read-write, large, compute-friendly)
-
enumerator ReadOnlyStorageBuffer#
Read-only storage buffer.
-
enumerator SampledTexture#
Sampled texture (used with a sampler for filtered reads)
-
enumerator StorageTexture#
Storage texture (unfiltered read/write, typically for compute)
-
enumerator Sampler#
Sampler object (filtering, addressing modes)
-
enumerator ComparisonSampler#
Comparison sampler (for shadow mapping, etc.)
-
enumerator UniformBuffer#
-
enum class ETextureSampleType : uint32_t#
The component type that a sampled texture binding expects.
Values:
-
enumerator Float#
Filterable float texture.
-
enumerator UnfilterableFloat#
Non-filterable float texture.
-
enumerator Depth#
Depth comparison texture.
-
enumerator Sint#
Signed integer texture.
-
enumerator Uint#
Unsigned integer texture.
-
enumerator Float#
-
enum class EStorageTextureAccess : uint32_t#
Access mode for storage texture bindings.
Values:
-
enumerator WriteOnly#
-
enumerator ReadOnly#
-
enumerator ReadWrite#
-
enumerator WriteOnly#
-
enum class ESamplerBindingType : uint32_t#
Sampler type classification for layout entries.
Values:
-
enumerator Filtering#
Standard filtering sampler.
-
enumerator NonFiltering#
Non-filtering (nearest) sampler.
-
enumerator Comparison#
Comparison sampler (for shadow maps)
-
enumerator Filtering#
-
enum class EPipelineType : uint32_t#
Discriminator for the kind of pipeline (graphics vs compute).
Values:
-
enumerator Graphics#
-
enumerator Compute#
-
enumerator Graphics#
-
enum class EFilterMode : uint32_t#
Texture filtering mode used for magnification, minification, and mip-level selection.
Values:
-
enumerator Nearest#
Nearest-neighbour (point) sampling.
-
enumerator Linear#
Linear (bilinear) interpolation.
-
enumerator Nearest#
-
enum class EAddressMode : uint32_t#
Texture address (wrap) mode applied per UV(W) axis.
Values:
-
enumerator Repeat#
Tile the texture at every UV integer junction.
-
enumerator MirrorRepeat#
Tile the texture, flipping it at every integer junction.
-
enumerator ClampToEdge#
Clamp texture coordinates to [0, 1]; the edge texel is extended.
-
enumerator Repeat#
-
enum class EShaderStage : uint32_t#
Shader stage type.
Values:
-
enumerator Vertex#
-
enumerator Fragment#
-
enumerator Compute#
-
enumerator Count#
-
enumerator Vertex#
-
enum class EVertexFormat : uint32_t#
Vertex attribute format (matches common GPU formats)
Values:
-
enumerator Float32#
-
enumerator Float32x2#
-
enumerator Float32x3#
-
enumerator Float32x4#
-
enumerator Sint32#
-
enumerator Sint32x2#
-
enumerator Sint32x3#
-
enumerator Sint32x4#
-
enumerator Uint32#
-
enumerator Uint32x2#
-
enumerator Uint32x3#
-
enumerator Uint32x4#
-
enumerator Float16x2#
-
enumerator Float16x4#
-
enumerator Uint8x2#
-
enumerator Uint8x4#
-
enumerator Sint8x2#
-
enumerator Sint8x4#
-
enumerator Unorm8x2#
-
enumerator Unorm8x4#
-
enumerator Snorm8x2#
-
enumerator Snorm8x4#
-
enumerator Uint16x2#
-
enumerator Uint16x4#
-
enumerator Sint16x2#
-
enumerator Sint16x4#
-
enumerator Unorm16x2#
-
enumerator Unorm16x4#
-
enumerator Snorm16x2#
-
enumerator Snorm16x4#
-
enumerator Float32#
-
enum class EVertexStepMode : uint32_t#
Vertex input stepping mode.
Values:
-
enumerator Vertex#
Attribute advances per vertex.
-
enumerator Instance#
Attribute advances per instance.
-
enumerator Vertex#
-
enum class EPrimitiveTopology : uint32_t#
Primitive topology for the input assembler stage.
Values:
-
enumerator PointList#
-
enumerator LineList#
-
enumerator LineStrip#
-
enumerator TriangleList#
-
enumerator TriangleStrip#
-
enumerator PointList#
-
enum class EFrontFace : uint32_t#
Front face winding order.
Values:
-
enumerator CounterClockwise#
-
enumerator Clockwise#
-
enumerator CounterClockwise#
-
enum class ECullModeFlags : uint32_t#
Cull mode for the rasterizer.
Values:
-
enumerator None#
-
enumerator Front#
-
enumerator Back#
-
enumerator None#
-
enum class EIndexFormat : uint32_t#
Index format for indexed draw calls.
Values:
-
enumerator Undefined#
-
enumerator Uint16#
-
enumerator Uint32#
-
enumerator Undefined#
-
enum class EBlendFactor : uint32_t#
Blend factor.
Values:
-
enumerator Zero#
-
enumerator One#
-
enumerator Src#
-
enumerator OneMinusSrc#
-
enumerator SrcAlpha#
-
enumerator OneMinusSrcAlpha#
-
enumerator Dst#
-
enumerator OneMinusDst#
-
enumerator DstAlpha#
-
enumerator OneMinusDstAlpha#
-
enumerator SrcAlphaSaturated#
-
enumerator Constant#
-
enumerator OneMinusConstant#
-
enumerator Zero#
-
enum class EBlendOperation : uint32_t#
Blend operation.
Values:
-
enumerator Add#
-
enumerator Subtract#
-
enumerator ReverseSubtract#
-
enumerator Min#
-
enumerator Max#
-
enumerator Add#
-
enum class EColorWriteMask : uint32_t#
Color write mask flags.
Values:
-
enumerator None#
-
enumerator Red#
-
enumerator Green#
-
enumerator Blue#
-
enumerator Alpha#
-
enumerator All#
-
enumerator None#
-
enum class EStencilOperation : uint32_t#
Stencil operation.
Values:
-
enumerator Keep#
-
enumerator Zero#
-
enumerator Replace#
-
enumerator IncrementClamp#
-
enumerator DecrementClamp#
-
enumerator Invert#
-
enumerator IncrementWrap#
-
enumerator DecrementWrap#
-
enumerator Keep#
-
enum class ELoadOp#
Load operation for render pass attachments.
Values:
-
enumerator Load#
-
enumerator Clear#
-
enumerator DontCare#
-
enumerator Load#
-
enum class EStoreOp#
Store operation for render pass attachments.
Values:
-
enumerator Store#
-
enumerator DontCare#
-
enumerator Store#
-
enum class EShaderTarget : uint32_t#
The target intermediate representation / language that the compiler should emit.
Values:
-
enumerator WGSL#
WebGPU Shading Language (text)
-
enumerator SPIRV#
SPIR-V bytecode (Vulkan)
-
enumerator HLSL#
HLSL source text (for further compilation to DXIL, or for debugging)
-
enumerator DXIL#
DirectX Intermediate Language bytecode (D3D12)
-
enumerator WGSL#
Functions
-
inline EBufferUsage operator|(EBufferUsage a, EBufferUsage b)#
-
inline EBufferUsage operator&(EBufferUsage a, EBufferUsage b)#
-
inline ETextureUsage operator|(ETextureUsage a, ETextureUsage b)#
-
inline ETextureUsage operator&(ETextureUsage a, ETextureUsage b)#
-
constexpr uint32_t GetBytesPerPixel(ETextureFormat format)#
Return the number of bytes per pixel for uncompressed formats. Compressed / depth-stencil formats return a best-effort value (block size divided by texel count is NOT attempted — callers dealing with BC formats should use dedicated block-size helpers).
-
inline EMemoryAccess operator|(EMemoryAccess a, EMemoryAccess b)#
-
inline EMemoryAccess operator&(EMemoryAccess a, EMemoryAccess b)#
-
inline EMemoryAccess &operator|=(EMemoryAccess &a, EMemoryAccess b)#
-
inline bool HasFlag(EMemoryAccess access, EMemoryAccess flag)#
-
inline EResourceState operator|(EResourceState a, EResourceState b)#
-
inline EResourceState operator&(EResourceState a, EResourceState b)#
-
inline EResourceState &operator|=(EResourceState &a, EResourceState b)#
-
inline bool HasFlag(EResourceState state, EResourceState flag)#
-
inline bool IsWriteState(EResourceState state)#
Returns true if the state contains any write flag.
-
inline EShaderStageFlags operator|(EShaderStageFlags a, EShaderStageFlags b)#
-
inline EShaderStageFlags operator&(EShaderStageFlags a, EShaderStageFlags b)#
-
inline EShaderStageFlags &operator|=(EShaderStageFlags &a, EShaderStageFlags b)#
-
inline bool HasStageFlag(EShaderStageFlags flags, EShaderStageFlags test)#
-
inline bool IsComparisonSampler(const SamplerDescriptor &desc)#
Returns true if the descriptor describes a comparison sampler.
-
inline uint32_t GetVertexFormatSize(EVertexFormat format)#
Returns the byte size of a single vertex attribute element.
-
inline EColorWriteMask operator|(EColorWriteMask a, EColorWriteMask b)#
-
inline EColorWriteMask operator&(EColorWriteMask a, EColorWriteMask b)#
-
static SlangCompileTarget ToSlangCompileTarget(EShaderTarget target)#
-
static void AppendDiagnostics(ISlangBlob *blob, std::string &outDiagnostics)#
-
static EBindingType FromSlangBindingType(slang::ParameterCategory category)#
-
static EVertexFormat FromSlangTypeToVertexFormat(uint32_t scalarType, uint32_t rows, uint32_t columns)#
-
static void ReflectParameterBinding(slang::VariableLayoutReflection *param, const std::vector<CompiledShaderStage> &stages, std::vector<ReflectedBinding> &outBindings)#
-
static void ReflectVertexInputsFromStruct(slang::TypeLayoutReflection *inputType, std::vector<ReflectedVertexInput> &outInputs)#
-
static void ReflectVertexInputs(slang::ProgramLayout *layout, std::vector<ReflectedVertexInput> &outInputs)#
-
inline wgpu::ShaderStage ConvertShaderStageFlags(EShaderStageFlags flags)#
Convert engine shader stage flags to wgpu::ShaderStage.
-
inline wgpu::TextureViewDimension ConvertTextureViewDimension(uint32_t dimension)#
Convert engine texture view dimension to wgpu::TextureViewDimension.
-
inline wgpu::TextureSampleType ConvertTextureSampleType(ETextureSampleType sampleType)#
Convert engine texture sample type to wgpu::TextureSampleType.
-
inline wgpu::StorageTextureAccess ConvertStorageTextureAccess(EStorageTextureAccess access)#
Convert engine storage texture access to wgpu::StorageTextureAccess.
-
inline wgpu::SamplerBindingType ConvertSamplerBindingType(ESamplerBindingType type)#
Convert engine sampler binding type to wgpu::SamplerBindingType.
-
inline wgpu::TextureFormat ConvertTextureFormatForBindGroup(ETextureFormat format)#
Convert engine texture format to wgpu::TextureFormat (for bind group / storage texture usage).
-
static wgpu::TextureFormat GetTextureFormat(IGraphicsTexture *texture)#
-
static uint32_t GetTextureBytesPerPixel(wgpu::TextureFormat format)#
-
inline wgpu::VertexFormat ConvertVertexFormat(EVertexFormat format)#
Convert engine vertex format to wgpu::VertexFormat.
-
inline wgpu::PrimitiveTopology ConvertPrimitiveTopology(EPrimitiveTopology topology)#
Convert engine primitive topology to wgpu::PrimitiveTopology.
-
inline wgpu::FrontFace ConvertFrontFace(EFrontFace frontFace)#
Convert engine front face to wgpu::FrontFace.
-
inline wgpu::CullMode ConvertCullMode(ECullModeFlags cullMode)#
Convert engine cull mode to wgpu::CullMode.
-
inline wgpu::IndexFormat ConvertIndexFormat(EIndexFormat format)#
Convert engine index format to wgpu::IndexFormat.
-
inline wgpu::BlendFactor ConvertBlendFactor(EBlendFactor factor)#
Convert engine blend factor to wgpu::BlendFactor.
-
inline wgpu::BlendOperation ConvertBlendOperation(EBlendOperation op)#
Convert engine blend operation to wgpu::BlendOperation.
-
inline wgpu::CompareFunction ConvertCompareFunction(ECompareFunction func)#
Convert engine compare function to wgpu::CompareFunction.
-
inline wgpu::StencilOperation ConvertStencilOperation(EStencilOperation op)#
Convert engine stencil operation to wgpu::StencilOperation.
-
inline wgpu::TextureFormat ConvertTextureFormatForPipeline(ETextureFormat format)#
Convert engine texture format to wgpu::TextureFormat.
This is a pipeline-local conversion helper. The WebGPUGraphicsDevice also has a ConvertTextureFormat but it is private; pipelines need their own accessible copy to build color target and depth/stencil state descriptors.
-
inline wgpu::ColorWriteMask ConvertColorWriteMask(EColorWriteMask mask)#
Convert engine color write mask to wgpu::ColorWriteMask.
-
inline wgpu::FilterMode ConvertFilterMode(EFilterMode mode)#
Convert engine filter mode to wgpu::FilterMode.
-
inline wgpu::MipmapFilterMode ConvertMipmapFilterMode(EFilterMode mode)#
Convert engine filter mode to wgpu::MipmapFilterMode.
-
inline wgpu::AddressMode ConvertAddressMode(EAddressMode mode)#
Convert engine address mode to wgpu::AddressMode.
Variables
-
static constexpr uint32_t MAX_COLOR_TARGETS = 8#
Maximum number of color targets a pipeline can have.
-
static constexpr uint32_t MAX_VERTEX_BUFFERS = 16#
Maximum number of vertex buffer bindings.
-
static constexpr uint32_t MAX_BIND_GROUPS = 4#
Maximum number of bind group layouts per pipeline.
-
struct BarrierGroup#
- #include <GraphicsTypes.hpp>
A batch of barriers to issue in a single call.
Public Members
-
std::vector<ResourceBarrierDescriptor> transitions#
-
std::vector<UAVBarrierDescriptor> uavBarriers#
-
std::vector<SplitBarrierDescriptor> beginSplitBarriers#
-
std::vector<SplitBarrierDescriptor> endSplitBarriers#
-
std::vector<ResourceBarrierDescriptor> transitions#
-
struct BindGroupDescriptor#
- #include <IBindGroup.hpp>
Descriptor for creating a bind group.
Public Members
-
IBindGroupLayout *layout = nullptr#
The layout this bind group conforms to.
-
std::vector<BindGroupEntry> entries#
The resource bindings.
-
std::string debugName#
Optional debug name.
-
IBindGroupLayout *layout = nullptr#
-
struct BindGroupEntry#
- #include <IBindGroup.hpp>
Describes a single resource binding within a bind group.
Exactly one of the resource pointer fields (buffer, texture, sampler) should be non-null, matching the type declared in the corresponding BindGroupLayoutEntry.
Public Members
-
uint32_t binding = 0#
Binding index (must match a BindGroupLayoutEntry::binding)
-
IGraphicsBuffer *buffer = nullptr#
Buffer to bind (for UniformBuffer / StorageBuffer / ReadOnlyStorageBuffer entries).
-
uint64_t offset = 0#
Byte offset into the buffer.
-
uint64_t size = 0#
Number of bytes to expose to the shader. Use 0 or UINT64_MAX for “whole buffer from offset”.
-
IGraphicsTexture *texture = nullptr#
Texture to bind (for SampledTexture / StorageTexture entries).
-
uint32_t binding = 0#
-
struct BindGroupLayoutDescriptor#
- #include <IBindGroup.hpp>
Descriptor for creating a bind group layout.
Public Members
-
std::vector<BindGroupLayoutEntry> entries#
The entries that make up this layout.
-
std::string debugName#
Optional debug name.
-
std::vector<BindGroupLayoutEntry> entries#
-
struct BindGroupLayoutEntry#
- #include <IBindGroup.hpp>
Describes a single binding within a bind group layout.
Each entry declares the binding index, the type of resource expected, which shader stages can see it, and type-specific configuration.
Public Members
-
uint32_t binding = 0#
Binding index (corresponds to @binding(N) in WGSL / binding in Slang / layout(binding = N) in GLSL).
-
EBindingType type = EBindingType::UniformBuffer#
The kind of resource at this binding slot.
-
EShaderStageFlags stageFlags = EShaderStageFlags::All#
Which shader stages this binding is visible to.
-
bool hasDynamicOffset = false#
For UniformBuffer / StorageBuffer / ReadOnlyStorageBuffer: whether the buffer binding has a dynamic offset.
-
uint64_t minBufferBindingSize = 0#
For UniformBuffer / StorageBuffer: minimum buffer binding size (0 = no constraint).
-
ETextureSampleType textureSampleType = ETextureSampleType::Float#
For SampledTexture: the expected sample type.
-
uint32_t textureViewDimension = 2#
For SampledTexture / StorageTexture: the texture view dimension. 0 = undefined, 1 = 1D, 2 = 2D, 3 = 3D, 4 = Cube, 5 = 2DArray, etc. (Backends translate this to their own enum.)
-
bool textureMultisampled = false#
For SampledTexture: whether the texture is multisampled.
-
EStorageTextureAccess storageTextureAccess = EStorageTextureAccess::WriteOnly#
For StorageTexture: the access mode.
-
ETextureFormat storageTextureFormat = ETextureFormat::RGBA8_UNORM#
For StorageTexture: the texture format.
-
ESamplerBindingType samplerType = ESamplerBindingType::Filtering#
For Sampler / ComparisonSampler: the sampler binding type.
-
uint32_t binding = 0#
-
struct BindGroupLayoutResource#
- #include <GraphicsResources.hpp>
Bind group layout resource for RenderGraph Owns the bind group layout lifetime so client code does not need to manage it.
Public Types
-
using Descriptor = BindGroupLayoutDescriptor#
Public Functions
-
inline IBindGroupLayout *Get() const#
Get the underlying bind group layout (convenience accessor)
-
inline bool IsValid() const#
Check if the resource is valid.
-
void CreateResource(const BindGroupLayoutDescriptor &layoutDescriptor, IGraphicsDevice *device)#
-
void DestroyResource(const BindGroupLayoutDescriptor &layoutDescriptor, IGraphicsDevice *device)#
Public Members
-
std::unique_ptr<IBindGroupLayout> layout#
Runtime bind group layout handle.
-
BindGroupLayoutDescriptor descriptor#
Resource descriptor.
-
using Descriptor = BindGroupLayoutDescriptor#
-
struct BindGroupResource#
- #include <GraphicsResources.hpp>
Bind group resource for RenderGraph Owns the bind group lifetime so client code does not need to manage it.
Public Types
-
using Descriptor = BindGroupDescriptor#
Public Functions
-
inline IBindGroup *Get() const#
Get the underlying bind group (convenience accessor)
-
inline bool IsValid() const#
Check if the resource is valid.
-
void CreateResource(const BindGroupDescriptor &bindGroupDescriptor, IGraphicsDevice *device)#
-
void DestroyResource(const BindGroupDescriptor &bindGroupDescriptor, IGraphicsDevice *device)#
Public Members
-
std::unique_ptr<IBindGroup> bindGroup#
Runtime bind group handle.
-
BindGroupDescriptor descriptor#
Resource descriptor.
-
using Descriptor = BindGroupDescriptor#
-
struct BlendComponent#
- #include <PipelineDescriptor.hpp>
Describes blend behaviour for a single component (color or alpha)
Public Members
-
EBlendOperation operation = EBlendOperation::Add#
-
EBlendFactor srcFactor = EBlendFactor::One#
-
EBlendFactor dstFactor = EBlendFactor::Zero#
-
EBlendOperation operation = EBlendOperation::Add#
-
struct BufferDescriptor#
- #include <GraphicsTypes.hpp>
Buffer creation descriptor.
Public Members
-
uint64_t size = 0#
-
EBufferUsage usage = EBufferUsage::None#
-
EMemoryAccess memoryAccess = EMemoryAccess::CPUNone#
-
const char *debugName = nullptr#
-
uint64_t size = 0#
-
struct BufferResource#
- #include <GraphicsResources.hpp>
Buffer resource descriptor for RenderGraph This is used during BuildContext to declare buffer creation parameters.
Public Types
-
using Descriptor = BufferDescriptor#
Public Functions
-
inline IGraphicsBuffer *Get() const#
Get the underlying buffer (convenience accessor)
-
inline bool IsValid() const#
Check if the resource is valid.
-
void CreateResource(const BufferDescriptor &bufferDescriptor, IGraphicsDevice *device)#
-
void DestroyResource(const BufferDescriptor &bufferDescriptor, IGraphicsDevice *device)#
Public Members
-
std::shared_ptr<IGraphicsBuffer> buffer#
Runtime buffer handle (set during execution)
-
BufferDescriptor descriptor#
Resource descriptor.
-
using Descriptor = BufferDescriptor#
-
struct ClearDepthStencilValue#
- #include <RenderPass.hpp>
Depth/stencil clear value.
-
struct ColorTargetState#
- #include <PipelineDescriptor.hpp>
Per-target blend state.
Public Members
-
ETextureFormat format = ETextureFormat::BGRA8_UNORM#
Texture format of this color target.
-
bool blendEnabled = false#
Whether blending is enabled for this target.
-
BlendComponent colorBlend#
Color channel blend settings.
-
BlendComponent alphaBlend#
Alpha channel blend settings.
-
EColorWriteMask writeMask = EColorWriteMask::All#
Write mask.
-
ETextureFormat format = ETextureFormat::BGRA8_UNORM#
-
struct CompiledShaderStage#
- #include <ShaderCompiler.hpp>
Per-stage compilation output.
Public Members
-
EShaderStage stage = EShaderStage::Vertex#
The stage this output corresponds to.
-
std::string entryPoint#
The entry point name.
-
ShaderModuleDescriptor moduleDesc#
A ready-to-use ShaderModuleDescriptor that can be passed directly to IGraphicsDevice::CreateShaderModule().
-
EShaderStage stage = EShaderStage::Vertex#
-
struct ComputePassData#
- #include <GraphicsResources.hpp>
Common data for a compute pass.
Public Members
-
std::vector<uint32_t> inputBuffers#
Input buffer resource IDs.
-
std::vector<uint32_t> outputBuffers#
Output buffer resource IDs.
-
std::vector<uint32_t> inputTextures#
Input texture resource IDs.
-
std::vector<uint32_t> outputTextures#
Output texture resource IDs.
-
uint32_t groupCountX = 1#
Dispatch dimensions.
-
uint32_t groupCountY = 1#
-
uint32_t groupCountZ = 1#
-
std::vector<uint32_t> inputBuffers#
-
struct ComputePipelineDescriptor#
- #include <PipelineDescriptor.hpp>
Complete descriptor for creating a compute pipeline.
Public Members
-
PipelineShaderStage computeStage#
Compute shader stage (required)
-
std::array<IBindGroupLayout*, MAX_BIND_GROUPS> bindGroupLayouts = {}#
Bind group layouts that this pipeline uses.
-
uint32_t bindGroupLayoutCount = 0#
Number of bind group layouts actually used.
-
std::string debugName#
Optional debug name.
-
PipelineShaderStage computeStage#
-
struct DepthStencilState#
- #include <PipelineDescriptor.hpp>
Depth/stencil state for the pipeline.
Public Members
-
bool enabled = false#
Whether depth/stencil is enabled at all. When false, the remaining fields are ignored and no depth/stencil attachment is expected.
-
ETextureFormat format = ETextureFormat::D24_UNORM#
Depth buffer format.
-
bool depthWriteEnabled = true#
Enable depth testing.
-
ECompareFunction depthCompare = ECompareFunction::Less#
Depth comparison function.
-
StencilFaceState stencilFront#
Stencil front face.
-
StencilFaceState stencilBack#
Stencil back face.
-
uint32_t stencilReadMask = 0xFF#
Stencil read mask.
-
uint32_t stencilWriteMask = 0xFF#
Stencil write mask.
-
int32_t depthBias = 0#
Depth bias (constant factor)
-
float depthBiasSlopeScale = 0.0f#
Depth bias slope factor.
-
float depthBiasClamp = 0.0f#
Depth bias clamp.
-
bool enabled = false#
-
struct DummyResource#
- #include <GraphicsResources.hpp>
Dummy resource type for render graph resources that don’t correspond to actual GPU resources.
This can be used to specify dependencies between passes in the render graph without needing a real texture or buffer (e.g. for synchronization or logical grouping).
For example, a pass that performs a compute operation without any actual GPU resources could use a DummyResource as its output, and subsequent passes could declare dependencies on that output to ensure correct execution order.
Public Functions
-
inline void CreateResource(const Descriptor &descriptor, IGraphicsDevice *device)#
-
inline void DestroyResource(const Descriptor &descriptor, IGraphicsDevice *device)#
-
struct Descriptor#
-
inline void CreateResource(const Descriptor &descriptor, IGraphicsDevice *device)#
-
struct FenceSignalDescriptor#
- #include <ICommandQueue.hpp>
Describes a single fence signal operation.
After all command lists in the same SubmitInfo batch have been submitted, the queue will signal the fence to the specified value.
-
struct FenceWaitDescriptor#
- #include <ICommandQueue.hpp>
Describes a single fence wait operation.
The queue will stall until the fence reaches the specified value before executing any command lists in the same SubmitInfo batch.
-
struct GraphicsApiMaterialInstance#
- #include <MaterialInstance.hpp>
Material instance struct that holds the underlying graphics API resources for a material, as well as the material pass type it belongs to.
Public Members
-
IBindGroup *bindGroup#
The bind group containing the material’s bound resources (e.g. textures, uniform buffers).
-
IPipeline *pipeline#
The graphics pipeline associated with this material instance, which encapsulates the shader stages and fixed-function state for rendering.
-
EMaterialPass passType#
The material pass type (e.g. opaque, transparent) that this instance belongs to, which determines how it is rendered in the pipeline.
-
IBindGroup *bindGroup#
-
struct GraphicsDeviceCapabilities#
- #include <GraphicsTypes.hpp>
Device capabilities.
Public Members
-
uint64_t maxBufferSize = 0#
-
uint32_t maxTextureDimension2D = 0#
-
uint32_t maxTextureDimension3D = 0#
-
uint32_t maxTextureArrayLayers = 0#
-
uint64_t maxUniformBufferBindingSize = 0#
-
uint64_t maxStorageBufferBindingSize = 0#
-
uint32_t maxColorAttachments = 0#
-
bool supportsCompute = false#
-
bool supportsGeometryShader = false#
-
bool supportsTessellation = false#
-
bool supportsRayTracing = false#
-
bool hasAsyncComputeQueue = false#
Whether the device exposes a dedicated async compute queue.
-
bool hasDedicatedTransferQueue = false#
Whether the device exposes a dedicated transfer/copy queue.
-
bool supportsTimelineFences = false#
Whether the device supports timeline (monotonic) fences.
-
uint32_t graphicsQueueSupportedStates = static_cast<uint32_t>(EResourceState::GenericRead) | static_cast<uint32_t>(EResourceState::RenderTarget) | static_cast<uint32_t>(EResourceState::DepthStencilWrite) | static_cast<uint32_t>(EResourceState::UnorderedAccess) | static_cast<uint32_t>(EResourceState::CopyDestination)#
Bitmask of EResourceState values supported for transitions on the graphics queue. Graphics queues typically support all states.
-
uint32_t computeQueueSupportedStates = static_cast<uint32_t>(EResourceState::NonPixelShaderAccess) | static_cast<uint32_t>(EResourceState::UnorderedAccess) | static_cast<uint32_t>(EResourceState::CopySource) | static_cast<uint32_t>(EResourceState::CopyDestination)#
Bitmask of EResourceState values supported for transitions on the compute queue. Compute queues cannot transition pixel-shader-related or render-target states.
-
uint32_t transferQueueSupportedStates = static_cast<uint32_t>(EResourceState::CopySource) | static_cast<uint32_t>(EResourceState::CopyDestination)#
Bitmask of EResourceState values supported for transitions on the transfer queue. Transfer queues can only handle copy states.
-
uint64_t maxBufferSize = 0#
-
struct GraphicsPassData#
- #include <GraphicsResources.hpp>
Common data for a simple graphics pass with color and depth.
Public Functions
-
inline RenderPassDescriptor BuildDescriptor(IRenderContext *ctx) const#
Helper to build a RenderPassDescriptor from this data.
Public Members
-
uint32_t depthTarget = 0#
Depth/stencil attachment resource ID (optional)
-
ClearColorValue clearColor = {0.0f, 0.0f, 0.0f, 1.0f}#
Clear color value.
-
float clearDepth = 1.0f#
Clear depth value.
-
inline RenderPassDescriptor BuildDescriptor(IRenderContext *ctx) const#
-
struct GraphicsPipelineDescriptor#
- #include <PipelineDescriptor.hpp>
Complete descriptor for creating a graphics pipeline.
This encompasses all fixed-function and programmable state required to create a GPU graphics pipeline state object. Fields have sensible defaults so that a minimal configuration (vertex + fragment shaders, one color target format) is sufficient to produce a working pipeline.
Public Members
-
PipelineShaderStage vertexStage#
Vertex shader stage (required)
-
PipelineShaderStage fragmentStage#
Fragment shader stage (required for rasterization pipelines)
-
std::vector<VertexBufferLayout> vertexBufferLayouts#
Vertex buffer layouts describing the vertex input state.
-
PrimitiveState primitive#
-
DepthStencilState depthStencil#
-
MultisampleState multisample#
-
std::vector<ColorTargetState> colorTargets#
Color targets that the fragment shader writes to. At least one is required for a rasterization pipeline.
-
std::array<IBindGroupLayout*, MAX_BIND_GROUPS> bindGroupLayouts = {}#
Bind group layouts that this pipeline uses. Index in the array corresponds to the set/group number (0-based). Null entries are allowed and indicate unused groups.
-
uint32_t bindGroupLayoutCount = 0#
Number of bind group layouts actually used (starting from index 0). Entries beyond this count are ignored even if non-null.
-
std::string debugName#
Optional debug name for the pipeline.
-
PipelineShaderStage vertexStage#
-
struct GraphicsPipelineResource#
- #include <GraphicsResources.hpp>
Graphics pipeline resource for RenderGraph Owns the graphics pipeline lifetime so client code does not need to manage it.
Public Types
-
using Descriptor = GraphicsPipelineDescriptor#
Public Functions
-
inline IGraphicsPipeline *Get() const#
Get the underlying graphics pipeline (convenience accessor)
-
inline bool IsValid() const#
Check if the resource is valid.
-
void CreateResource(const GraphicsPipelineDescriptor &pipelineDescriptor, IGraphicsDevice *device)#
-
void DestroyResource(const GraphicsPipelineDescriptor &pipelineDescriptor, IGraphicsDevice *device)#
Public Members
-
std::unique_ptr<IGraphicsPipeline> pipeline#
Runtime graphics pipeline handle.
-
GraphicsPipelineDescriptor descriptor#
Resource descriptor.
-
using Descriptor = GraphicsPipelineDescriptor#
-
class IBindGroup#
- #include <IBindGroup.hpp>
Abstract interface for a bind group (set of resource bindings).
Subclassed by Hush::Graphics::WebGPUBindGroup
Public Functions
-
IBindGroup() = default#
-
virtual ~IBindGroup() = default#
-
IBindGroup(const IBindGroup&) = delete#
-
IBindGroup &operator=(const IBindGroup&) = delete#
-
IBindGroup(IBindGroup&&) = delete#
-
IBindGroup &operator=(IBindGroup&&) = delete#
-
virtual IBindGroupLayout *GetLayout() const = 0#
Get the layout this bind group was created from.
-
virtual bool IsValid() const = 0#
Check if the bind group is valid.
-
virtual void *GetNativeHandle() const = 0#
Get the native API handle For WebGPU: wgpu::BindGroup* For Vulkan: VkDescriptorSet*.
-
IBindGroup() = default#
-
class IBindGroupLayout#
- #include <IBindGroup.hpp>
Abstract interface for a bind group layout.
A bind group layout declares the expected shape (binding indices, types, stage visibility) of a set of resource bindings. It is used when creating both pipelines (for validation and driver optimisation) and bind groups (as the template that the group must match).
Subclassed by Hush::Graphics::WebGPUBindGroupLayout
Public Functions
-
IBindGroupLayout() = default#
-
virtual ~IBindGroupLayout() = default#
-
IBindGroupLayout(const IBindGroupLayout&) = delete#
-
IBindGroupLayout &operator=(const IBindGroupLayout&) = delete#
-
IBindGroupLayout(IBindGroupLayout&&) = delete#
-
IBindGroupLayout &operator=(IBindGroupLayout&&) = delete#
-
virtual uint32_t GetEntryCount() const = 0#
Get the number of entries in this layout.
-
virtual bool IsValid() const = 0#
Check if the layout is valid.
-
virtual void *GetNativeHandle() const = 0#
Get the native API handle.
-
IBindGroupLayout() = default#
-
class ICommandList#
- #include <ICommandList.hpp>
Base interface for command lists, which are used to record GPU commands for execution.
Subclassed by Hush::Graphics::ICopyCommandList
Public Functions
-
ICommandList() = default#
-
virtual ~ICommandList() = default#
-
ICommandList(const ICommandList&) = delete#
-
ICommandList &operator=(const ICommandList&) = delete#
-
ICommandList(ICommandList&&) = delete#
-
ICommandList &operator=(ICommandList&&) = delete#
-
virtual void Reset() = 0#
Reset command list for recording.
-
virtual void Close() = 0#
Close command list after recording.
-
virtual void ResourceBarrier(std::span<const ResourceBarrierDescriptor> barriers) = 0#
Record one or more resource state transition barriers.
Transitions move a resource from one GPU usage state to another (e.g. RenderTarget -> ShaderResource). The GPU must not access the resource in the new state until the barrier completes.
- Parameters:
barriers – Array of transition barrier descriptors.
-
virtual void UAVBarrier(std::span<const UAVBarrierDescriptor> barriers) = 0#
Record one or more UAV (Unordered Access View) barriers.
Ensures all previous UAV writes to the specified resource(s) are visible before subsequent UAV reads or writes begin.
- Parameters:
barriers – Array of UAV barrier descriptors.
-
virtual void BeginSplitBarrier(std::span<const SplitBarrierDescriptor> barriers) = 0#
Begin the first half of a split barrier (async transition).
Split barriers allow the GPU to start a resource state transition early and overlap it with other unrelated work, completing it later with EndSplitBarrier(). This can hide transition latency.
Note
Not all backends support split barriers. Implementations that don’t may treat this as a no-op and perform the full transition in EndSplitBarrier() instead.
- Parameters:
barriers – Array of split barrier descriptors to begin.
-
virtual void EndSplitBarrier(std::span<const SplitBarrierDescriptor> barriers) = 0#
Complete the second half of a split barrier.
Must be paired with a prior BeginSplitBarrier() call for the same resource(s). After this call the resource is fully transitioned.
- Parameters:
barriers – Array of split barrier descriptors to end.
-
virtual void *GetNativeHandle() const = 0#
Get native handle (API-specific)
-
ICommandList() = default#
-
class ICommandQueue#
- #include <ICommandQueue.hpp>
Abstract command queue for command submission.
Subclassed by Hush::Graphics::WebGPUCommandQueue
Public Functions
-
ICommandQueue() = default#
-
virtual ~ICommandQueue() = default#
-
ICommandQueue(const ICommandQueue&) = delete#
-
ICommandQueue &operator=(const ICommandQueue&) = delete#
-
ICommandQueue(ICommandQueue&&) = delete#
-
ICommandQueue &operator=(ICommandQueue&&) = delete#
-
virtual EQueueType GetQueueType() const = 0#
Get queue type.
-
virtual void Submit(std::span<ICommandList*> commandLists) = 0#
Submit command lists for execution (simple, no synchronization).
This is the simplest form of submission — no fence waits or signals are associated with the call. Useful for single-queue scenarios or when synchronization is managed externally.
- Parameters:
commandLists – Array of command lists to submit, executed in order.
-
virtual void SubmitBatched(const SubmitInfo &submitInfo) = 0#
Submit a batch of command lists with explicit fence synchronization.
This is the primary submission method used by the render graph executor. It maps to the article’s concept of a command list batch: a group of command lists that share the same set of fence waits (before) and fence signals (after).
The implementation must:
Wait on all fences in submitInfo.waitFences before beginning execution.
Execute all command lists in submitInfo.commandLists, in order.
Signal all fences in submitInfo.signalFences after execution completes.
- Parameters:
submitInfo – Batched submission descriptor containing waits, command lists, and signals.
-
virtual void Signal(IFence *fence, uint64_t value) = 0#
Signal a fence from this queue without submitting any command lists.
Enqueues a GPU-side signal for the given fence to the specified value. The signal will occur after all previously submitted work on this queue has completed.
- Parameters:
fence – The fence to signal.
value – The value to signal the fence to (must be monotonically increasing for timeline fences).
-
virtual void Wait(IFence *fence, uint64_t value) = 0#
Enqueue a GPU-side wait on a fence before any subsequent work.
All command lists submitted after this call will not begin execution until the fence reaches the specified value. This is a GPU-side wait only — it does not block the CPU.
- Parameters:
fence – The fence to wait on.
value – The value the fence must reach before the wait is satisfied.
-
virtual void WaitIdle() = 0#
Wait for all commands on this queue to complete (CPU-side stall).
Blocks the calling thread until the GPU has finished executing all previously submitted command lists on this queue.
-
virtual void *GetNativeHandle() const = 0#
Get native handle (API-specific)
-
ICommandQueue() = default#
-
class IComputeCommandList : public Hush::Graphics::ICopyCommandList#
- #include <ICommandList.hpp>
Command list interface for compute operations.
Compute command lists can also record copy commands.
Subclassed by Hush::Graphics::IGraphicsCommandList, Hush::Graphics::WebGPUComputeCommandList
Public Functions
-
IComputeCommandList() = default#
-
~IComputeCommandList() override = default#
-
IComputeCommandList(const IComputeCommandList&) = delete#
-
IComputeCommandList &operator=(const IComputeCommandList&) = delete#
-
IComputeCommandList(IComputeCommandList&&) = delete#
-
IComputeCommandList &operator=(IComputeCommandList&&) = delete#
-
virtual void Dispatch(uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ) = 0#
Record a compute dispatch command.
-
virtual void DispatchIndirect(IGraphicsBuffer *indirectArgsBuffer, uint64_t offset) = 0#
Record a compute dispatch indirect command.
-
virtual void BindComputePipeline(IComputePipeline *pipeline) = 0#
Bind a compute pipeline for subsequent dispatch calls.
- Parameters:
pipeline – The compute pipeline to bind (must be a valid IComputePipeline).
-
virtual void SetComputeBindGroup(uint32_t groupIndex, IBindGroup *bindGroup, std::span<const uint32_t> dynamicOffsets = {}) = 0#
Set a bind group at the given group/set index for compute operations.
The bind group must conform to the layout declared at that index in the currently bound compute pipeline’s descriptor.
- Parameters:
groupIndex – The group/set index (0-based, corresponds to @group(N) in WGSL).
bindGroup – The bind group to set.
dynamicOffsets – Optional dynamic offsets for dynamic uniform/storage buffer bindings.
-
ICopyCommandList() = default#
-
ICopyCommandList(const ICopyCommandList&) = delete#
-
ICopyCommandList(ICopyCommandList&&) = delete#
-
IComputeCommandList() = default#
-
class IComputePipeline : public Hush::Graphics::IPipeline#
- #include <IPipeline.hpp>
Interface for a compiled compute pipeline.
A compute pipeline combines:
A single compute shader stage
Bind group layouts (resource binding signature)
Compute pipelines are bound before Dispatch() / DispatchIndirect() calls on a compute or graphics command list.
Subclassed by Hush::Graphics::WebGPUComputePipeline
Public Functions
-
IComputePipeline() = default#
-
~IComputePipeline() override = default#
-
IComputePipeline(const IComputePipeline&) = delete#
-
IComputePipeline &operator=(const IComputePipeline&) = delete#
-
IComputePipeline(IComputePipeline&&) = delete#
-
IComputePipeline &operator=(IComputePipeline&&) = delete#
-
inline virtual EPipelineType GetType() const override#
Always returns EPipelineType::Compute.
-
class ICopyCommandList : public Hush::Graphics::ICommandList#
- #include <ICommandList.hpp>
Command list interface for copy/transfer operations.
Subclassed by Hush::Graphics::IComputeCommandList, Hush::Graphics::WebGPUCopyCommandList
Public Functions
-
ICopyCommandList() = default#
-
~ICopyCommandList() override = default#
-
ICopyCommandList(const ICopyCommandList&) = delete#
-
ICopyCommandList &operator=(const ICopyCommandList&) = delete#
-
ICopyCommandList(ICopyCommandList&&) = delete#
-
ICopyCommandList &operator=(ICopyCommandList&&) = delete#
-
virtual void CopyBuffer(IGraphicsBuffer *src, uint64_t srcOffset, IGraphicsBuffer *dst, uint64_t dstOffset, uint64_t size) = 0#
Record a buffer-to-buffer copy command.
-
virtual void CopyBufferToTexture(IGraphicsBuffer *src, uint64_t srcOffset, IGraphicsTexture *dst, uint32_t dstX, uint32_t dstY, uint32_t dstZ, uint32_t width, uint32_t height, uint32_t depth, uint32_t rowPitch) = 0#
Record a buffer-to-texture copy command.
- Parameters:
rowPitch – Byte stride between consecutive rows in the source buffer (must be aligned to 256).
-
virtual void CopyTextureToBuffer(IGraphicsTexture *src, uint32_t srcX, uint32_t srcY, uint32_t srcZ, IGraphicsBuffer *dst, uint64_t dstOffset, uint32_t width, uint32_t height, uint32_t depth) = 0#
Record a texture-to-buffer copy command.
-
virtual void CopyTexture(IGraphicsTexture *src, uint32_t srcX, uint32_t srcY, uint32_t srcZ, IGraphicsTexture *dst, uint32_t dstX, uint32_t dstY, uint32_t dstZ, uint32_t width, uint32_t height, uint32_t depth) = 0#
Record a texture-to-texture copy command.
-
ICopyCommandList() = default#
-
class IFence#
- #include <IFence.hpp>
Abstract fence interface for GPU synchronization.
A fence is a synchronization primitive used to coordinate work between the CPU and GPU, or between different GPU queues. This interface models a timeline fence (also known as a monotonic fence), where the fence holds a monotonically increasing uint64 value.
Timeline fences are the foundation of the render graph’s cross-queue synchronization scheme described by the SSIS (Sufficient Synchronization Index Set) algorithm:
A queue signals the fence to a specific value after completing work.
Another queue waits on the fence until it reaches a required value.
Each queue in the render graph owns one timeline fence. When the graph’s execution encounters a cross-queue dependency it inserts a Signal on the producing queue and a Wait on the consuming queue for the same fence value.
Note
On APIs that only support binary fences/semaphores (e.g. WebGPU), the backend implementation may emulate timeline behavior by chaining binary primitives or falling back to queue-level waits.
Subclassed by Hush::Graphics::WebGPUFence
Public Functions
-
IFence() = default#
-
virtual ~IFence() = default#
-
virtual uint64_t GetCompletedValue() const = 0#
Get the last value that was signaled (completed) by the GPU.
This is a non-blocking query. The returned value may lag behind the most recently requested signal if the GPU has not caught up yet.
- Returns:
The most recent completed fence value.
-
virtual uint64_t GetPendingValue() const = 0#
Get the last value that was requested to be signaled.
This tracks the highest value passed to Signal() or to a queue submission that references this fence, regardless of whether the GPU has completed it yet.
- Returns:
The most recent pending (or completed) signal value.
-
virtual bool WaitCPU(uint64_t value, uint64_t timeoutNs = std::numeric_limits<uint64_t>::max()) = 0#
Block the calling CPU thread until the fence reaches the specified value or the timeout expires.
- Parameters:
value – The fence value to wait for.
timeoutNs – Maximum time to wait in nanoseconds. Use UINT64_MAX for an infinite wait.
- Returns:
true if the fence reached the requested value before the timeout, false on timeout.
-
virtual void SignalCPU(uint64_t value) = 0#
Signal the fence to a specific value from the CPU.
This is rarely needed in normal render-graph operation (GPU-side signals via queue submission are preferred), but useful for:
Initial fence setup
Forcing completion from the CPU (e.g. during shutdown)
- Parameters:
value – The value to signal. Must be greater than the current completed value (timeline fences are monotonic).
-
virtual void *GetNativeHandle() const = 0#
Get the native API handle for this fence.
D3D12:
ID3D12Fence*Vulkan:
VkSemaphore(timeline semaphore)Metal:
id<MTLSharedEvent>WebGPU: implementation-defined or nullptr
- Returns:
Opaque pointer to the native fence object.
Public Static Attributes
-
static constexpr uint64_t INVALID_FENCE_VALUE = std::numeric_limits<uint64_t>::max()#
Sentinel value representing an invalid / uninitialized fence value.
-
class IGraphicsBuffer#
- #include <IGraphicsBuffer.hpp>
Abstract buffer interface.
Subclassed by Hush::Graphics::WebGPUBuffer
Public Functions
-
IGraphicsBuffer() = default#
-
virtual ~IGraphicsBuffer() = default#
-
IGraphicsBuffer(const IGraphicsBuffer&) = delete#
-
IGraphicsBuffer &operator=(const IGraphicsBuffer&) = delete#
-
IGraphicsBuffer(IGraphicsBuffer&&) = delete#
-
IGraphicsBuffer &operator=(IGraphicsBuffer&&) = delete#
-
virtual uint64_t GetSize() const = 0#
Get buffer size in bytes.
-
virtual EBufferUsage GetUsage() const = 0#
Get buffer usage flags.
-
virtual void *Map(IGraphicsDevice *device) = 0#
Map buffer for CPU access (if supported)
- Parameters:
device – Non-owning pointer to the graphics device (may be needed for some APIs to perform the mapping)
- Returns:
Pointer to mapped memory, or nullptr if mapping failed
-
virtual void Unmap() = 0#
Unmap buffer.
-
virtual void *GetNativeHandle() const = 0#
Get native handle (API-specific)
-
IGraphicsBuffer() = default#
-
class IGraphicsCommandList : public Hush::Graphics::IComputeCommandList#
- #include <ICommandList.hpp>
Command list interface for graphics operations.
This is the most feature-rich command list type, supporting all graphics commands as well as compute and copy commands.
Subclassed by Hush::Graphics::WebGPUGraphicsCommandList
Public Functions
-
IGraphicsCommandList() = default#
-
~IGraphicsCommandList() override = default#
-
IGraphicsCommandList(const IGraphicsCommandList&) = delete#
-
IGraphicsCommandList &operator=(const IGraphicsCommandList&) = delete#
-
IGraphicsCommandList(IGraphicsCommandList&&) = delete#
-
IGraphicsCommandList &operator=(IGraphicsCommandList&&) = delete#
-
virtual void Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) = 0#
Record a draw command.
- Parameters:
vertexCount – Number of vertices to draw
instanceCount – Number of instances to draw
firstVertex – Index of the first vertex
firstInstance – Index of the first instance
-
virtual void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) = 0#
Record an indexed draw command.
- Parameters:
indexCount – Number of indices to draw
instanceCount – Number of instances to draw
firstIndex – Index of the first index
vertexOffset – Value added to each index before fetching vertex data
firstInstance – Index of the first instance
-
virtual void DrawIndirect(IGraphicsBuffer *indirectArgsBuffer, uint64_t offset) = 0#
Record an indirect draw command.
- Parameters:
indirectArgsBuffer – Buffer containing draw arguments (must be created with indirect usage flag)
offset – Byte offset into the buffer where draw arguments start
-
virtual void DrawIndexedIndirect(IGraphicsBuffer *indirectArgsBuffer, uint64_t offset) = 0#
Record an indexed indirect draw command.
- Parameters:
indirectArgsBuffer – Buffer containing draw arguments (must be created with indirect usage flag)
offset – Byte offset into the buffer where draw arguments start
-
virtual void SetVertexBuffer(uint32_t slot, IGraphicsBuffer *buffer, uint64_t offset = 0) = 0#
Set vertex buffer.
- Parameters:
slot – Binding slot for the vertex buffer
buffer – Vertex buffer to bind
offset – Byte offset into the buffer
-
virtual void SetIndexBuffer(IGraphicsBuffer *buffer, uint64_t offset = 0) = 0#
Set index buffer.
- Parameters:
buffer – Index buffer to bind
offset – Byte offset into the buffer
-
virtual void SetViewport(float x, float y, float width, float height, float minDepth, float maxDepth) = 0#
Set viewport.
- Parameters:
x – Top-left x coordinate of the viewport
y – Top-left y coordinate of the viewport
width – Width of the viewport
height – Height of the viewport
minDepth – Minimum depth value (0.0 to 1.0)
maxDepth – Maximum depth value (0.0 to 1.0)
-
virtual void SetScissor(int32_t x, int32_t y, uint32_t width, uint32_t height) = 0#
Set scissor rectangle.
- Parameters:
x – Top-left x coordinate of the scissor rectangle
y – Top-left y coordinate of the scissor rectangle
width – Width of the scissor rectangle
height – Height of the scissor rectangle
-
virtual void BeginRenderPass(const RenderPassDescriptor &descriptor) = 0#
Begin render pass with descriptor (WebGPU-style)
- Parameters:
descriptor – Render pass configuration describing color and depth/stencil attachments
-
virtual void EndRenderPass() = 0#
End render pass.
-
virtual void BindPipeline(IPipeline *pipeline) = 0#
Bind graphics pipeline.
- Parameters:
pipeline – Pipeline to bind (must be a graphics pipeline compatible with the current render pass)
-
virtual void SetBindGroup(uint32_t groupIndex, IBindGroup *bindGroup, std::span<const uint32_t> dynamicOffsets = {}) = 0#
Set a bind group at the given group/set index for graphics operations.
The bind group must conform to the layout declared at that index in the currently bound graphics pipeline’s descriptor.
In WebGPU terms this corresponds to setBindGroup on the render pass encoder. In Vulkan terms this maps to vkCmdBindDescriptorSets.
- Parameters:
groupIndex – The group/set index (0-based, corresponds to @group(N) in WGSL / set = N in Vulkan / space N in D3D12).
bindGroup – The bind group to set.
dynamicOffsets – Optional dynamic offsets for dynamic uniform/storage buffer bindings within the bind group.
-
IComputeCommandList() = default#
-
IComputeCommandList(const IComputeCommandList&) = delete#
-
IComputeCommandList(IComputeCommandList&&) = delete#
-
IGraphicsCommandList() = default#
-
class IGraphicsDevice#
- #include <IGraphicsDevice.hpp>
Abstract graphics device interface Provides a unified API for creating resources and submitting commands.
Subclassed by Hush::Graphics::WebGPUGraphicsDevice
Public Functions
-
IGraphicsDevice() noexcept = default#
-
virtual ~IGraphicsDevice() = default#
-
IGraphicsDevice(const IGraphicsDevice&) = delete#
-
IGraphicsDevice &operator=(const IGraphicsDevice&) = delete#
-
IGraphicsDevice(IGraphicsDevice&&) = delete#
-
IGraphicsDevice &operator=(IGraphicsDevice&&) = delete#
-
virtual EGraphicsAPI GetAPI() const = 0#
Get the graphics API backend.
-
virtual GraphicsDeviceCapabilities GetCapabilities() const = 0#
Get device capabilities.
-
virtual bool IsInitialized() const = 0#
Check if device is initialized.
-
virtual std::unique_ptr<IGraphicsBuffer> CreateBuffer(const BufferDescriptor &descriptor) = 0#
Create a buffer.
- Parameters:
descriptor – Buffer creation parameters
- Returns:
Created buffer, or nullptr on failure
-
virtual void WriteBuffer(IGraphicsBuffer *buffer, uint64_t offset, const void *data, uint64_t size) = 0#
Write data from the CPU into a GPU buffer.
This is the primary mechanism for uploading uniform data, vertex data, or any other CPU-side payload into a GPU buffer. The buffer must have been created with appropriate usage flags (e.g. EBufferUsage::Uniform with EMemoryAccess::CPUWrite).
On WebGPU this maps to wgpu::Queue::writeBuffer(). On Vulkan/D3D12 this maps to a staging upload or direct map+copy.
- Parameters:
buffer – The destination GPU buffer.
offset – Byte offset into the buffer to start writing at.
data – Pointer to the source CPU data.
size – Number of bytes to write.
-
virtual std::unique_ptr<IGraphicsTexture> CreateTexture(const TextureDescriptor &descriptor) = 0#
Create a texture.
- Parameters:
descriptor – Texture creation parameters
- Returns:
Created texture, or nullptr on failure
-
virtual std::unique_ptr<ISampler> CreateSampler(const SamplerDescriptor &descriptor) = 0#
Create a sampler object.
Samplers control how textures are sampled in shaders: filtering modes, address (wrap) modes, LOD clamping, comparison function, and anisotropy. Samplers are immutable once created.
- Parameters:
descriptor – Sampler creation parameters.
- Returns:
Created sampler, or nullptr on failure.
-
virtual std::unique_ptr<IShaderModule> CreateShaderModule(const ShaderModuleDescriptor &descriptor) = 0#
Create a shader module from compiled bytecode or source text.
The descriptor should contain either binary bytecode (SPIR-V, DXIL) or source text (WGSL) depending on the backend, as produced by the Slang-based ShaderCompiler.
- Parameters:
descriptor – Shader module creation parameters (stage, entry point, bytecode/source).
- Returns:
Created shader module, or nullptr on failure.
-
virtual std::unique_ptr<IGraphicsPipeline> CreateGraphicsPipeline(const GraphicsPipelineDescriptor &descriptor) = 0#
Create a graphics (rasterization) pipeline.
The descriptor must reference valid shader modules (vertex + fragment) and at least one color target. Shader modules must have been created by this same device.
- Parameters:
descriptor – Graphics pipeline creation parameters.
- Returns:
Created pipeline, or nullptr on failure.
-
virtual std::unique_ptr<IComputePipeline> CreateComputePipeline(const ComputePipelineDescriptor &descriptor) = 0#
Create a compute pipeline.
The descriptor must reference a valid compute shader module created by this same device.
- Parameters:
descriptor – Compute pipeline creation parameters.
- Returns:
Created pipeline, or nullptr on failure.
-
virtual std::unique_ptr<IBindGroupLayout> CreateBindGroupLayout(const BindGroupLayoutDescriptor &descriptor) = 0#
Create a bind group layout.
A bind group layout declares the expected shape (binding indices, resource types, shader stage visibility) of a set of resource bindings. Layouts are used at pipeline creation time and when creating bind group instances.
- Parameters:
descriptor – Bind group layout creation parameters.
- Returns:
Created bind group layout, or nullptr on failure.
-
virtual std::unique_ptr<IBindGroup> CreateBindGroup(const BindGroupDescriptor &descriptor) = 0#
Create a bind group (a concrete set of resource bindings).
A bind group is an immutable collection of buffer, texture, and sampler bindings that can be set on a command list before draw or dispatch calls. It must conform to the layout specified in the descriptor.
- Parameters:
descriptor – Bind group creation parameters (layout + entries).
- Returns:
Created bind group, or nullptr on failure.
-
virtual std::unique_ptr<ICopyCommandList> CreateCopyCommandList() = 0#
Create a copy command list.
- Returns:
Created command list, or nullptr on failure
-
virtual std::unique_ptr<IComputeCommandList> CreateComputeCommandList() = 0#
Create a compute command list.
- Returns:
Created command list, or nullptr on failure
-
virtual std::unique_ptr<IGraphicsCommandList> CreateGraphicsCommandList() = 0#
Create a graphics command list.
- Returns:
Created command list, or nullptr on failure
-
virtual std::unique_ptr<IFence> CreateFence(uint64_t initialValue = 0) = 0#
Create a timeline fence for cross-queue GPU synchronization.
Timeline fences hold a monotonically increasing uint64 value. Queues can signal the fence to a value after completing work, and other queues (or the CPU) can wait until the fence reaches a required value.
The render graph creates one fence per queue and uses the SSIS algorithm to determine the minimal set of signal/wait pairs needed to respect cross-queue dependencies.
- Parameters:
initialValue – The starting value of the fence (typically 0).
- Returns:
Created fence, or nullptr on failure.
-
virtual ICommandQueue *GetGraphicsQueue() = 0#
Get the main graphics queue.
Note
This might return the same queue as GetComputeQueue or GetTransferQueue if the API doesn’t support separate queues Which is the case for WebGPU. To check if separate queues are supported, use the capabilities struct.
-
virtual ICommandQueue *GetComputeQueue() = 0#
Get a compute queue.
On backends that don’t expose multiple queues (e.g. WebGPU), this will return the same queue as GetGraphicsQueue().
-
virtual ICommandQueue *GetTransferQueue() = 0#
Get a transfer queue.
On backends that don’t expose multiple queues (e.g. WebGPU), this will return the same queue as GetGraphicsQueue().
-
inline virtual ICommandQueue *GetQueueForType(EQueueType type)#
Get a command queue by queue type.
Convenience method used by the render graph to map EPassType / queue index to the corresponding queue. Backends that share a single queue for multiple types (e.g. WebGPU) may return the same pointer for different queue types.
- Parameters:
type – The queue type to retrieve.
- Returns:
Pointer to the requested queue, never nullptr (falls back to the graphics queue if the requested type is not available).
-
inline virtual uint32_t MapPassTypeToQueueIndex(EQueueType passType) const#
Map a render-graph pass type to the physical queue index used by this device.
The render graph assigns each pass a queue index that drives dependency detection, SSIS culling, fence allocation, and execution plan generation. On multi-queue backends (D3D12, Vulkan) the default mapping is a 1:1 correspondence with EPassType ordinal values (Graphics=0, Compute=1, Transfer=2).
Single-queue backends (WebGPU) should override this to collapse all pass types onto queue index 0, which eliminates unnecessary cross-queue synchronisation, fence pairs, and execution plans.
- Parameters:
passType – The logical pass type declared by the user.
- Returns:
The physical queue index to use in the render graph.
-
inline virtual uint32_t GetQueueSupportedStates(EQueueType type) const#
Get the bitmask of EResourceState values that the given queue type can transition resources to.
This is used by the render graph’s transition rerouting logic to determine the “most competent queue” — the queue capable of performing a required state transition. When a receiving queue cannot perform a transition (e.g. compute queue cannot transition to PixelShaderAccess), the transition is rerouted to the most competent queue (usually graphics).
- Parameters:
type – The queue type to query.
- Returns:
Bitmask of supported EResourceState values for transitions.
-
virtual void BeginFrame() = 0#
Begin a new frame.
- Returns:
Swapchain texture handle, or nullptr on failure
-
virtual void EndFrame() = 0#
End frame and present.
-
virtual IGraphicsTexture *GetCurrentFrameTexture() const = 0#
Get the current frame’s swapchain texture.
-
virtual void Resize(uint32_t width, uint32_t height) = 0#
Resize the swapchain.
- Parameters:
width – New width
height – New height
-
virtual void AddToDeletionQueue(std::function<void()> &&deleteFunc) = 0#
Add a function to the deletion queue for deferred cleanup.
- Parameters:
deleteFunc – Deletion function
-
virtual void FlushDeletionQueue() = 0#
Flush deletion queue.
-
virtual void *GetNativeHandle() const = 0#
Get native device handle (API-specific)
-
IGraphicsDevice() noexcept = default#
-
class IGraphicsPipeline : public Hush::Graphics::IPipeline#
- #include <IPipeline.hpp>
Interface for a compiled graphics (rasterization) pipeline.
A graphics pipeline combines:
Vertex and fragment shader stages
Vertex input layout (buffer bindings + attribute descriptions)
Primitive topology and rasterizer state
Blend state per color target
Depth/stencil state
Multisample state
Bind group layouts (resource binding signature)
Once created, the pipeline is immutable. To change state you must create a new pipeline. Pipeline creation can be expensive, so applications should cache and reuse pipelines across frames.
Subclassed by Hush::Graphics::WebGPUGraphicsPipeline
Public Functions
-
IGraphicsPipeline() = default#
-
~IGraphicsPipeline() override = default#
-
IGraphicsPipeline(const IGraphicsPipeline&) = delete#
-
IGraphicsPipeline &operator=(const IGraphicsPipeline&) = delete#
-
IGraphicsPipeline(IGraphicsPipeline&&) = delete#
-
IGraphicsPipeline &operator=(IGraphicsPipeline&&) = delete#
-
inline virtual EPipelineType GetType() const override#
Always returns EPipelineType::Graphics.
-
virtual uint32_t GetColorTargetCount() const = 0#
Get the number of color targets this pipeline was created with.
This corresponds to the number of ColorTargetState entries in the GraphicsPipelineDescriptor used at creation time. The render pass that this pipeline is used with must have a matching number of color attachments.
-
virtual bool HasDepthStencil() const = 0#
Returns true if the pipeline was created with depth/stencil state enabled.
When true, the render pass must include a depth/stencil attachment.
-
virtual uint32_t GetVertexBufferSlotCount() const = 0#
Get the number of vertex buffer slots this pipeline expects.
Corresponds to the number of VertexBufferLayout entries in the descriptor. Before a draw call, the application must bind at least this many vertex buffers via SetVertexBuffer().
-
class IGraphicsTexture#
- #include <IGraphicsTexture.hpp>
Abstract texture interface.
Subclassed by Hush::Graphics::WebGPUTexture
Public Functions
-
IGraphicsTexture() = default#
-
virtual ~IGraphicsTexture() = default#
-
IGraphicsTexture(const IGraphicsTexture&) = delete#
-
IGraphicsTexture &operator=(const IGraphicsTexture&) = delete#
-
IGraphicsTexture(IGraphicsTexture&&) = delete#
-
IGraphicsTexture &operator=(IGraphicsTexture&&) = delete#
-
virtual uint32_t GetWidth() const = 0#
Get texture width.
-
virtual uint32_t GetHeight() const = 0#
Get texture height.
-
virtual uint32_t GetDepth() const = 0#
Get texture depth.
-
virtual ETextureFormat GetFormat() const = 0#
Get texture format.
-
virtual uint32_t GetMipLevels() const = 0#
Get mip level count.
-
virtual void *GetNativeHandle() const = 0#
Get native handle (API-specific)
-
IGraphicsTexture() = default#
-
struct ImportedBindGroupLayoutResource#
- #include <GraphicsResources.hpp>
Import/external bind group layout resource for RenderGraph Used when you want to reference an existing bind group layout created outside the graph.
Public Types
-
using Descriptor = BindGroupLayoutDescriptor#
Public Functions
-
inline IBindGroupLayout *Get() const#
Get the underlying bind group layout (convenience accessor)
-
inline bool IsValid() const#
Check if the resource is valid.
-
inline void CreateResource(const BindGroupLayoutDescriptor &layoutDescriptor, IGraphicsDevice *device)#
-
inline void DestroyResource(const BindGroupLayoutDescriptor &layoutDescriptor, IGraphicsDevice *device)#
Public Members
-
IBindGroupLayout *layout = nullptr#
Imported bind group layout handle (non-owning)
-
using Descriptor = BindGroupLayoutDescriptor#
-
struct ImportedBindGroupResource#
- #include <GraphicsResources.hpp>
Import/external bind group resource for RenderGraph Used when you want to reference an existing bind group created outside the graph.
Public Types
-
using Descriptor = BindGroupDescriptor#
Public Functions
-
inline IBindGroup *Get() const#
Get the underlying bind group (convenience accessor)
-
inline bool IsValid() const#
Check if the resource is valid.
-
inline void CreateResource(const BindGroupDescriptor &bindGroupDescriptor, IGraphicsDevice *device)#
-
inline void DestroyResource(const BindGroupDescriptor &bindGroupDescriptor, IGraphicsDevice *device)#
Public Members
-
IBindGroup *bindGroup = nullptr#
Imported bind group handle (non-owning)
-
using Descriptor = BindGroupDescriptor#
-
struct ImportedBufferResource#
- #include <GraphicsResources.hpp>
Import/external buffer resource for RenderGraph Used when you want to reference an existing buffer created outside the graph.
Public Types
-
using Descriptor = BufferDescriptor#
Public Functions
-
inline IGraphicsBuffer *Get() const#
Get the underlying buffer (convenience accessor)
-
inline bool IsValid() const#
Check if the resource is valid.
-
inline void CreateResource(const BufferDescriptor &bufferDescriptor, IGraphicsDevice *device)#
-
inline void DestroyResource(const BufferDescriptor &bufferDescriptor, IGraphicsDevice *device)#
Public Members
-
IGraphicsBuffer *buffer = nullptr#
Imported buffer handle.
-
using Descriptor = BufferDescriptor#
-
struct ImportedGraphicsPipelineResource#
- #include <GraphicsResources.hpp>
Import/external graphics pipeline resource for RenderGraph Used when you want to reference an existing graphics pipeline created outside the graph.
Public Types
-
using Descriptor = GraphicsPipelineDescriptor#
Public Functions
-
inline IGraphicsPipeline *Get() const#
Get the underlying graphics pipeline (convenience accessor)
-
inline bool IsValid() const#
Check if the resource is valid.
-
inline void CreateResource(const GraphicsPipelineDescriptor &pipelineDescriptor, IGraphicsDevice *device)#
-
inline void DestroyResource(const GraphicsPipelineDescriptor &pipelineDescriptor, IGraphicsDevice *device)#
Public Members
-
IGraphicsPipeline *pipeline = nullptr#
Imported graphics pipeline handle (non-owning)
-
using Descriptor = GraphicsPipelineDescriptor#
-
struct ImportedSamplerResource#
- #include <GraphicsResources.hpp>
Import/external sampler resource for RenderGraph Used when you want to reference an existing sampler created outside the graph.
Public Types
-
using Descriptor = SamplerDescriptor#
Public Functions
-
inline bool IsValid() const#
Check if the resource is valid.
-
inline void CreateResource(const SamplerDescriptor &samplerDescriptor, IGraphicsDevice *device)#
-
inline void DestroyResource(const SamplerDescriptor &samplerDescriptor, IGraphicsDevice *device)#
-
using Descriptor = SamplerDescriptor#
-
struct ImportedShaderResource#
- #include <GraphicsResources.hpp>
Import/external shader module resource for RenderGraph Used when you want to reference an existing shader module created outside the graph.
Public Types
-
using Descriptor = ShaderModuleDescriptor#
Public Functions
-
inline IShaderModule *Get() const#
Get the underlying shader module (convenience accessor)
-
inline bool IsValid() const#
Check if the resource is valid.
-
inline void CreateResource(const ShaderModuleDescriptor &shaderDescriptor, IGraphicsDevice *device)#
-
inline void DestroyResource(const ShaderModuleDescriptor &shaderDescriptor, IGraphicsDevice *device)#
Public Members
-
IShaderModule *shaderModule = nullptr#
Imported shader module handle (non-owning)
-
using Descriptor = ShaderModuleDescriptor#
-
struct ImportedTextureResource#
- #include <GraphicsResources.hpp>
Import/external texture resource for RenderGraph Used when you want to reference an existing texture created outside the graph.
Public Types
-
using Descriptor = TextureDescriptor#
Public Functions
-
inline IGraphicsTexture *Get() const#
Get the underlying texture (convenience accessor)
-
inline bool IsValid() const#
Check if the resource is valid.
-
inline void CreateResource(const TextureDescriptor &textureDescriptor, IGraphicsDevice *device)#
-
inline void DestroyResource(const TextureDescriptor &textureDescriptor, IGraphicsDevice *device)#
Public Members
-
IGraphicsTexture *texture = nullptr#
Imported texture handle.
-
using Descriptor = TextureDescriptor#
-
class IPipeline#
- #include <IPipeline.hpp>
Abstract base interface for all GPU pipeline state objects.
This is the type accepted by IGraphicsCommandList::BindPipeline(). Callers can query the pipeline type to determine whether it is a graphics or compute pipeline, and down-cast if needed.
Subclassed by Hush::Graphics::IComputePipeline, Hush::Graphics::IGraphicsPipeline
Public Functions
-
IPipeline() = default#
-
virtual ~IPipeline() = default#
-
virtual EPipelineType GetType() const = 0#
Get the type of this pipeline (graphics or compute).
-
inline bool IsGraphics() const#
Convenience: returns true if this is a graphics pipeline.
-
inline bool IsCompute() const#
Convenience: returns true if this is a compute pipeline.
-
virtual bool IsValid() const = 0#
Check if the pipeline was created successfully and is usable.
A pipeline that failed creation (e.g. shader compilation error, incompatible state) will return false.
-
virtual std::string_view GetDebugName() const = 0#
Get the debug name assigned at creation time.
Returns an empty string_view if no debug name was provided.
-
virtual void *GetNativeHandle() const = 0#
Get the native API handle for the pipeline.
The returned pointer’s type depends on the backend:
WebGPU graphics: wgpu::RenderPipeline*
WebGPU compute: wgpu::ComputePipeline*
Vulkan: VkPipeline*
D3D12: ID3D12PipelineState*
Ownership is NOT transferred; the pipeline object retains ownership.
-
IPipeline() = default#
-
class IRenderContext#
- #include <GraphicsResources.hpp>
Render execution context provided to passes during Execute phase This interface provides access to command lists and resource resolution.
Public Functions
-
virtual ~IRenderContext() = default#
-
IRenderContext(const IRenderContext&) = delete#
-
IRenderContext &operator=(const IRenderContext&) = delete#
-
IRenderContext(IRenderContext&&) = delete#
-
IRenderContext &operator=(IRenderContext&&) = delete#
-
virtual IGraphicsCommandList *GetGraphicsCommandList() = 0#
Get graphics command list for the current pass.
-
virtual IComputeCommandList *GetComputeCommandList() = 0#
Get compute command list for the current pass.
-
virtual ICopyCommandList *GetCopyCommandList() = 0#
Get transfer/copy command list for the current pass.
-
virtual IGraphicsTexture *GetTexture(uint32_t resourceId) = 0#
Resolve a resource ID to a texture.
- Parameters:
resourceId – Resource ID from the render graph
- Returns:
Texture pointer, or nullptr if not found or wrong type
-
virtual IGraphicsBuffer *GetBuffer(uint32_t resourceId) = 0#
Resolve a resource ID to a buffer.
- Parameters:
resourceId – Resource ID from the render graph
- Returns:
Buffer pointer, or nullptr if not found or wrong type
-
virtual IGraphicsDevice *GetDevice() = 0#
Get the graphics device for resource creation or queries.
-
virtual uint32_t GetFrameIndex() const = 0#
Get current frame index (for double/triple buffering)
-
virtual IGraphicsTexture *GetSwapchainTexture() = 0#
Get swapchain texture for presenting (if available)
-
virtual ~IRenderContext() = default#
-
class ISampler#
- #include <ISampler.hpp>
Abstract sampler interface.
Represents a GPU sampler object that controls how textures are sampled (filtering, addressing, LOD clamping, comparison).
Samplers are immutable once created — create a new sampler if you need different parameters.
Subclassed by Hush::Graphics::WebGPUSampler
Public Functions
-
ISampler() = default#
-
virtual ~ISampler() = default#
-
virtual EFilterMode GetMagFilter() const = 0#
Get the magnification filter mode.
-
virtual EFilterMode GetMinFilter() const = 0#
Get the minification filter mode.
-
virtual EFilterMode GetMipmapFilter() const = 0#
Get the mip-map filter mode.
-
virtual EAddressMode GetAddressModeU() const = 0#
Get the address mode for the U axis.
-
virtual EAddressMode GetAddressModeV() const = 0#
Get the address mode for the V axis.
-
virtual EAddressMode GetAddressModeW() const = 0#
Get the address mode for the W axis.
-
virtual ECompareFunction GetCompareFunction() const = 0#
Get the comparison function (Undefined if not a comparison sampler).
-
inline bool IsComparisonSampler() const#
Check whether this is a comparison sampler.
-
virtual uint16_t GetMaxAnisotropy() const = 0#
Get the maximum anisotropy level.
-
virtual void *GetNativeHandle() const = 0#
Get the native API handle.
-
ISampler() = default#
-
class IShaderModule#
- #include <IShaderModule.hpp>
Abstract interface for a compiled shader module.
Represents a single shader stage that has been compiled and is ready to be used in pipeline creation. The underlying representation is backend-specific (e.g. wgpu::ShaderModule for WebGPU, VkShaderModule for Vulkan).
Subclassed by Hush::Graphics::WebGPUShaderModule
Public Functions
-
IShaderModule() = default#
-
virtual ~IShaderModule() = default#
-
IShaderModule(const IShaderModule&) = delete#
-
IShaderModule &operator=(const IShaderModule&) = delete#
-
IShaderModule(IShaderModule&&) = delete#
-
IShaderModule &operator=(IShaderModule&&) = delete#
-
virtual EShaderStage GetStage() const = 0#
Get the shader stage this module was compiled for.
-
virtual std::string_view GetEntryPoint() const = 0#
Get the entry point name.
-
virtual bool IsValid() const = 0#
Check if the module is valid and usable.
-
virtual void *GetNativeHandle() const = 0#
Get the native API handle For WebGPU: wgpu::ShaderModule* For Vulkan: VkShaderModule*.
-
IShaderModule() = default#
-
class Material3D#
- #include <Material3D.hpp>
High-level material class that abstracts away the underlying graphics API and shader details.
Public Types
-
enum class EError#
Values:
-
enumerator None#
-
enumerator NullDevice#
-
enumerator NullShaderModule#
-
enumerator InvalidShaderModule#
-
enumerator BindGroupLayoutCreationFailed#
-
enumerator UniformBufferCreationFailed#
-
enumerator BindGroupCreationFailed#
-
enumerator PipelineCreationFailed#
-
enumerator PropertyNotFound#
-
enumerator None#
Public Functions
-
Material3D() = default#
-
~Material3D() = default#
-
Material3D(const Material3D&) = delete#
-
Material3D &operator=(const Material3D&) = delete#
-
Material3D(Material3D&&) noexcept = default#
-
Material3D &operator=(Material3D&&) noexcept = default#
-
std::optional<EError> Init(IGraphicsDevice *device, const Material3DDescriptor &descriptor)#
Create all GPU resources (pipeline, bind group layout, uniform buffer, bind group) from pre-compiled shaders.
The descriptor must carry valid, already-compiled IShaderModule pointers and a ShaderCompilationResult with reflection data.
- Parameters:
device – The graphics device to create resources on.
descriptor – Material configuration.
- Returns:
Success on success, or the specific EError on failure.
-
template<typename T>
inline std::optional<EError> SetProperty(std::string_view name, const T &value)# Set a uniform property by name.
The value is written into a CPU-side staging buffer. Call FlushProperties() to upload the data to the GPU before rendering.
- Template Parameters:
T – The type of the property value (must be trivially copyable and match the size declared in the shader).
- Parameters:
name – The property name as declared in the shader’s uniform / constant buffer.
value – The value to set.
- Returns:
Success if the property was found and written, or EError::PropertyNotFound if the name does not exist.
-
void FlushProperties(IGraphicsDevice *device)#
Upload the CPU-side uniform staging buffer to the GPU.
This is a no-op if no properties have been modified since the last flush (or since Init).
- Parameters:
queue – The graphics queue to submit the buffer write command on.
-
template<typename T>
inline std::optional<EError> SetPropertyAndFlush(IGraphicsDevice *device, std::string_view name, const T &value)# Convenience: set a property and immediately flush.
-
void Bind(IGraphicsCommandList *cmdList, uint32_t bindGroupIndex = 0) const#
Bind this material’s pipeline and bind group on the given graphics command list.
Call this inside a render pass, after BeginRenderPass() and before Draw() / DrawIndexed().
- Parameters:
cmdList – The graphics command list to record on.
bindGroupIndex – The group/set index to bind the material’s bind group at (default 0).
-
EAlphaBlendMode GetAlphaBlendMode() const noexcept#
-
void SetAlphaBlendMode(EAlphaBlendMode blendMode) noexcept#
-
EMaterialPass GetMaterialPass() const noexcept#
-
void SetMaterialPass(EMaterialPass pass) noexcept#
-
GraphicsApiMaterialInstance *GetInternalMaterial() noexcept#
Returns the low-level material instance holding the pipeline and bind group pointers.
This is used internally by the renderer when it needs to sort or batch draw calls by material.
-
const GraphicsApiMaterialInstance *GetInternalMaterial() const noexcept#
-
void SetName(std::string_view name)#
-
const std::string &GetName() const noexcept#
-
IGraphicsPipeline *GetPipeline() const noexcept#
-
IBindGroup *GetBindGroup() const noexcept#
-
IBindGroupLayout *GetBindGroupLayout() const noexcept#
-
IGraphicsBuffer *GetUniformBuffer() const noexcept#
-
const std::unordered_map<std::string, MaterialPropertyInfo> &GetPropertyMap() const noexcept#
Get the reflected property map.
-
uint64_t GetUniformBufferSize() const noexcept#
Get the total uniform buffer size in bytes.
-
enum class EError#
-
struct Material3DDescriptor#
- #include <Material3D.hpp>
Configuration options for initialising a Material3D.
The caller is responsible for compiling the shader and creating the IShaderModule instances beforehand. Material3D never touches the ShaderCompiler — it only consumes already-compiled outputs.
Public Members
-
IShaderModule *vertexShader = nullptr#
Pre-compiled vertex shader module (non-owning). Must remain valid for the lifetime of the Material3D.
-
IShaderModule *fragmentShader = nullptr#
Pre-compiled fragment shader module (non-owning). Must remain valid for the lifetime of the Material3D.
-
std::string vertexEntry = "vertexMain"#
Vertex shader entry point name.
-
std::string fragmentEntry = "fragmentMain"#
Fragment shader entry point name.
-
const ShaderCompilationResult *compilationResult = nullptr#
Compilation result that carries reflection data (bindings, vertex inputs). The material reads this to build bind group layouts and the uniform property map. Non-owning; must remain valid for the duration of the Init() call (it is not stored).
-
ETextureFormat colorTargetFormat = ETextureFormat::BGRA8_UNORM#
The texture format of the color target this material will render to.
-
bool blendEnabled = false#
Whether blending is enabled for this material’s color target.
-
DepthStencilState depthStencil = {}#
Optional depth/stencil configuration. When enabled the pipeline will be created with depth testing.
-
std::string debugName#
Optional debug name.
-
IShaderModule *vertexShader = nullptr#
-
struct MaterialPropertyInfo#
- #include <Material3D.hpp>
Describes a single uniform property within a material’s uniform buffer. Tracked internally after shader reflection so that SetProperty can write to the correct offset.
-
struct MultisampleState#
- #include <PipelineDescriptor.hpp>
Multisample / anti-aliasing state.
-
struct PipelineShaderStage#
- #include <PipelineDescriptor.hpp>
Describes a shader stage to attach to a pipeline.
Public Functions
-
inline std::string_view GetEffectiveEntryPoint() const#
Returns the effective entry point name.
Public Members
-
std::string entryPoint#
Entry point name within the module When empty, the module’s own entry point name is used.
-
inline std::string_view GetEffectiveEntryPoint() const#
-
struct PrimitiveState#
- #include <PipelineDescriptor.hpp>
Primitive state configuration.
Public Members
-
EPrimitiveTopology topology = EPrimitiveTopology::TriangleList#
-
EIndexFormat stripIndexFormat = EIndexFormat::Undefined#
Only for strip topologies.
-
EFrontFace frontFace = EFrontFace::CounterClockwise#
-
ECullModeFlags cullMode = ECullModeFlags::None#
-
EPrimitiveTopology topology = EPrimitiveTopology::TriangleList#
-
struct ReflectedBinding#
- #include <ShaderCompiler.hpp>
A single reflected resource binding extracted from compiled shaders.
The compiler fills these from Slang’s reflection API so that callers can automatically build BindGroupLayoutDescriptors without manually duplicating the shader’s binding declarations.
Public Members
-
uint32_t set = 0#
The set / group index this binding belongs to.
-
uint32_t binding = 0#
The binding index within the set / group.
-
EBindingType type = EBindingType::UniformBuffer#
The kind of resource.
-
EShaderStageFlags stageFlags = EShaderStageFlags::None#
Which shader stages reference this binding.
-
std::string name#
Debug name (from the shader source)
-
uint64_t bufferSize = 0#
For buffer bindings: minimum required size (0 = unknown)
-
uint32_t set = 0#
-
struct ReflectedVertexInput#
- #include <ShaderCompiler.hpp>
Reflected vertex input attribute extracted from the vertex shader.
Public Members
-
uint32_t location = 0#
Shader location index.
-
std::string semanticName#
Semantic name (if available from HLSL/Slang semantics)
-
EVertexFormat format = EVertexFormat::Float32x4#
Format of the attribute.
-
uint32_t location = 0#
-
class RenderGraphSystem : public Hush::ISystem#
Public Functions
-
RenderGraphSystem(Scene &scene, RenderGraph::RenderDevice *renderDevice)#
Construct the system with a scene and the render device.
- Parameters:
scene – The scene this system belongs to.
renderDevice – Non-owning pointer to the render device that owns the graph, executor, and graphics device reference. Must outlive this system.
-
~RenderGraphSystem() override = default#
-
RenderGraphSystem(const RenderGraphSystem&) = delete#
-
RenderGraphSystem &operator=(const RenderGraphSystem&) = delete#
-
RenderGraphSystem(RenderGraphSystem&&) = delete#
-
RenderGraphSystem &operator=(RenderGraphSystem&&) = delete#
-
virtual void OnShutdown() override#
OnShutdown() is called when the system is shutting down.
-
virtual void OnUpdate(float delta) override#
OnRender() is called when the system should render.
- Parameters:
delta – Time since last frame
-
virtual void OnFixedUpdate(float delta) override#
OnFixedUpdate() is called when the system should update its state.
- Parameters:
delta – Time since last fixed frame
-
virtual void OnPreRender() override#
Begin the frame and prepare the graph for execution.
Takes one of two paths:
Fast path (graph already compiled, all builders have frameUpdateFunc):
BeginFrame — acquires the next swapchain image.
SoftReset — resets only the executor’s per-frame state (fence counters, resource state tracker). Graph topology is preserved.
Per-frame update — invokes each builder’s frameUpdateFunc to update imported resources (e.g. swapchain backbuffer) via RenderGraph::UpdateImport(). No recompilation needed.
Slow path (first frame, after Invalidate(), or missing frameUpdateFunc):
BeginFrame — acquires the next swapchain image.
Reset — clears graph passes, resources, compilation state AND resets the executor’s per-frame state.
Rebuild — iterates all RenderGraphBuilderComponent entities and invokes their builderFunc to declare passes and resources.
Compile — topological sort, dependency levels, SSIS culling.
-
virtual void OnRender() override#
Execute the compiled render graph.
Delegates to RenderGraphExecutor::Execute() which:
Realizes any unrealized transient GPU resources.
Initializes per-resource state tracking from imported initial states.
For each dependency level: detects multi-queue reads, selects the most competent queue for transition rerouting, computes resource barriers, builds command list batches bounded by fence waits/signals, records pass work into command lists, and submits batches.
-
virtual void OnPostRender() override#
End the frame and present the swapchain image.
-
inline virtual std::string_view GetName() const override#
GetName() is used to get the name of the system
- Returns:
Name of the system
-
inline Hush::RenderGraph::RenderDevice *GetRenderDevice() const noexcept#
Get the render device (graph + executor + device reference).
-
inline Hush::RenderGraph::RenderGraphExecutor &GetExecutor() noexcept#
Convenience: get the render graph executor.
Useful for inspecting executor state (fence values, resource state tracker) during debugging or for advanced manual control.
-
inline const Hush::RenderGraph::RenderGraphExecutor &GetExecutor() const noexcept#
Convenience: get the render graph executor (const).
-
inline Hush::RenderGraph::RenderGraph &GetRenderGraph() noexcept#
Convenience: get the render graph.
-
inline const Hush::RenderGraph::RenderGraph &GetRenderGraph() const noexcept#
Convenience: get the render graph (const).
-
inline IGraphicsDevice *GetGraphicsDevice() const noexcept#
Convenience: get the underlying graphics device.
-
inline bool IsGraphCompiled() const noexcept#
Check whether the render graph has been compiled and is ready for execution this frame.
-
inline bool IsFrameActive() const noexcept#
Returns true if BeginFrame() has been called for the current frame and EndFrame() has not yet been called.
-
RenderGraphSystem(Scene &scene, RenderGraph::RenderDevice *renderDevice)#
-
struct RenderPassColorAttachment#
- #include <RenderPass.hpp>
Color attachment descriptor for render passes.
-
struct RenderPassDepthStencilAttachment#
- #include <RenderPass.hpp>
Depth/stencil attachment descriptor for render passes.
-
struct RenderPassDescriptor#
- #include <RenderPass.hpp>
Render pass descriptor Describes the configuration for a render pass, including all attachments.
Public Functions
-
inline void AddColorAttachment(const RenderPassColorAttachment &attachment)#
Helper to add a color attachment.
-
inline void SetDepthStencilAttachment(const RenderPassDepthStencilAttachment &attachment)#
Helper to set depth/stencil attachment.
Public Members
-
std::array<RenderPassColorAttachment, MAX_COLOR_TARGETS> colorAttachments#
-
uint32_t colorAttachmentCount = 0#
-
std::optional<RenderPassDepthStencilAttachment> depthStencilAttachment#
-
std::string_view debugLabel#
-
inline void AddColorAttachment(const RenderPassColorAttachment &attachment)#
-
struct ResourceBarrierDescriptor#
- #include <GraphicsTypes.hpp>
Describes a resource state transition barrier.
Public Members
-
void *resource = nullptr#
Opaque pointer to the resource (IGraphicsBuffer* or IGraphicsTexture*)
-
EResourceState stateBefore = EResourceState::Undefined#
State before the barrier.
-
EResourceState stateAfter = EResourceState::Undefined#
State after the barrier.
-
uint32_t subresource = UINT32_MAX#
Subresource index (use UINT32_MAX for all subresources)
-
void *resource = nullptr#
-
struct SamplerDescriptor#
- #include <ISampler.hpp>
Descriptor for creating a sampler object.
Public Members
-
EFilterMode magFilter = EFilterMode::Linear#
Magnification filter (used when the texel is larger than one pixel).
-
EFilterMode minFilter = EFilterMode::Linear#
Minification filter (used when the texel is smaller than one pixel).
-
EFilterMode mipmapFilter = EFilterMode::Linear#
Mip-map filter (used when selecting between mip levels).
-
EAddressMode addressModeU = EAddressMode::ClampToEdge#
Address mode for the U (S / horizontal) texture coordinate.
-
EAddressMode addressModeV = EAddressMode::ClampToEdge#
Address mode for the V (T / vertical) texture coordinate.
-
EAddressMode addressModeW = EAddressMode::ClampToEdge#
Address mode for the W (R / depth) texture coordinate.
-
float lodMinClamp = 0.0f#
Minimum level-of-detail clamp value.
-
float lodMaxClamp = 32.0f#
Maximum level-of-detail clamp value.
Use a very large value (the default) to avoid clamping the max LOD, effectively allowing all mip levels to be used.
-
ECompareFunction compare = ECompareFunction::Undefined#
Comparison function for comparison (depth) samplers.
Set to ECompareFunction::Undefined for regular filtering samplers. Any other value creates a comparison sampler.
-
uint16_t maxAnisotropy = 1#
Maximum anisotropy level (1 = no anisotropy).
Values > 1 enable anisotropic filtering. The actual maximum is clamped to the device’s capability. Must be >= 1.
-
const char *debugName = nullptr#
Optional debug name for graphics debuggers.
-
EFilterMode magFilter = EFilterMode::Linear#
-
struct SamplerResource#
- #include <GraphicsResources.hpp>
Sampler resource for RenderGraph Owns the sampler lifetime so client code does not need to manage it.
Public Types
-
using Descriptor = SamplerDescriptor#
Public Functions
-
inline bool IsValid() const#
Check if the resource is valid.
-
void CreateResource(const SamplerDescriptor &samplerDescriptor, IGraphicsDevice *device)#
-
void DestroyResource(const SamplerDescriptor &samplerDescriptor, IGraphicsDevice *device)#
Public Members
-
SamplerDescriptor descriptor#
Resource descriptor.
-
using Descriptor = SamplerDescriptor#
-
struct ShaderBytecode#
- #include <IShaderModule.hpp>
Holds compiled shader data in a backend-appropriate format.
For SPIR-V / DXIL backends this contains binary bytecode. For WebGPU this contains WGSL source text.
Public Functions
-
inline bool IsValid() const#
Returns true if this bytecode container has usable content.
Public Members
-
std::variant<BinaryContent, TextContent, std::monostate> content#
The shader content, which can be either binary or text depending on the backend.
-
inline bool IsValid() const#
-
struct ShaderCompilationResult#
- #include <ShaderCompiler.hpp>
Full result of a shader compilation request.
Public Functions
-
inline const CompiledShaderStage *FindStage(EShaderStage stage) const#
Helper: find a compiled stage by type.
- Returns:
Pointer to the stage, or nullptr if not found.
-
inline std::vector<BindGroupLayoutDescriptor> BuildBindGroupLayoutDescriptors() const#
Helper: build BindGroupLayoutDescriptors from reflected bindings.
Groups the reflected bindings by set index and produces one layout descriptor per set. The returned vector is indexed by set number (gaps are filled with empty descriptors).
Public Members
-
bool success = false#
Whether compilation succeeded for all requested entry points.
-
std::string diagnostics#
Human-readable error / warning messages from the compiler.
-
std::vector<CompiledShaderStage> stages#
Per-stage compilation outputs (one per ShaderEntryPointRequest).
-
std::vector<ReflectedBinding> bindings#
Reflected resource bindings (union across all stages).
-
std::vector<ReflectedVertexInput> vertexInputs#
Reflected vertex inputs (from the vertex stage, if present).
-
inline const CompiledShaderStage *FindStage(EShaderStage stage) const#
-
class ShaderCompiler#
- #include <ShaderCompiler.hpp>
Slang-based shader compiler.
Compiles .slang shader source files (or raw strings) to the target backend format (WGSL, SPIR-V, HLSL, DXIL) and extracts reflection data.
The compiler owns a Slang global session and per-compilation sessions. It caches compiled results keyed by (source identity + entry points + target) so that repeated compilations of the same shader are free.
Public Functions
-
ShaderCompiler()#
-
~ShaderCompiler()#
-
ShaderCompiler(const ShaderCompiler&) = delete#
-
ShaderCompiler &operator=(const ShaderCompiler&) = delete#
-
ShaderCompiler(ShaderCompiler &&other) noexcept#
-
ShaderCompiler &operator=(ShaderCompiler &&other) noexcept#
-
bool Initialize(const ShaderCompilerOptions &options = {})#
Initialize the Slang global session with the given options.
Must be called once before any compilation. Can be called again to reinitialise with different options (clears the cache).
- Parameters:
options – Compiler options (target, optimisation, etc.).
- Returns:
True on success, false if Slang initialisation failed.
-
bool IsInitialized() const#
Check if the compiler has been initialized successfully.
-
EShaderTarget GetTarget() const#
Get the current target backend.
-
ShaderCompilationResult CompileFromSource(std::string_view source, std::string_view sourceName, const std::vector<ShaderEntryPointRequest> &entryPoints)#
Compile a raw Slang source string with the given entry points.
- Parameters:
source – Slang source code.
sourceName – Virtual file name for diagnostics (e.g. “inline.slang”).
entryPoints – List of entry points to compile.
- Returns:
Compilation result.
-
void ClearCache()#
Clear all cached compilation results.
Call this when shaders are modified at runtime (hot-reload) to force recompilation on the next request.
-
size_t GetCacheSize() const#
Get the number of cached compilation results.
Public Static Functions
-
static EShaderTarget GetTargetForAPI(EGraphicsAPI api)#
Helper to select the appropriate EShaderTarget for a given graphics API backend.
-
static const char *GetSlangProfileForStage(EShaderStage stage, EShaderTarget target)#
Helper: given an EShaderStage, return the Slang profile name string (e.g. “vs_6_0”, “ps_6_0”, “cs_6_0” for HLSL-family targets, or the WGSL / GLSL equivalents).
-
ShaderCompiler()#
-
struct ShaderCompilerOptions#
- #include <ShaderCompiler.hpp>
Compiler-wide options.
Public Members
-
EShaderTarget target = EShaderTarget::WGSL#
The backend target to compile for.
-
uint32_t optimizationLevel = 1#
Optimisation level (0 = none, 1 = default, 2 = performance, 3 = size). Maps to Slang’s optimisation settings.
-
bool generateDebugInfo = false#
Generate debug information in the output.
-
std::vector<std::string> includePaths#
Additional include search paths for #include / import.
-
std::vector<std::pair<std::string, std::string>> defines#
Preprocessor macro definitions (name, value pairs). An empty value means a define with no value (like -DFOO).
-
uint32_t matrixLayout = 0#
The matrix layout to use for uniform buffers. 0 = row-major (Slang default), 1 = column-major.
-
EShaderTarget target = EShaderTarget::WGSL#
-
struct ShaderEntryPointRequest#
- #include <ShaderCompiler.hpp>
Describes a single entry point to compile.
Public Members
-
EShaderStage stage = EShaderStage::Vertex#
The shader stage this entry point targets.
-
std::string entryPointName = "main"#
The name of the entry point function in the Slang source. For example: “vertexMain”, “fragmentMain”, “computeMain”.
-
EShaderStage stage = EShaderStage::Vertex#
-
struct ShaderModuleDescriptor#
- #include <IShaderModule.hpp>
Descriptor for creating a shader module.
Public Members
-
EShaderStage stage = EShaderStage::Vertex#
The shader stage this module represents.
-
std::string entryPoint = "main"#
Entry point function name within the shader Defaults to “main” for GLSL/SPIR-V convention. Slang shaders may use names like “vertexMain”, “fragmentMain”, etc.
-
ShaderBytecode bytecode#
Compiled shader bytecode or source.
-
std::string debugName#
Optional debug name.
-
EShaderStage stage = EShaderStage::Vertex#
-
struct ShaderResource#
- #include <GraphicsResources.hpp>
Shader module resource for RenderGraph This is used during BuildContext to declare shader module creation parameters. Owns the shader module lifetime so client code does not need to manage it.
Public Types
-
using Descriptor = ShaderModuleDescriptor#
Public Functions
-
inline IShaderModule *Get() const#
Get the underlying shader module (convenience accessor)
-
inline bool IsValid() const#
Check if the resource is valid.
-
void CreateResource(const ShaderModuleDescriptor &shaderDescriptor, IGraphicsDevice *device)#
-
void DestroyResource(const ShaderModuleDescriptor &shaderDescriptor, IGraphicsDevice *device)#
Public Members
-
std::unique_ptr<IShaderModule> shaderModule#
Runtime shader module handle (set during execution)
-
ShaderModuleDescriptor descriptor#
Resource descriptor.
-
using Descriptor = ShaderModuleDescriptor#
-
struct SplitBarrierDescriptor#
- #include <GraphicsTypes.hpp>
Describes a split barrier (begin/end pair for overlapped transitions).
Split barriers allow the GPU to begin a transition early and complete it later, hiding latency by overlapping the transition with other work.
Public Members
-
void *resource = nullptr#
-
EResourceState stateBefore = EResourceState::Undefined#
-
EResourceState stateAfter = EResourceState::Undefined#
-
uint32_t subresource = UINT32_MAX#
-
void *resource = nullptr#
-
struct StencilFaceState#
- #include <PipelineDescriptor.hpp>
Stencil face state.
Public Members
-
ECompareFunction compare = ECompareFunction::Always#
-
EStencilOperation failOp = EStencilOperation::Keep#
-
EStencilOperation depthFailOp = EStencilOperation::Keep#
-
EStencilOperation passOp = EStencilOperation::Keep#
-
ECompareFunction compare = ECompareFunction::Always#
-
struct SubmitInfo#
- #include <ICommandQueue.hpp>
Describes a batched submission to a command queue.
Public Members
-
std::vector<FenceWaitDescriptor> waitFences#
Fences to wait on before executing command lists. The queue will not begin executing until all wait conditions are met.
-
std::vector<ICommandList*> commandLists#
Command lists to execute, in order.
-
std::vector<FenceSignalDescriptor> signalFences#
Fences to signal after all command lists have completed execution.
-
std::vector<FenceWaitDescriptor> waitFences#
-
struct TextureDescriptor#
- #include <GraphicsTypes.hpp>
Texture creation descriptor.
Public Members
-
uint32_t width = 1#
-
uint32_t height = 1#
-
uint32_t depth = 1#
-
uint32_t mipLevels = 1#
-
uint32_t arrayLayers = 1#
-
uint32_t sampleCount = 1#
-
ETextureFormat format = ETextureFormat::RGBA8_UNORM#
-
ETextureUsage usage = ETextureUsage::Sampled#
-
const char *debugName = nullptr#
-
bool ownedByExternalSource = false#
-
uint32_t width = 1#
-
struct TextureResource#
- #include <GraphicsResources.hpp>
Texture resource descriptor for RenderGraph This is used during BuildContext to declare texture creation parameters.
Public Types
-
using Descriptor = TextureDescriptor#
Public Functions
-
inline IGraphicsTexture *Get() const#
Get the underlying texture (convenience accessor)
-
inline bool IsValid() const#
Check if the resource is valid.
-
void CreateResource(const TextureDescriptor &textureDescriptor, IGraphicsDevice *device)#
-
void DestroyResource(const TextureDescriptor &textureDescriptor, IGraphicsDevice *device)#
Public Members
-
std::unique_ptr<IGraphicsTexture> texture#
Runtime texture handle (set during execution)
-
TextureDescriptor descriptor#
Resource descriptor.
-
using Descriptor = TextureDescriptor#
-
struct TransferPassData#
- #include <GraphicsResources.hpp>
Common data for a transfer/copy pass.
Public Members
-
uint32_t sourceResource = 0#
Source resource ID.
-
uint32_t destinationResource = 0#
Destination resource ID.
-
struct Hush::Graphics::TransferPassData::CopyRegion region#
-
struct CopyRegion#
- #include <GraphicsResources.hpp>
Copy region information (buffer offset or texture coordinates)
-
uint32_t sourceResource = 0#
-
struct UAVBarrierDescriptor#
- #include <GraphicsTypes.hpp>
UAV (Unordered Access View) barrier — ensures all UAV writes complete before subsequent UAV reads or writes on the same resource.
Public Members
-
void *resource = nullptr#
nullptr means barrier on all UAV resources
-
void *resource = nullptr#
-
struct VertexAttribute#
- #include <PipelineDescriptor.hpp>
Describes a single vertex attribute within a vertex buffer layout.
Public Members
-
uint32_t shaderLocation = 0#
Shader location index (layout(location = N))
-
uint32_t offset = 0#
Byte offset of this attribute within the vertex buffer stride.
-
EVertexFormat format = EVertexFormat::Float32x4#
Data format of the attribute.
-
uint32_t shaderLocation = 0#
-
struct VertexBufferLayout#
- #include <PipelineDescriptor.hpp>
Describes the layout of a single vertex buffer binding.
Public Members
-
uint32_t stride = 0#
Byte stride between consecutive elements.
-
EVertexStepMode stepMode = EVertexStepMode::Vertex#
Per-vertex or per-instance stepping.
-
std::vector<VertexAttribute> attributes#
Attributes sourced from this buffer.
-
uint32_t stride = 0#
-
class WebGPUBindGroup : public Hush::Graphics::IBindGroup#
- #include <WebGPUBindGroup.hpp>
WebGPU implementation of IBindGroup.
Wraps a wgpu::BindGroup that holds concrete resource bindings (buffers, textures, samplers) matching a bind group layout. Bind groups are set on a command list before draw / dispatch calls via SetBindGroup().
Public Functions
-
WebGPUBindGroup(wgpu::Device device, const BindGroupDescriptor &descriptor)#
Construct a bind group from the engine descriptor.
Translates the descriptor’s entries into wgpu::BindGroupEntry structures and creates the native wgpu::BindGroup.
- Parameters:
device – The WebGPU device.
descriptor – The backend-agnostic bind group descriptor.
-
~WebGPUBindGroup() override#
-
WebGPUBindGroup(const WebGPUBindGroup&) = delete#
-
WebGPUBindGroup &operator=(const WebGPUBindGroup&) = delete#
-
WebGPUBindGroup(WebGPUBindGroup&&) = delete#
-
WebGPUBindGroup &operator=(WebGPUBindGroup&&) = delete#
-
inline virtual IBindGroupLayout *GetLayout() const override#
Get the layout this bind group was created from.
-
inline virtual bool IsValid() const override#
Check if the bind group is valid.
-
inline virtual void *GetNativeHandle() const override#
Get the native API handle For WebGPU: wgpu::BindGroup* For Vulkan: VkDescriptorSet*.
-
inline wgpu::BindGroup GetBindGroup() const#
Get the underlying wgpu::BindGroup directly.
-
inline const std::string &GetDebugName() const#
Get the debug name assigned at creation time.
-
WebGPUBindGroup(wgpu::Device device, const BindGroupDescriptor &descriptor)#
-
class WebGPUBindGroupLayout : public Hush::Graphics::IBindGroupLayout#
- #include <WebGPUBindGroup.hpp>
WebGPU implementation of IBindGroupLayout.
Wraps a wgpu::BindGroupLayout that describes the expected shape (binding indices, types, shader stage visibility) of a set of resource bindings. Used at pipeline creation time for validation and at bind group creation time as the template the group must match.
Public Functions
-
WebGPUBindGroupLayout(wgpu::Device device, const BindGroupLayoutDescriptor &descriptor)#
Construct a bind group layout from the engine descriptor.
Translates the descriptor’s entries into wgpu::BindGroupLayoutEntry structures and creates the native wgpu::BindGroupLayout.
- Parameters:
device – The WebGPU device.
descriptor – The backend-agnostic bind group layout descriptor.
-
~WebGPUBindGroupLayout() override#
-
WebGPUBindGroupLayout(const WebGPUBindGroupLayout&) = delete#
-
WebGPUBindGroupLayout &operator=(const WebGPUBindGroupLayout&) = delete#
-
WebGPUBindGroupLayout(WebGPUBindGroupLayout&&) = delete#
-
WebGPUBindGroupLayout &operator=(WebGPUBindGroupLayout&&) = delete#
-
inline virtual uint32_t GetEntryCount() const override#
Get the number of entries in this layout.
-
inline virtual bool IsValid() const override#
Check if the layout is valid.
-
inline virtual void *GetNativeHandle() const override#
Get the native API handle.
-
inline wgpu::BindGroupLayout GetLayout() const#
Get the underlying wgpu::BindGroupLayout directly.
-
inline const std::string &GetDebugName() const#
Get the debug name assigned at creation time.
-
WebGPUBindGroupLayout(wgpu::Device device, const BindGroupLayoutDescriptor &descriptor)#
-
class WebGPUBuffer : public Hush::Graphics::IGraphicsBuffer#
- #include <WebGPUBuffer.hpp>
WebGPU buffer implementation.
Public Functions
-
WebGPUBuffer(wgpu::Buffer buffer, wgpu::Instance instance, const BufferDescriptor &desc)#
-
~WebGPUBuffer() override#
-
WebGPUBuffer(const WebGPUBuffer&) = delete#
-
WebGPUBuffer(WebGPUBuffer&&) = delete#
-
WebGPUBuffer &operator=(const WebGPUBuffer&) = delete#
-
WebGPUBuffer &operator=(WebGPUBuffer&&) = delete#
-
inline virtual uint64_t GetSize() const override#
Get buffer size in bytes.
-
inline virtual EBufferUsage GetUsage() const override#
Get buffer usage flags.
-
virtual void *Map(Graphics::IGraphicsDevice *device) override#
Map buffer for CPU access (if supported)
- Parameters:
device – Non-owning pointer to the graphics device (may be needed for some APIs to perform the mapping)
- Returns:
Pointer to mapped memory, or nullptr if mapping failed
-
virtual void Unmap() override#
Unmap buffer.
-
virtual void *GetNativeHandle() const override#
Get native handle (API-specific)
-
inline wgpu::Buffer GetBuffer() const#
-
WebGPUBuffer(wgpu::Buffer buffer, wgpu::Instance instance, const BufferDescriptor &desc)#
-
class WebGPUCommandQueue : public Hush::Graphics::ICommandQueue#
- #include <WebGPUCommandQueue.hpp>
WebGPU command queue implementation.
Public Functions
-
WebGPUCommandQueue(wgpu::Queue queue, EQueueType type)#
-
~WebGPUCommandQueue() override = default#
-
WebGPUCommandQueue(const WebGPUCommandQueue&) = delete#
-
WebGPUCommandQueue(WebGPUCommandQueue&&) = delete#
-
WebGPUCommandQueue &operator=(const WebGPUCommandQueue&) = delete#
-
WebGPUCommandQueue &operator=(WebGPUCommandQueue&&) = delete#
-
inline virtual EQueueType GetQueueType() const override#
Get queue type.
-
virtual void Submit(std::span<ICommandList*> commandLists) override#
Submit command lists for execution (simple, no synchronization).
This is the simplest form of submission — no fence waits or signals are associated with the call. Useful for single-queue scenarios or when synchronization is managed externally.
- Parameters:
commandLists – Array of command lists to submit, executed in order.
-
virtual void SubmitBatched(const SubmitInfo &submitInfo) override#
Submit a batch of command lists with explicit fence synchronization.
This is the primary submission method used by the render graph executor. It maps to the article’s concept of a command list batch: a group of command lists that share the same set of fence waits (before) and fence signals (after).
The implementation must:
Wait on all fences in submitInfo.waitFences before beginning execution.
Execute all command lists in submitInfo.commandLists, in order.
Signal all fences in submitInfo.signalFences after execution completes.
- Parameters:
submitInfo – Batched submission descriptor containing waits, command lists, and signals.
-
virtual void Signal(IFence *fence, uint64_t value) override#
Signal a fence from this queue without submitting any command lists.
Enqueues a GPU-side signal for the given fence to the specified value. The signal will occur after all previously submitted work on this queue has completed.
- Parameters:
fence – The fence to signal.
value – The value to signal the fence to (must be monotonically increasing for timeline fences).
-
virtual void Wait(IFence *fence, uint64_t value) override#
Enqueue a GPU-side wait on a fence before any subsequent work.
All command lists submitted after this call will not begin execution until the fence reaches the specified value. This is a GPU-side wait only — it does not block the CPU.
- Parameters:
fence – The fence to wait on.
value – The value the fence must reach before the wait is satisfied.
-
virtual void WaitIdle() override#
Wait for all commands on this queue to complete (CPU-side stall).
Blocks the calling thread until the GPU has finished executing all previously submitted command lists on this queue.
-
virtual void *GetNativeHandle() const override#
Get native handle (API-specific)
-
inline wgpu::Queue GetQueue() const#
-
wgpu::CommandEncoder CreateEncoder(const char *label = nullptr)#
-
WebGPUCommandQueue(wgpu::Queue queue, EQueueType type)#
-
class WebGPUComputeCommandList : public Hush::Graphics::IComputeCommandList#
- #include <WebGPUCommandList.hpp>
WebGPU implementation of compute command list.
Public Functions
-
explicit WebGPUComputeCommandList(wgpu::Device device)#
-
~WebGPUComputeCommandList() override#
-
WebGPUComputeCommandList(const WebGPUComputeCommandList&) = delete#
-
WebGPUComputeCommandList &operator=(const WebGPUComputeCommandList&) = delete#
-
WebGPUComputeCommandList(WebGPUComputeCommandList&&) = delete#
-
WebGPUComputeCommandList &operator=(WebGPUComputeCommandList&&) = delete#
-
virtual void Reset() override#
Reset command list for recording.
-
virtual void Close() override#
Close command list after recording.
-
virtual void *GetNativeHandle() const override#
Get native handle (API-specific)
-
virtual void ResourceBarrier(std::span<const ResourceBarrierDescriptor> barriers) override#
Record one or more resource state transition barriers.
Transitions move a resource from one GPU usage state to another (e.g. RenderTarget -> ShaderResource). The GPU must not access the resource in the new state until the barrier completes.
- Parameters:
barriers – Array of transition barrier descriptors.
-
virtual void UAVBarrier(std::span<const UAVBarrierDescriptor> barriers) override#
Record one or more UAV (Unordered Access View) barriers.
Ensures all previous UAV writes to the specified resource(s) are visible before subsequent UAV reads or writes begin.
- Parameters:
barriers – Array of UAV barrier descriptors.
-
virtual void BeginSplitBarrier(std::span<const SplitBarrierDescriptor> barriers) override#
Begin the first half of a split barrier (async transition).
Split barriers allow the GPU to start a resource state transition early and overlap it with other unrelated work, completing it later with EndSplitBarrier(). This can hide transition latency.
Note
Not all backends support split barriers. Implementations that don’t may treat this as a no-op and perform the full transition in EndSplitBarrier() instead.
- Parameters:
barriers – Array of split barrier descriptors to begin.
-
virtual void EndSplitBarrier(std::span<const SplitBarrierDescriptor> barriers) override#
Complete the second half of a split barrier.
Must be paired with a prior BeginSplitBarrier() call for the same resource(s). After this call the resource is fully transitioned.
- Parameters:
barriers – Array of split barrier descriptors to end.
-
virtual void CopyBuffer(IGraphicsBuffer *src, uint64_t srcOffset, IGraphicsBuffer *dst, uint64_t dstOffset, uint64_t size) override#
Record a buffer-to-buffer copy command.
-
virtual void CopyBufferToTexture(IGraphicsBuffer *src, uint64_t srcOffset, IGraphicsTexture *dst, uint32_t dstX, uint32_t dstY, uint32_t dstZ, uint32_t width, uint32_t height, uint32_t depth, uint32_t rowPitch) override#
Record a buffer-to-texture copy command.
- Parameters:
rowPitch – Byte stride between consecutive rows in the source buffer (must be aligned to 256).
-
virtual void CopyTextureToBuffer(IGraphicsTexture *src, uint32_t srcX, uint32_t srcY, uint32_t srcZ, IGraphicsBuffer *dst, uint64_t dstOffset, uint32_t width, uint32_t height, uint32_t depth) override#
Record a texture-to-buffer copy command.
-
virtual void CopyTexture(IGraphicsTexture *src, uint32_t srcX, uint32_t srcY, uint32_t srcZ, IGraphicsTexture *dst, uint32_t dstX, uint32_t dstY, uint32_t dstZ, uint32_t width, uint32_t height, uint32_t depth) override#
Record a texture-to-texture copy command.
-
virtual void Dispatch(uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ) override#
Record a compute dispatch command.
-
virtual void DispatchIndirect(IGraphicsBuffer *indirectArgsBuffer, uint64_t offset) override#
Record a compute dispatch indirect command.
-
virtual void BindComputePipeline(IComputePipeline *pipeline) override#
Bind a compute pipeline for subsequent dispatch calls.
- Parameters:
pipeline – The compute pipeline to bind (must be a valid IComputePipeline).
-
virtual void SetComputeBindGroup(uint32_t groupIndex, IBindGroup *bindGroup, std::span<const uint32_t> dynamicOffsets = {}) override#
Set a bind group at the given group/set index for compute operations.
The bind group must conform to the layout declared at that index in the currently bound compute pipeline’s descriptor.
- Parameters:
groupIndex – The group/set index (0-based, corresponds to @group(N) in WGSL).
bindGroup – The bind group to set.
dynamicOffsets – Optional dynamic offsets for dynamic uniform/storage buffer bindings.
-
inline wgpu::CommandEncoder GetEncoder() const#
-
inline wgpu::CommandBuffer GetCommandBuffer() const#
-
explicit WebGPUComputeCommandList(wgpu::Device device)#
-
class WebGPUComputePipeline : public Hush::Graphics::IComputePipeline#
- #include <WebGPUPipeline.hpp>
WebGPU implementation of IComputePipeline.
Wraps a wgpu::ComputePipeline created from the engine’s ComputePipelineDescriptor.
Public Functions
-
inline WebGPUComputePipeline(wgpu::Device device, const ComputePipelineDescriptor &descriptor)#
Construct a compute pipeline from the engine descriptor.
- Parameters:
device – The WebGPU device.
descriptor – The backend-agnostic compute pipeline descriptor.
-
inline ~WebGPUComputePipeline() override#
-
WebGPUComputePipeline(const WebGPUComputePipeline&) = delete#
-
WebGPUComputePipeline &operator=(const WebGPUComputePipeline&) = delete#
-
WebGPUComputePipeline(WebGPUComputePipeline&&) = delete#
-
WebGPUComputePipeline &operator=(WebGPUComputePipeline&&) = delete#
-
inline virtual bool IsValid() const override#
Check if the pipeline was created successfully and is usable.
A pipeline that failed creation (e.g. shader compilation error, incompatible state) will return false.
-
inline virtual std::string_view GetDebugName() const override#
Get the debug name assigned at creation time.
Returns an empty string_view if no debug name was provided.
-
inline virtual void *GetNativeHandle() const override#
Get the native API handle for the pipeline.
The returned pointer’s type depends on the backend:
WebGPU graphics: wgpu::RenderPipeline*
WebGPU compute: wgpu::ComputePipeline*
Vulkan: VkPipeline*
D3D12: ID3D12PipelineState*
Ownership is NOT transferred; the pipeline object retains ownership.
-
inline wgpu::ComputePipeline GetPipeline() const#
Get the underlying wgpu::ComputePipeline directly.
-
inline WebGPUComputePipeline(wgpu::Device device, const ComputePipelineDescriptor &descriptor)#
-
class WebGPUCopyCommandList : public Hush::Graphics::ICopyCommandList#
- #include <WebGPUCommandList.hpp>
WebGPU implementation of copy command list.
Public Functions
-
explicit WebGPUCopyCommandList(wgpu::Device device)#
-
~WebGPUCopyCommandList() override#
-
WebGPUCopyCommandList(const WebGPUCopyCommandList&) = delete#
-
WebGPUCopyCommandList &operator=(const WebGPUCopyCommandList&) = delete#
-
WebGPUCopyCommandList(WebGPUCopyCommandList&&) = delete#
-
WebGPUCopyCommandList &operator=(WebGPUCopyCommandList&&) = delete#
-
virtual void Reset() override#
Reset command list for recording.
-
virtual void Close() override#
Close command list after recording.
-
virtual void *GetNativeHandle() const override#
Get native handle (API-specific)
-
virtual void ResourceBarrier(std::span<const ResourceBarrierDescriptor> barriers) override#
Record one or more resource state transition barriers.
Transitions move a resource from one GPU usage state to another (e.g. RenderTarget -> ShaderResource). The GPU must not access the resource in the new state until the barrier completes.
- Parameters:
barriers – Array of transition barrier descriptors.
-
virtual void UAVBarrier(std::span<const UAVBarrierDescriptor> barriers) override#
Record one or more UAV (Unordered Access View) barriers.
Ensures all previous UAV writes to the specified resource(s) are visible before subsequent UAV reads or writes begin.
- Parameters:
barriers – Array of UAV barrier descriptors.
-
virtual void BeginSplitBarrier(std::span<const SplitBarrierDescriptor> barriers) override#
Begin the first half of a split barrier (async transition).
Split barriers allow the GPU to start a resource state transition early and overlap it with other unrelated work, completing it later with EndSplitBarrier(). This can hide transition latency.
Note
Not all backends support split barriers. Implementations that don’t may treat this as a no-op and perform the full transition in EndSplitBarrier() instead.
- Parameters:
barriers – Array of split barrier descriptors to begin.
-
virtual void EndSplitBarrier(std::span<const SplitBarrierDescriptor> barriers) override#
Complete the second half of a split barrier.
Must be paired with a prior BeginSplitBarrier() call for the same resource(s). After this call the resource is fully transitioned.
- Parameters:
barriers – Array of split barrier descriptors to end.
-
virtual void CopyBuffer(IGraphicsBuffer *src, uint64_t srcOffset, IGraphicsBuffer *dst, uint64_t dstOffset, uint64_t size) override#
Record a buffer-to-buffer copy command.
-
virtual void CopyBufferToTexture(IGraphicsBuffer *src, uint64_t srcOffset, IGraphicsTexture *dst, uint32_t dstX, uint32_t dstY, uint32_t dstZ, uint32_t width, uint32_t height, uint32_t depth, uint32_t rowPitch) override#
Record a buffer-to-texture copy command.
- Parameters:
rowPitch – Byte stride between consecutive rows in the source buffer (must be aligned to 256).
-
virtual void CopyTextureToBuffer(IGraphicsTexture *src, uint32_t srcX, uint32_t srcY, uint32_t srcZ, IGraphicsBuffer *dst, uint64_t dstOffset, uint32_t width, uint32_t height, uint32_t depth) override#
Record a texture-to-buffer copy command.
-
virtual void CopyTexture(IGraphicsTexture *src, uint32_t srcX, uint32_t srcY, uint32_t srcZ, IGraphicsTexture *dst, uint32_t dstX, uint32_t dstY, uint32_t dstZ, uint32_t width, uint32_t height, uint32_t depth) override#
Record a texture-to-texture copy command.
-
inline wgpu::CommandEncoder GetEncoder() const#
-
inline wgpu::CommandBuffer GetCommandBuffer() const#
-
explicit WebGPUCopyCommandList(wgpu::Device device)#
-
class WebGPUFence : public Hush::Graphics::IFence#
- #include <WebGPUFence.hpp>
WebGPU fence implementation — CPU-emulated timeline fence.
WebGPU does not expose native timeline fences (timeline semaphores). Since WebGPU only has a single queue, cross-queue synchronization is inherently serialized. This implementation emulates timeline fence semantics entirely on the CPU using an atomic counter and a condition variable for WaitCPU blocking.
This is sufficient for the render graph executor to function correctly:
Signal/Wait calls from SubmitBatched update the CPU-side counter.
Because WebGPU serializes all GPU work on one queue, ordering is already guaranteed by submission order.
WaitCPU can be used during shutdown or synchronization points.
Public Functions
-
inline explicit WebGPUFence(uint64_t initialValue = 0)#
Construct a CPU-emulated fence with the given initial value.
- Parameters:
initialValue – Starting value for the fence counter (typically 0).
-
~WebGPUFence() override = default#
-
WebGPUFence(const WebGPUFence&) = delete#
-
WebGPUFence &operator=(const WebGPUFence&) = delete#
-
WebGPUFence(WebGPUFence&&) = delete#
-
WebGPUFence &operator=(WebGPUFence&&) = delete#
-
inline virtual uint64_t GetCompletedValue() const override#
Get the last completed (signaled) value.
Since this is CPU-emulated, the completed value is updated immediately when SignalCPU or the queue’s Signal method is called.
-
inline virtual uint64_t GetPendingValue() const override#
Get the last pending (requested) signal value.
-
inline virtual bool WaitCPU(uint64_t value, uint64_t timeoutNs = std::numeric_limits<uint64_t>::max()) override#
Block the calling thread until the fence reaches the specified value or the timeout expires.
- Parameters:
value – The fence value to wait for.
timeoutNs – Maximum wait time in nanoseconds (UINT64_MAX = infinite).
- Returns:
true if the value was reached, false on timeout.
-
inline virtual void SignalCPU(uint64_t value) override#
Signal the fence to a specific value from the CPU.
Updates both the completed and pending values and wakes any threads blocked in WaitCPU.
- Parameters:
value – The value to signal (must be >= current completed value).
-
inline void SetPendingValue(uint64_t value)#
Mark a value as pending (requested but not yet completed).
This is used internally by the queue to track the highest requested signal value before the GPU has actually completed the work.
- Parameters:
value – The pending signal value.
-
inline virtual void *GetNativeHandle() const override#
Returns nullptr — WebGPU has no native fence object.
-
class WebGPUGraphicsCommandList : public Hush::Graphics::IGraphicsCommandList#
- #include <WebGPUCommandList.hpp>
WebGPU implementation of graphics command list.
Public Functions
-
explicit WebGPUGraphicsCommandList(wgpu::Device device)#
-
~WebGPUGraphicsCommandList() override#
-
WebGPUGraphicsCommandList(const WebGPUGraphicsCommandList&) = delete#
-
WebGPUGraphicsCommandList &operator=(const WebGPUGraphicsCommandList&) = delete#
-
WebGPUGraphicsCommandList(WebGPUGraphicsCommandList&&) = delete#
-
WebGPUGraphicsCommandList &operator=(WebGPUGraphicsCommandList&&) = delete#
-
virtual void Reset() override#
Reset command list for recording.
-
virtual void Close() override#
Close command list after recording.
-
virtual void *GetNativeHandle() const override#
Get native handle (API-specific)
-
virtual void ResourceBarrier(std::span<const ResourceBarrierDescriptor> barriers) override#
Record one or more resource state transition barriers.
Transitions move a resource from one GPU usage state to another (e.g. RenderTarget -> ShaderResource). The GPU must not access the resource in the new state until the barrier completes.
- Parameters:
barriers – Array of transition barrier descriptors.
-
virtual void UAVBarrier(std::span<const UAVBarrierDescriptor> barriers) override#
Record one or more UAV (Unordered Access View) barriers.
Ensures all previous UAV writes to the specified resource(s) are visible before subsequent UAV reads or writes begin.
- Parameters:
barriers – Array of UAV barrier descriptors.
-
virtual void BeginSplitBarrier(std::span<const SplitBarrierDescriptor> barriers) override#
Begin the first half of a split barrier (async transition).
Split barriers allow the GPU to start a resource state transition early and overlap it with other unrelated work, completing it later with EndSplitBarrier(). This can hide transition latency.
Note
Not all backends support split barriers. Implementations that don’t may treat this as a no-op and perform the full transition in EndSplitBarrier() instead.
- Parameters:
barriers – Array of split barrier descriptors to begin.
-
virtual void EndSplitBarrier(std::span<const SplitBarrierDescriptor> barriers) override#
Complete the second half of a split barrier.
Must be paired with a prior BeginSplitBarrier() call for the same resource(s). After this call the resource is fully transitioned.
- Parameters:
barriers – Array of split barrier descriptors to end.
-
virtual void CopyBuffer(IGraphicsBuffer *src, uint64_t srcOffset, IGraphicsBuffer *dst, uint64_t dstOffset, uint64_t size) override#
Record a buffer-to-buffer copy command.
-
virtual void CopyBufferToTexture(IGraphicsBuffer *src, uint64_t srcOffset, IGraphicsTexture *dst, uint32_t dstX, uint32_t dstY, uint32_t dstZ, uint32_t width, uint32_t height, uint32_t depth, uint32_t rowPitch) override#
Record a buffer-to-texture copy command.
- Parameters:
rowPitch – Byte stride between consecutive rows in the source buffer (must be aligned to 256).
-
virtual void CopyTextureToBuffer(IGraphicsTexture *src, uint32_t srcX, uint32_t srcY, uint32_t srcZ, IGraphicsBuffer *dst, uint64_t dstOffset, uint32_t width, uint32_t height, uint32_t depth) override#
Record a texture-to-buffer copy command.
-
virtual void CopyTexture(IGraphicsTexture *src, uint32_t srcX, uint32_t srcY, uint32_t srcZ, IGraphicsTexture *dst, uint32_t dstX, uint32_t dstY, uint32_t dstZ, uint32_t width, uint32_t height, uint32_t depth) override#
Record a texture-to-texture copy command.
-
virtual void Dispatch(uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ) override#
Record a compute dispatch command.
-
virtual void DispatchIndirect(IGraphicsBuffer *indirectArgsBuffer, uint64_t offset) override#
Record a compute dispatch indirect command.
-
virtual void BindComputePipeline(IComputePipeline *pipeline) override#
Bind a compute pipeline for subsequent dispatch calls.
- Parameters:
pipeline – The compute pipeline to bind (must be a valid IComputePipeline).
-
virtual void SetComputeBindGroup(uint32_t groupIndex, IBindGroup *bindGroup, std::span<const uint32_t> dynamicOffsets = {}) override#
Set a bind group at the given group/set index for compute operations.
The bind group must conform to the layout declared at that index in the currently bound compute pipeline’s descriptor.
- Parameters:
groupIndex – The group/set index (0-based, corresponds to @group(N) in WGSL).
bindGroup – The bind group to set.
dynamicOffsets – Optional dynamic offsets for dynamic uniform/storage buffer bindings.
-
virtual void Draw(uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance) override#
Record a draw command.
- Parameters:
vertexCount – Number of vertices to draw
instanceCount – Number of instances to draw
firstVertex – Index of the first vertex
firstInstance – Index of the first instance
-
virtual void DrawIndexed(uint32_t indexCount, uint32_t instanceCount, uint32_t firstIndex, int32_t vertexOffset, uint32_t firstInstance) override#
Record an indexed draw command.
- Parameters:
indexCount – Number of indices to draw
instanceCount – Number of instances to draw
firstIndex – Index of the first index
vertexOffset – Value added to each index before fetching vertex data
firstInstance – Index of the first instance
-
virtual void DrawIndirect(IGraphicsBuffer *indirectArgsBuffer, uint64_t offset) override#
Record an indirect draw command.
- Parameters:
indirectArgsBuffer – Buffer containing draw arguments (must be created with indirect usage flag)
offset – Byte offset into the buffer where draw arguments start
-
virtual void DrawIndexedIndirect(IGraphicsBuffer *indirectArgsBuffer, uint64_t offset) override#
Record an indexed indirect draw command.
- Parameters:
indirectArgsBuffer – Buffer containing draw arguments (must be created with indirect usage flag)
offset – Byte offset into the buffer where draw arguments start
-
virtual void SetVertexBuffer(uint32_t slot, IGraphicsBuffer *buffer, uint64_t offset = 0) override#
Set vertex buffer.
- Parameters:
slot – Binding slot for the vertex buffer
buffer – Vertex buffer to bind
offset – Byte offset into the buffer
-
virtual void SetIndexBuffer(IGraphicsBuffer *buffer, uint64_t offset = 0) override#
Set index buffer.
- Parameters:
buffer – Index buffer to bind
offset – Byte offset into the buffer
-
virtual void SetViewport(float x, float y, float width, float height, float minDepth, float maxDepth) override#
Set viewport.
- Parameters:
x – Top-left x coordinate of the viewport
y – Top-left y coordinate of the viewport
width – Width of the viewport
height – Height of the viewport
minDepth – Minimum depth value (0.0 to 1.0)
maxDepth – Maximum depth value (0.0 to 1.0)
-
virtual void SetScissor(int32_t x, int32_t y, uint32_t width, uint32_t height) override#
Set scissor rectangle.
- Parameters:
x – Top-left x coordinate of the scissor rectangle
y – Top-left y coordinate of the scissor rectangle
width – Width of the scissor rectangle
height – Height of the scissor rectangle
-
virtual void BeginRenderPass(const RenderPassDescriptor &descriptor) override#
Begin render pass with descriptor (WebGPU-style)
- Parameters:
descriptor – Render pass configuration describing color and depth/stencil attachments
-
virtual void EndRenderPass() override#
End render pass.
-
virtual void BindPipeline(IPipeline *pipeline) override#
Bind graphics pipeline.
- Parameters:
pipeline – Pipeline to bind (must be a graphics pipeline compatible with the current render pass)
-
virtual void SetBindGroup(uint32_t groupIndex, IBindGroup *bindGroup, std::span<const uint32_t> dynamicOffsets = {}) override#
Set a bind group at the given group/set index for graphics operations.
The bind group must conform to the layout declared at that index in the currently bound graphics pipeline’s descriptor.
In WebGPU terms this corresponds to setBindGroup on the render pass encoder. In Vulkan terms this maps to vkCmdBindDescriptorSets.
- Parameters:
groupIndex – The group/set index (0-based, corresponds to @group(N) in WGSL / set = N in Vulkan / space N in D3D12).
bindGroup – The bind group to set.
dynamicOffsets – Optional dynamic offsets for dynamic uniform/storage buffer bindings within the bind group.
-
inline wgpu::CommandEncoder GetEncoder() const#
-
inline wgpu::CommandBuffer GetCommandBuffer() const#
-
inline wgpu::RenderPassEncoder GetRenderPass() const#
-
explicit WebGPUGraphicsCommandList(wgpu::Device device)#
-
class WebGPUGraphicsDevice : public Hush::Graphics::IGraphicsDevice#
- #include <WebGPUGraphicsDevice.hpp>
WebGPU graphics device implementation.
Public Functions
-
explicit WebGPUGraphicsDevice(void *windowHandle)#
Constructor.
- Parameters:
windowHandle – Platform window handle (SDL_Window*)
-
~WebGPUGraphicsDevice() override#
-
WebGPUGraphicsDevice(const WebGPUGraphicsDevice&) = delete#
-
WebGPUGraphicsDevice(WebGPUGraphicsDevice&&) = delete#
-
WebGPUGraphicsDevice &operator=(const WebGPUGraphicsDevice&) = delete#
-
WebGPUGraphicsDevice &operator=(WebGPUGraphicsDevice&&) = delete#
-
inline virtual EGraphicsAPI GetAPI() const override#
Get the graphics API backend.
-
virtual Hush::Graphics::GraphicsDeviceCapabilities GetCapabilities() const override#
Get device capabilities.
-
inline virtual bool IsInitialized() const override#
Check if device is initialized.
-
virtual std::unique_ptr<IGraphicsBuffer> CreateBuffer(const BufferDescriptor &descriptor) override#
Create a buffer.
- Parameters:
descriptor – Buffer creation parameters
- Returns:
Created buffer, or nullptr on failure
-
virtual void WriteBuffer(IGraphicsBuffer *buffer, uint64_t offset, const void *data, uint64_t size) override#
Write data from the CPU into a GPU buffer.
This is the primary mechanism for uploading uniform data, vertex data, or any other CPU-side payload into a GPU buffer. The buffer must have been created with appropriate usage flags (e.g. EBufferUsage::Uniform with EMemoryAccess::CPUWrite).
On WebGPU this maps to wgpu::Queue::writeBuffer(). On Vulkan/D3D12 this maps to a staging upload or direct map+copy.
- Parameters:
buffer – The destination GPU buffer.
offset – Byte offset into the buffer to start writing at.
data – Pointer to the source CPU data.
size – Number of bytes to write.
-
virtual std::unique_ptr<IGraphicsTexture> CreateTexture(const TextureDescriptor &descriptor) override#
Create a texture.
- Parameters:
descriptor – Texture creation parameters
- Returns:
Created texture, or nullptr on failure
-
virtual std::unique_ptr<ISampler> CreateSampler(const SamplerDescriptor &descriptor) override#
Create a sampler object.
Samplers control how textures are sampled in shaders: filtering modes, address (wrap) modes, LOD clamping, comparison function, and anisotropy. Samplers are immutable once created.
- Parameters:
descriptor – Sampler creation parameters.
- Returns:
Created sampler, or nullptr on failure.
-
virtual std::unique_ptr<IShaderModule> CreateShaderModule(const ShaderModuleDescriptor &descriptor) override#
Create a shader module from compiled bytecode or source text.
The descriptor should contain either binary bytecode (SPIR-V, DXIL) or source text (WGSL) depending on the backend, as produced by the Slang-based ShaderCompiler.
- Parameters:
descriptor – Shader module creation parameters (stage, entry point, bytecode/source).
- Returns:
Created shader module, or nullptr on failure.
-
virtual std::unique_ptr<IGraphicsPipeline> CreateGraphicsPipeline(const GraphicsPipelineDescriptor &descriptor) override#
Create a graphics (rasterization) pipeline.
The descriptor must reference valid shader modules (vertex + fragment) and at least one color target. Shader modules must have been created by this same device.
- Parameters:
descriptor – Graphics pipeline creation parameters.
- Returns:
Created pipeline, or nullptr on failure.
-
virtual std::unique_ptr<IComputePipeline> CreateComputePipeline(const ComputePipelineDescriptor &descriptor) override#
Create a compute pipeline.
The descriptor must reference a valid compute shader module created by this same device.
- Parameters:
descriptor – Compute pipeline creation parameters.
- Returns:
Created pipeline, or nullptr on failure.
-
virtual std::unique_ptr<IBindGroupLayout> CreateBindGroupLayout(const BindGroupLayoutDescriptor &descriptor) override#
Create a bind group layout.
A bind group layout declares the expected shape (binding indices, resource types, shader stage visibility) of a set of resource bindings. Layouts are used at pipeline creation time and when creating bind group instances.
- Parameters:
descriptor – Bind group layout creation parameters.
- Returns:
Created bind group layout, or nullptr on failure.
-
virtual std::unique_ptr<IBindGroup> CreateBindGroup(const BindGroupDescriptor &descriptor) override#
Create a bind group (a concrete set of resource bindings).
A bind group is an immutable collection of buffer, texture, and sampler bindings that can be set on a command list before draw or dispatch calls. It must conform to the layout specified in the descriptor.
- Parameters:
descriptor – Bind group creation parameters (layout + entries).
- Returns:
Created bind group, or nullptr on failure.
-
virtual std::unique_ptr<ICopyCommandList> CreateCopyCommandList() override#
Create a copy command list.
- Returns:
Created command list, or nullptr on failure
-
virtual std::unique_ptr<IComputeCommandList> CreateComputeCommandList() override#
Create a compute command list.
- Returns:
Created command list, or nullptr on failure
-
virtual std::unique_ptr<IGraphicsCommandList> CreateGraphicsCommandList() override#
Create a graphics command list.
- Returns:
Created command list, or nullptr on failure
-
virtual std::unique_ptr<IFence> CreateFence(uint64_t initialValue = 0) override#
Create a timeline fence for cross-queue GPU synchronization.
Timeline fences hold a monotonically increasing uint64 value. Queues can signal the fence to a value after completing work, and other queues (or the CPU) can wait until the fence reaches a required value.
The render graph creates one fence per queue and uses the SSIS algorithm to determine the minimal set of signal/wait pairs needed to respect cross-queue dependencies.
- Parameters:
initialValue – The starting value of the fence (typically 0).
- Returns:
Created fence, or nullptr on failure.
-
inline virtual ICommandQueue *GetGraphicsQueue() override#
Get the main graphics queue.
Note
This might return the same queue as GetComputeQueue or GetTransferQueue if the API doesn’t support separate queues Which is the case for WebGPU. To check if separate queues are supported, use the capabilities struct.
-
inline virtual ICommandQueue *GetComputeQueue() override#
Get a compute queue.
On backends that don’t expose multiple queues (e.g. WebGPU), this will return the same queue as GetGraphicsQueue().
-
inline virtual ICommandQueue *GetTransferQueue() override#
Get a transfer queue.
On backends that don’t expose multiple queues (e.g. WebGPU), this will return the same queue as GetGraphicsQueue().
-
inline virtual uint32_t MapPassTypeToQueueIndex(EQueueType passType) const override#
WebGPU exposes a single queue — collapse all pass types onto queue 0 so the render graph never generates cross-queue sync, fences, or separate execution plans.
-
virtual void BeginFrame() override#
Begin a new frame.
- Returns:
Swapchain texture handle, or nullptr on failure
-
virtual void EndFrame() override#
End frame and present.
-
virtual IGraphicsTexture *GetCurrentFrameTexture() const override#
Get the current frame’s swapchain texture.
-
virtual void Resize(uint32_t width, uint32_t height) override#
Resize the swapchain.
- Parameters:
width – New width
height – New height
-
virtual void AddToDeletionQueue(std::function<void()> &&deleteFunc) override#
Add a function to the deletion queue for deferred cleanup.
- Parameters:
deleteFunc – Deletion function
-
virtual void FlushDeletionQueue() override#
Flush deletion queue.
-
virtual void *GetNativeHandle() const override#
Get native device handle (API-specific)
-
inline wgpu::Device GetDevice() const#
-
inline wgpu::Instance GetInstance() const#
-
inline wgpu::Surface GetSurface() const#
-
inline wgpu::TextureFormat GetSurfaceFormat() const#
-
void PollEvents()#
-
explicit WebGPUGraphicsDevice(void *windowHandle)#
-
class WebGPUGraphicsPipeline : public Hush::Graphics::IGraphicsPipeline#
- #include <WebGPUPipeline.hpp>
WebGPU implementation of IGraphicsPipeline.
Wraps a wgpu::RenderPipeline created from the engine’s GraphicsPipelineDescriptor. All fixed-function and programmable state is baked into the native pipeline object at creation time.
Public Functions
-
inline WebGPUGraphicsPipeline(wgpu::Device device, const GraphicsPipelineDescriptor &descriptor)#
Construct a graphics pipeline from the engine descriptor.
Translates the descriptor into WebGPU-native structures and calls wgpu::Device::createRenderPipeline.
- Parameters:
device – The WebGPU device.
descriptor – The backend-agnostic graphics pipeline descriptor.
-
inline ~WebGPUGraphicsPipeline() override#
-
WebGPUGraphicsPipeline(const WebGPUGraphicsPipeline&) = delete#
-
WebGPUGraphicsPipeline &operator=(const WebGPUGraphicsPipeline&) = delete#
-
WebGPUGraphicsPipeline(WebGPUGraphicsPipeline&&) = delete#
-
WebGPUGraphicsPipeline &operator=(WebGPUGraphicsPipeline&&) = delete#
-
inline virtual bool IsValid() const override#
Check if the pipeline was created successfully and is usable.
A pipeline that failed creation (e.g. shader compilation error, incompatible state) will return false.
-
inline virtual std::string_view GetDebugName() const override#
Get the debug name assigned at creation time.
Returns an empty string_view if no debug name was provided.
-
inline virtual void *GetNativeHandle() const override#
Get the native API handle for the pipeline.
The returned pointer’s type depends on the backend:
WebGPU graphics: wgpu::RenderPipeline*
WebGPU compute: wgpu::ComputePipeline*
Vulkan: VkPipeline*
D3D12: ID3D12PipelineState*
Ownership is NOT transferred; the pipeline object retains ownership.
-
inline virtual uint32_t GetColorTargetCount() const override#
Get the number of color targets this pipeline was created with.
This corresponds to the number of ColorTargetState entries in the GraphicsPipelineDescriptor used at creation time. The render pass that this pipeline is used with must have a matching number of color attachments.
-
inline virtual bool HasDepthStencil() const override#
Returns true if the pipeline was created with depth/stencil state enabled.
When true, the render pass must include a depth/stencil attachment.
-
inline virtual uint32_t GetVertexBufferSlotCount() const override#
Get the number of vertex buffer slots this pipeline expects.
Corresponds to the number of VertexBufferLayout entries in the descriptor. Before a draw call, the application must bind at least this many vertex buffers via SetVertexBuffer().
-
inline wgpu::RenderPipeline GetPipeline() const#
Get the underlying wgpu::RenderPipeline directly.
-
inline WebGPUGraphicsPipeline(wgpu::Device device, const GraphicsPipelineDescriptor &descriptor)#
-
class WebGPUSampler : public Hush::Graphics::ISampler#
- #include <WebGPUSampler.hpp>
WebGPU implementation of ISampler.
Wraps a wgpu::Sampler that controls how textures are sampled (filtering, addressing, LOD clamping, comparison).
Public Functions
-
WebGPUSampler(wgpu::Device device, const SamplerDescriptor &descriptor)#
Construct a sampler from the engine descriptor.
Translates the SamplerDescriptor into a wgpu::SamplerDescriptor and creates the native wgpu::Sampler.
- Parameters:
device – The WebGPU device.
descriptor – The backend-agnostic sampler descriptor.
-
~WebGPUSampler() override#
-
WebGPUSampler(const WebGPUSampler&) = delete#
-
WebGPUSampler &operator=(const WebGPUSampler&) = delete#
-
WebGPUSampler(WebGPUSampler&&) = delete#
-
WebGPUSampler &operator=(WebGPUSampler&&) = delete#
-
inline virtual EFilterMode GetMagFilter() const override#
Get the magnification filter mode.
-
inline virtual EFilterMode GetMinFilter() const override#
Get the minification filter mode.
-
inline virtual EFilterMode GetMipmapFilter() const override#
Get the mip-map filter mode.
-
inline virtual EAddressMode GetAddressModeU() const override#
Get the address mode for the U axis.
-
inline virtual EAddressMode GetAddressModeV() const override#
Get the address mode for the V axis.
-
inline virtual EAddressMode GetAddressModeW() const override#
Get the address mode for the W axis.
-
inline virtual ECompareFunction GetCompareFunction() const override#
Get the comparison function (Undefined if not a comparison sampler).
-
inline virtual uint16_t GetMaxAnisotropy() const override#
Get the maximum anisotropy level.
-
virtual void *GetNativeHandle() const override#
Get the native API handle.
-
inline wgpu::Sampler GetSampler() const#
Get the underlying wgpu::Sampler directly.
-
WebGPUSampler(wgpu::Device device, const SamplerDescriptor &descriptor)#
-
class WebGPUShaderModule : public Hush::Graphics::IShaderModule#
- #include <WebGPUShaderModule.hpp>
WebGPU implementation of a compiled shader module.
Wraps a wgpu::ShaderModule that was created from WGSL source text. The module is immutable after creation and can be shared across multiple pipelines that reference the same shader stage.
Public Functions
-
inline WebGPUShaderModule(wgpu::Device device, const ShaderModuleDescriptor &descriptor)#
Construct a WebGPU shader module from a descriptor and device.
The descriptor’s bytecode.sourceText must contain valid WGSL source. The module is created immediately during construction.
- Parameters:
device – The WebGPU device to create the module on.
descriptor – The shader module descriptor with WGSL source and metadata.
-
inline ~WebGPUShaderModule() override#
-
WebGPUShaderModule(const WebGPUShaderModule&) = delete#
-
WebGPUShaderModule &operator=(const WebGPUShaderModule&) = delete#
-
WebGPUShaderModule(WebGPUShaderModule&&) = delete#
-
WebGPUShaderModule &operator=(WebGPUShaderModule&&) = delete#
-
inline virtual EShaderStage GetStage() const override#
Get the shader stage this module was compiled for.
-
inline virtual std::string_view GetEntryPoint() const override#
Get the entry point name.
-
inline virtual bool IsValid() const override#
Check if the underlying wgpu::ShaderModule was created successfully.
-
inline virtual void *GetNativeHandle() const override#
Get the native wgpu::ShaderModule handle.
- Returns:
Pointer to the internal wgpu::ShaderModule. Ownership is NOT transferred; this object retains ownership.
-
inline wgpu::ShaderModule GetModule() const#
Get the underlying wgpu::ShaderModule directly.
-
inline const std::string &GetDebugName() const#
Get the debug name assigned at creation time.
-
inline WebGPUShaderModule(wgpu::Device device, const ShaderModuleDescriptor &descriptor)#
-
class WebGPUTexture : public Hush::Graphics::IGraphicsTexture#
- #include <WebGPUTexture.hpp>
WebGPU texture implementation.
Public Functions
-
WebGPUTexture(wgpu::Texture texture, wgpu::TextureView view, const TextureDescriptor &desc)#
-
~WebGPUTexture() override#
-
WebGPUTexture(const WebGPUTexture&) = delete#
-
WebGPUTexture(WebGPUTexture &&rhs) noexcept#
-
WebGPUTexture &operator=(const WebGPUTexture&) = delete#
-
WebGPUTexture &operator=(WebGPUTexture&&) noexcept#
-
inline virtual uint32_t GetWidth() const override#
Get texture width.
-
inline virtual uint32_t GetHeight() const override#
Get texture height.
-
inline virtual uint32_t GetDepth() const override#
Get texture depth.
-
inline virtual ETextureFormat GetFormat() const override#
Get texture format.
-
inline virtual uint32_t GetMipLevels() const override#
Get mip level count.
-
virtual void *GetNativeHandle() const override#
Get native handle (API-specific)
-
inline wgpu::Texture GetTexture() const#
-
inline wgpu::TextureView GetView() const#
-
WebGPUTexture(wgpu::Texture texture, wgpu::TextureView view, const TextureDescriptor &desc)#
-
namespace DefaultRenderer#
-
struct FinalPassResources#
- #include <DefaultRenderer.hpp>
Resources for the final pass that copies the rendered image to the backbuffer.
Public Members
-
Hush::RenderGraph::ResourceId backbuffer = {}#
-
Hush::RenderGraph::ResourceId backbuffer = {}#
-
struct GeometryPassResources#
Public Members
-
Hush::RenderGraph::ResourceId geometryBufferAlbedo = {}#
-
Hush::RenderGraph::ResourceId geometryBufferNormal = {}#
-
Hush::RenderGraph::ResourceId geometryDepthBuffer = {}#
-
Hush::RenderGraph::ResourceId geometryBufferAlbedo = {}#
-
struct LightingPassResources#
Public Members
-
Hush::RenderGraph::ResourceId lightingBuffer = {}#
-
Hush::RenderGraph::ResourceId lightingBuffer = {}#
-
struct FinalPassResources#
-
enum class EGraphicsAPI#
-
namespace Hashing#
-
namespace impl#
-
class QueryImpl#
Subclassed by Hush::Query< Hush::RenderGraph::RenderGraphBuilderComponent >, Hush::Query< Hush::WorldTransform, Hush::LocalTransform, Hush::Entity::Name >, Hush::Query< Hush::ToastNotification >, Hush::Query< Hush::Renderer::GpuUploadComponent, Hush::MeshReference >, Hush::Query< Hush::Renderer::GpuUploadComponent, Hush::Ref< Hush::TextureComponent > >, Hush::Query< const Hush::MeshReference, const Hush::WorldTransform >, Hush::Query< Hush::WorldTransform, Hush::LocalTransform >, Hush::Query< Components >
-
namespace QueryBuilderImpl#
-
class QueryImpl#
-
namespace Mat4Math#
-
namespace MathUtils#
-
namespace Networking#
-
namespace Reflection#
Functions
-
class FieldInfo#
Public Types
-
using EVariantError = Variant::EVariantError#
-
using Setter = std::function<EVariantError(std::span<const VariantView>)>#
-
using Getter = std::function<Result<Variant, EVariantError>(std::span<const VariantView>)>#
Public Functions
-
inline FieldInfo(TypeId typeId, std::string name, Setter setter, Getter getter, uint64_t offset = 0)#
-
inline std::string_view GetName() const#
-
inline Result<Variant, Variant::EVariantError> Get(std::span<const VariantView> args) const#
-
inline Result<Variant, Variant::EVariantError> Get(std::initializer_list<const VariantView> args) const#
-
inline EVariantError Set(const std::span<const VariantView> args) const#
-
inline EVariantError Set(std::initializer_list<VariantView> args) const#
-
inline uint64_t GetOffset() const#
-
using EVariantError = Variant::EVariantError#
-
class FunctionInfo#
Public Types
-
enum class EFunctionInfoError : uint8_t#
Values:
-
enumerator None#
-
enumerator InvalidType#
-
enumerator InvalidArgsCount#
-
enumerator InvalidArgsType#
-
enumerator NonMatchingArgs#
-
enumerator None#
-
using CallFunc = Result<Variant, EFunctionInfoError> (*)(std::span<const VariantView>)#
Public Functions
-
inline Result<Variant, EFunctionInfoError> Call(std::span<const VariantView> args) const#
Calls the function with the given arguments.
- Parameters:
returnVal – Return value type.
args – Arguments to the function.
- Returns:
Result with the return value or an error.
-
template<typename ...Args>
inline Result<Variant, EFunctionInfoError> Call(Args&&... args) const# Calls the function with the given arguments.
- Template Parameters:
Args – Arguments to the function.
- Parameters:
returnVal – Return value type.
args – Arguments to the function.
- Returns:
Result with the return value or an error.
-
inline std::uint64_t GetArgsCount() const#
-
inline bool IsCallableWith(std::span<const VariantView> args) const#
-
inline std::string_view GetName() const#
Public Static Functions
-
template<typename ...Args>
static inline FunctionInfo Create(CallFunc callFunc, std::string name)#
Public Static Attributes
-
static constexpr std::uint8_t MAX_ARGS = 16#
-
enum class EFunctionInfoError : uint8_t#
-
class ReflectionDB#
Public Functions
-
template<ReflectedType T>
inline RegisterClassBuilder<T> RegisterClass()#
-
template<typename T>
struct RegisterClassBuilder# Public Functions
-
inline explicit RegisterClassBuilder(ReflectionDB *reflectionDB)#
-
inline RegisterClassBuilder &AddConstructor(FunctionInfo constructor)#
-
inline RegisterClassBuilder &AddInPlaceConstructor(TypeInfo::InPlaceCtor ctor)#
-
inline RegisterClassBuilder &AddFunction(FunctionInfo function)#
-
inline RegisterClassBuilder &SizeOf(std::size_t size)#
-
inline RegisterClassBuilder &AlignmentOf(std::size_t alignment)#
-
inline RegisterClassBuilder &AddProperty(FieldInfo property)#
-
inline void Register()#
-
inline explicit RegisterClassBuilder(ReflectionDB *reflectionDB)#
-
template<ReflectedType T>
-
class TypeInfo#
Public Types
-
enum class EInPlaceConstructorError#
Values:
-
enumerator None#
-
enumerator InsufficientMemory#
-
enumerator NoInPlaceConstructors#
-
enumerator NonMatchingArgs#
-
enumerator InvalidType#
-
enumerator None#
-
using InPlaceCtorFunc = EInPlaceConstructorError (*)(void *mem, std::span<const VariantView>)#
Public Functions
-
inline void AddFunction(const FunctionInfo &function)#
-
inline std::span<const FunctionInfo> GetFunctions() const#
-
inline std::optional<std::reference_wrapper<const FieldInfo>> GetField(std::string_view name) const#
-
inline const std::string &GetName() const#
-
inline void SetName(std::string_view name)#
-
inline std::size_t GetSize() const#
-
inline void SetSize(std::size_t size)#
-
inline std::size_t GetAlignment() const#
-
inline void SetAlignment(std::size_t alignment)#
-
inline Result<Variant, FunctionInfo::EFunctionInfoError> CreateInstance(std::span<const VariantView> args) const#
Creates an instance of this type with the given arguments and returns it as a Variant. If you wish to create an instance in a specific memory location, or avoid heap allocation, use CreateInPlaceInstance(void *mem, size_t memSize, std::span<const VariantView> args) const instead.
Note
This function might allocate memory for the instance, depending on the size of the type. See Hush::Reflection::Variant::MAX_SIZE for the maximum size of a type that can be created without allocating in the heap.
- Parameters:
args – Arguments to pass to the constructor.
- Returns:
Result with the created instance or an error.
-
inline Result<Variant, FunctionInfo::EFunctionInfoError> CreateInstance(std::initializer_list<const VariantView> args) const#
Creates an instance of this type with the given arguments. See CreateInstance(std::span<constVariantView> args) const for more information.
- Parameters:
args – Arguments to pass to the constructor.
- Returns:
Result with the created instance or an error.
-
inline std::optional<EInPlaceConstructorError> CreateInPlaceInstance(void *mem, size_t memSize, std::span<const VariantView> args) const#
Creates an instance of this type in-place using the provided memory and arguments. This function checks if the provided memory is sufficient and if there are any in-place constructors available.
When using this function, ensure that the memory provided is properly aligned for the type being constructed. Also, the memory must be large enough to hold the type’s data.
Note
This function is designed for advanced use cases where you need to create an instance of a type in a specific memory location, This function never allocates memory for the instance.
Warning
Keep in mind that this function does not keep track of the lifetime of the created instance. You’re responsible for managing the memory and ensuring that the instance is destroyed properly.
- Parameters:
mem – Pointer to the memory where the instance should be created.
memSize – Size of the memory in bytes. Must be at least as large as the size of the type.
args – Arguments to pass to the in-place constructor.
- Returns:
An optional error if the in-place construction fails, or an empty optional if it succeeds.
-
inline std::optional<EInPlaceConstructorError> CreateInPlaceInstance(void *mem, size_t memSize, std::initializer_list<const VariantView> args) const#
Creates an instance of this type in-place using the provided memory and arguments. See CreateInPlaceInstance(void *mem, size_t memSize, std::span<const VariantView> args) const for more information.
- Parameters:
mem – Pointer to the memory where the instance should be created.
memSize – Size of the memory in bytes.
args – Arguments to pass to the in-place constructor.
- Returns:
An optional error if the in-place construction fails, or an empty optional if it succeeds.
-
inline Result<Variant, FunctionInfo::EFunctionInfoError> CallFunction(std::string_view name, std::span<const VariantView> args) const#
Calls a function with the given name and arguments. This helper function searches for a function in O(n) time, where n is the number of functions in this type. This also supports overloaded functions, as it checks the argument types to find a matching function.
- Parameters:
name – Name of the function to call.
args – Arguments to pass to the function.
- Returns:
Result with the return value or an error.
-
inline Result<Variant, FunctionInfo::EFunctionInfoError> CallFunction(std::string_view name, std::initializer_list<const VariantView> args) const#
Calls a function with the given name and arguments. This is a convenience overload that allows passing arguments as an initializer list. For more information, see the CallFunction(std::string_view name, std::span<const VariantView> args) const function.
- Parameters:
name – Name of the function to call.
args – Arguments to pass to the function.
- Returns:
Result with the return value or an error.
-
inline void SetConstructors(std::vector<FunctionInfo> &&constructors)#
-
inline void SetFunctions(std::vector<FunctionInfo> &&functions)#
-
inline void SetInPlaceCtors(std::vector<InPlaceCtor> &&inPlaceCtor)#
Sets the in-place constructors for this type.
- Parameters:
inPlaceCtor – A vector of in-place constructors to set.
-
struct InPlaceCtor#
Public Functions
-
inline InPlaceCtor(InPlaceCtorFunc callFunc, std::span<const TypeId> args)#
-
inline EInPlaceConstructorError ConstructUnchecked(void *mem, std::span<const VariantView> args) const#
-
inline bool IsCallableWith(std::span<const VariantView> args) const#
Public Members
-
std::array<TypeId, FunctionInfo::MAX_ARGS> m_argsType#
-
InPlaceCtorFunc m_func#
-
uint8_t m_argsCount = {}#
Public Static Functions
-
template<typename ...Args>
static inline InPlaceCtor Create(InPlaceCtorFunc callFunc)#
-
inline InPlaceCtor(InPlaceCtorFunc callFunc, std::span<const TypeId> args)#
-
enum class EInPlaceConstructorError#
-
class Variant#
Public Types
-
using EVariantError = VariantView::EVariantError#
-
using EVariantError = VariantView::EVariantError#
-
struct VariantView#
- #include <Variant.hpp>
A VariantView that holds a reference to any type.
-
class FieldInfo#
-
namespace Renderer#
-
struct GpuUploadComponent#
- #include <GpuUploadComponent.hpp>
ECS component used to mark entities that require GPU uploads.
This is a simple empty struct that serves as a marker. Entities with this component will be processed by the ResourceUploadSystem, which will perform the necessary GPU uploads and then remove this tag when done.
Tagging other entities is not supported as it won’t do anything. You can implement your own system to handle uploads for other resource types. But it is not recommended to do so.
Note
Only TextureComponent and MeshReference entities should be tagged with this component, as the ResourceUploadSystem assumes these types when processing uploads.
Public Types
Public Members
-
size_t cpuOffset = 0#
Byte offset into the staging buffer where this entity’s data is located.
-
EUploadMode uploadMode = EUploadMode::Full#
Upload mode for this entity’s resource.
-
size_t cpuOffset = 0#
-
class ResourceUploadSystem : public Hush::ISystem#
Public Functions
-
ResourceUploadSystem(Scene &scene, RenderGraph::RenderDevice *renderDevice, uint64_t stagingBufferSize = DEFAULT_STAGING_BUFFER_SIZE)#
Construct the system with a scene, render device, and optional staging buffer size.
- Parameters:
scene – The scene this system belongs to.
renderDevice – Non-owning pointer to the render device that owns the render graph and executor. Must outlive this system.
stagingBufferSize – Total size in bytes of the CPU-mapped staging buffer. Half is used for meshes, the other half for textures. Defaults to 128 MiB.
-
~ResourceUploadSystem() override = default#
-
ResourceUploadSystem(const ResourceUploadSystem&) = delete#
-
ResourceUploadSystem &operator=(const ResourceUploadSystem&) = delete#
-
ResourceUploadSystem(ResourceUploadSystem&&) = delete#
-
ResourceUploadSystem &operator=(ResourceUploadSystem&&) = delete#
-
virtual void OnShutdown() override#
OnShutdown() is called when the system is shutting down.
-
virtual void OnUpdate(float delta) override#
OnRender() is called when the system should render.
- Parameters:
delta – Time since last frame
-
virtual void OnFixedUpdate(float delta) override#
OnFixedUpdate() is called when the system should update its state.
- Parameters:
delta – Time since last fixed frame
-
virtual void OnPreRender() override#
CPU-only staging pass.
Iterates all entities that carry a GpuMeshUploadState or GpuTextureUploadState component. For each dirty resource the CPU data is memcpy’d into the staging buffer and a pending copy descriptor is appended.
No GPU calls are made here — the actual copies are deferred to the render-graph Transfer pass.
-
virtual void OnRender() override#
OnRender() is called when the system should render.
-
virtual void OnPostRender() override#
OnPostRender() is called after rendering.
-
inline virtual std::string_view GetName() const override#
GetName() is used to get the name of the system
- Returns:
Name of the system
-
inline uint64_t GetStagingBufferSize() const noexcept#
Get the total staging buffer size (in bytes).
-
inline uint64_t GetHalfQuota() const noexcept#
Get the per-half upload quota (in bytes).
-
inline uint64_t GetBytesUploadedLastFrame() const noexcept#
Get the number of bytes staged during the most recent OnPreRender() invocation.
-
inline RenderGraph::ResourceId GetUploadSyncResourceId() const noexcept#
Return the render-graph ResourceId of the upload sync token.
Rendering passes that consume uploaded mesh/texture data should call
ctx.Read(id)on this resource in their build callback to create a dependency edge that ensures the Transfer pass completes before they execute.Note
The returned ID is only valid after the render graph has been built for the current frame (i.e. after the RenderGraphSystem invokes the builder callbacks).
-
inline bool HasPendingUploads() const noexcept#
Return true if there are pending copies to issue this frame (i.e. the Transfer pass has actual work to do).
-
inline const std::vector<PendingBufferCopy> &GetPendingBufferCopies() const noexcept#
Read-only access to the pending buffer copies for the current frame. Used by the Transfer pass execute callback.
-
inline const std::vector<PendingTextureCopy> &GetPendingTextureCopies() const noexcept#
Read-only access to the pending texture copies for the current frame. Used by the Transfer pass execute callback.
-
inline Graphics::IGraphicsBuffer *GetStagingBuffer() const noexcept#
Get the raw staging buffer pointer (for the Transfer pass execute callback to issue CopyBuffer commands against).
Public Static Attributes
-
static constexpr uint64_t DEFAULT_STAGING_BUFFER_SIZE = 128ULL * 1024ULL * 1024ULL#
Total size of the CPU-mapped intermediate staging buffer used to ferry data from CPU memory to the GPU. Default: 128 MiB.
-
static constexpr uint64_t DEFAULT_MESH_STAGING_SIZE = DEFAULT_STAGING_BUFFER_SIZE / 2#
The first half of the staging buffer (64 MiB) is reserved for mesh vertex/index uploads.
-
static constexpr uint64_t DEFAULT_TEXTURE_STAGING_SIZE = DEFAULT_STAGING_BUFFER_SIZE / 2#
The second half of the staging buffer (64 MiB) is reserved for texture uploads.
-
static constexpr size_t MAX_RESOURCE_UPLOADS_PER_FRAME = 64#
Maximum number of individual resource uploads processed in a single frame. Acts as an upper bound to prevent pathological iteration over a very large number of dirty entities.
-
struct PendingBufferCopy#
- #include <ResourceUploadSystem.hpp>
Describes a single buffer-to-buffer copy that will be recorded into the Transfer pass command list.
-
struct PendingTextureCopy#
- #include <ResourceUploadSystem.hpp>
Describes a single buffer-to-texture copy that will be recorded into the Transfer pass command list.
Public Members
-
uint64_t stagingOffset#
Byte offset into the staging buffer.
-
Graphics::IGraphicsTexture *destination#
Target GPU texture.
-
uint32_t dstX#
Destination X offset in texels.
-
uint32_t dstY#
Destination Y offset in texels.
-
uint32_t dstZ#
Destination Z offset (layer / depth).
-
uint32_t width#
Width of the region to copy (texels).
-
uint32_t height#
Height of the region to copy (texels).
-
uint32_t depth#
Depth of the region to copy.
-
uint32_t rowPitch#
Aligned bytes-per-row in the staging buffer.
-
uint64_t stagingOffset#
-
struct UploadPassData#
- #include <ResourceUploadSystem.hpp>
Pass-local data stored inside the render-graph Transfer pass.
Public Members
-
RenderGraph::ResourceId stagingBufferResource = {}#
Imported staging buffer (Read).
-
RenderGraph::ResourceId syncToken = {}#
Transient sync token (Write).
-
RenderGraph::ResourceId stagingBufferResource = {}#
-
ResourceUploadSystem(Scene &scene, RenderGraph::RenderDevice *renderDevice, uint64_t stagingBufferSize = DEFAULT_STAGING_BUFFER_SIZE)#
-
struct GpuUploadComponent#
-
namespace RenderGraph#
Enums
Functions
-
inline Hush::Graphics::EQueueType PassTypeToQueueType(EPassType passType)#
Maps EPassType to Graphics::EQueueType.
-
struct CommandListBatch#
- #include <RenderGraphExecutor.hpp>
Represents a group of command lists to be submitted together in a single ExecuteCommandLists call, surrounded by fence waits and/or signals.
This is the fundamental execution unit described in the article’s “Command list batching” section. Batches are split whenever a fence signal or wait requirement is detected while iterating through passes on a queue within a dependency level.
Public Members
-
std::vector<Hush::Graphics::FenceWaitDescriptor> fenceWaits#
Fence wait operations to perform BEFORE executing any command lists. The queue will not begin executing command lists in this batch until all wait conditions are satisfied.
-
std::vector<Hush::Graphics::ICommandList*> commandLists#
Command lists to execute in this batch, in submission order. Each command list should already be closed (recorded and finalized). During batch building these are nullptr placeholders; during submission they are replaced with real command list pointers.
-
std::vector<Hush::Graphics::FenceSignalDescriptor> fenceSignals#
Fence signal operations to perform AFTER all command lists complete. Typically signals the queue’s own timeline fence to allow dependent queues to proceed.
-
bool isTransitionRerouteBatch = false#
Whether this batch contains the rerouted transitions command list. When true, this batch is the dedicated “transitions” batch that runs on the most competent queue before the main work batches.
-
std::vector<Hush::Graphics::FenceWaitDescriptor> fenceWaits#
-
struct DependencyLevelExecutionContext#
- #include <RenderGraphExecutor.hpp>
Holds transient execution data built during Execute() for a single dependency level. This includes barriers, rerouted transitions, and the per-queue execution plans.
Public Members
-
std::vector<QueueExecutionPlan> queuePlans#
Per-queue execution plans for this dependency level. Index corresponds to queue index.
-
std::vector<Hush::Graphics::ResourceBarrierDescriptor> reroutedBarriers#
Resources that require rerouted transitions in this dependency level (read by multiple queues, or transition unsupported on receiving queue).
-
uint32_t mostCompetentQueueIndex = 0#
Index of the queue responsible for executing rerouted transitions.
-
std::vector<QueueExecutionPlan> queuePlans#
-
template<typename PassData, typename ExecuteFn>
class Pass : public Hush::RenderGraph::PassBase# - #include <RenderGraph.hpp>
Templated pass implementation that stores PassData and execution callback.
Public Functions
-
inline virtual void Execute(Hush::Graphics::ICommandList *cmdList, const ResourceManager &resourceManager) override#
Executes the current pass with the given command list.
- Parameters:
commandList – Command list appropriate for this pass type.
resourceManager – Provides access to resources declared in the graph.
-
inline virtual void Execute(Hush::Graphics::ICommandList *cmdList, const ResourceManager &resourceManager) override#
-
struct PassBase#
- #include <RenderGraph.hpp>
Base class for all passes.
This is not meant to be used directly by users but instead the Pass template. However, implementing this manually can be useful for language bindings.
Subclassed by Hush::RenderGraph::Pass< PassData, ExecuteFn >
Public Functions
-
PassBase() = default#
-
virtual ~PassBase() = default#
-
virtual void Execute(Hush::Graphics::ICommandList *commandList, const ResourceManager &resourceManager) = 0#
Executes the current pass with the given command list.
- Parameters:
commandList – Command list appropriate for this pass type.
resourceManager – Provides access to resources declared in the graph.
-
PassBase() = default#
-
struct QueueExecutionPlan#
- #include <RenderGraphExecutor.hpp>
Describes the full execution plan for a single queue across one dependency level.
For queues involved in cross-queue dependencies, the plan may contain:
A rerouted transitions batch (barriers from other queues).
One or more work batches, split at fence signal/wait boundaries.
For queues NOT involved in cross-queue dependencies, the plan simply contains work batches with no rerouting, where split barriers can be used for better performance.
Public Members
-
uint32_t queueIndex = 0#
Index of the queue this plan belongs to (maps to EPassType).
-
std::vector<CommandListBatch> batches#
Ordered list of command list batches to submit on this queue. Batches are submitted sequentially; within each batch, command lists are submitted together in a single API call.
-
bool requiresTransitionRerouting = false#
True if this queue is involved in cross-queue transition rerouting for the current dependency level.
-
bool isMostCompetentQueue = false#
True if this queue is the “most competent queue” responsible for performing rerouted resource transitions.
-
class RenderDevice#
- #include <RenderDevice.hpp>
High-level rendering orchestrator.
Owns the render graph (declaration + compilation) and the executor (runtime GPU work), and holds a non-owning reference to the graphics device that both depend on.
This is the class that game/engine code should interact with for all render-graph-based rendering. Lower-level access to the device or graph internals is available through accessor methods when needed.
Public Functions
-
inline explicit RenderDevice(Hush::Graphics::IGraphicsDevice *device)#
Construct a RenderDevice from a non-owning device pointer.
- Parameters:
device – The graphics device backend. Must outlive this RenderDevice instance. Ownership is NOT transferred.
-
~RenderDevice() = default#
-
RenderDevice(const RenderDevice&) = delete#
-
RenderDevice &operator=(const RenderDevice&) = delete#
-
RenderDevice(RenderDevice&&) = delete#
-
RenderDevice &operator=(RenderDevice&&) = delete#
-
inline void BeginFrame()#
Begin a new frame.
Delegates to the graphics device’s BeginFrame() to acquire the next swapchain image. Call this before registering any passes for the frame.
-
inline void EndFrame()#
End the current frame and present.
Delegates to the graphics device’s EndFrame() which typically presents the swapchain image. Call this after execution is complete.
-
template<typename PassData, typename BuildFn, typename ExecuteFn>
inline const PassData &AddPass(EPassType passType, std::string_view name, BuildFn &&buildFn, ExecuteFn &&execFn)# Register a render pass with typed local data, a build callback, and an execute callback.
This is a thin forwarding wrapper around RenderGraph::AddPass. See that method for full documentation on the callback signatures.
- Template Parameters:
PassData – Per-pass data struct (default-constructible).
BuildFn – void(BuildContext&, PassData&)
ExecuteFn – void(PassData&, ICommandList*, ResourceManager&)
- Parameters:
passType – The queue type this pass targets.
name – Debug name for the pass.
buildFn – Called immediately to declare resource dependencies.
execFn – Called during execution to record GPU commands.
- Returns:
Reference to the initialized PassData (owned by the graph).
-
inline void Compile()#
Compile the render graph if it is dirty.
This performs topological sort, dependency level assignment, and SSIS-based synchronization point culling. It is a no-op if the graph is already compiled.
-
inline void Execute()#
Execute the compiled render graph.
This:
Realizes any unrealized transient GPU resources.
Initializes resource state tracking.
For each dependency level, builds barriers, batches command lists, and submits them with proper fence synchronization.
- Pre:
The graph must be compiled (not dirty). Call Compile() first or use CompileAndExecute().
-
inline void CompileAndExecute()#
Convenience method: compile (if dirty) then execute.
This is the typical call in a frame loop after all passes have been registered.
-
inline void Reset()#
Reset the render graph and executor state for a fresh frame.
Clears all passes, resources, and compilation state from the graph. Resets the executor’s per-frame fence counters and resource state tracker (fence objects themselves are reused).
Call this at the start of a frame (before or after BeginFrame) if you are rebuilding the graph each frame. If your graph is static across frames, you only need to call this when the graph changes.
-
inline void SoftReset()#
Lightweight per-frame reset that keeps the graph compiled.
Only resets the executor’s per-frame state (resource state tracker and fence value counters). The graph’s passes, resources, topology, and compilation output are all preserved.
Use this instead of Reset() when the graph topology has not changed and you only need to update per-frame imported resources (e.g. swapchain backbuffer) via RenderGraph::UpdateImport().
-
inline void Invalidate() noexcept#
Mark the render graph as dirty, forcing a full rebuild next frame.
Unlike Reset(), this does NOT clear passes, resources, or compilation data immediately. It simply flips the graph’s state flag so that the next frame’s OnPreRender() takes the slow path (full Reset + rebuild
Compile).
Call this when something external invalidates the current graph structure — e.g. a window resize that changes render target dimensions, a scene change that adds/removes passes, etc.
-
inline RenderGraph &GetRenderGraph() noexcept#
Get a mutable reference to the underlying render graph.
Useful for advanced scenarios where you need direct access to the graph structure (e.g. for debugging, visualization, or custom compilation steps).
-
inline const RenderGraph &GetRenderGraph() const noexcept#
Get a const reference to the underlying render graph.
-
inline RenderGraphExecutor &GetExecutor() noexcept#
Get a mutable reference to the executor.
Useful for advanced scenarios like manually controlling fence values or inspecting execution state.
-
inline const RenderGraphExecutor &GetExecutor() const noexcept#
Get a const reference to the executor.
-
inline Hush::Graphics::IGraphicsDevice *GetGraphicsDevice() const noexcept#
Get the underlying graphics device.
Useful for creating resources outside the graph (e.g. swapchain images that are later imported via BuildContext::Import).
-
inline ResourceManager &GetResourceManager() noexcept#
Get the resource manager from the render graph.
Convenience shortcut for GetRenderGraph().GetResourceManager().
-
inline const ResourceManager &GetResourceManager() const noexcept#
Get the resource manager from the render graph (const).
-
inline bool IsCompiled() const noexcept#
Check if the render graph is compiled and ready for execution.
-
inline bool IsDirty() const noexcept#
Check if the render graph is dirty and needs recompilation.
-
inline void Resize(uint32_t width, uint32_t height)#
Resize the swapchain through the graphics device.
- Parameters:
width – New width in pixels.
height – New height in pixels.
-
inline explicit RenderDevice(Hush::Graphics::IGraphicsDevice *device)#
-
class RenderGraph#
- #include <RenderGraph.hpp>
Render graph implementation based on DAG scheduling.
Based on the article: https://levelup.gitconnected.com/organizing-gpu-work-with-directed-acyclic-graphs-f3fd5f2c2af3
This class is a pure data structure representing the dependency graph of render passes. It owns passes, computes the optimal execution order (topological sort), groups passes into dependency levels, and determines the minimal set of synchronization points (SSIS algorithm).
It does NOT interact with the GPU in any way. All execution, barrier computation, fence management, and command list batching are handled by RenderGraphExecutor. This separation allows:
Testing the graph without a GPU device
Swapping execution strategies without changing the graph
Clear ownership: RenderDevice owns both the graph and the executor
Public Functions
-
RenderGraph() = default#
-
inline void SetQueueMap(EPassType passType, uint32_t queueIndex) noexcept#
Set the physical queue index for a given logical pass type.
Call this once after construction (typically from RenderDevice) to inform the graph how pass types map to physical queues. On multi-queue backends the default mapping (Graphics=0, Compute=1, Transfer=2) is used. Single-queue backends (WebGPU) should set all entries to 0.
-
inline uint32_t GetMappedQueueIndex(EPassType passType) const noexcept#
Get the physical queue index for a given logical pass type.
-
template<typename PassData, typename BuildFn, typename ExecuteFn>
inline const PassData &AddPass(EPassType passType, std::string_view name, BuildFn &&buildFn, ExecuteFn &&execFn)# Add a pass with typed local data and the two callbacks (build, execute)
-
void Compile()#
Compile the render graph, optimizing and culling passes as needed.
-
inline bool IsDirty() const noexcept#
Check if the render graph is dirty and needs recompilation.
-
inline bool IsCompiled() const noexcept#
Check if the render graph has been compiled and is ready for execution.
-
template<ResourceConcept T>
inline void UpdateImport(ResourceId id, T &&newResource)# Update an imported (external) resource’s data in-place.
This replaces the underlying resource instance (e.g. swapchain backbuffer pointer) for an already-imported resource without modifying graph topology, resource IDs, or compilation state. The graph remains in the Compiled state after this call.
Use this inside a per-frame update callback to swap per-frame imported handles instead of tearing down and rebuilding the entire graph every frame.
- Template Parameters:
T – Must satisfy ResourceConcept and match the type used at the original Import() call site.
- Parameters:
id – The ResourceId returned by the original Import().
newResource – The replacement resource instance to move in.
-
inline void Invalidate() noexcept#
Mark a compiled graph as dirty, forcing a full rebuild next frame.
Unlike Reset(), this does NOT clear passes, resources, or compilation data. It simply flips the state flag so that the next frame’s OnPreRender() takes the slow path (full Reset + rebuild + Compile).
Call this when something external invalidates the current graph structure — e.g. a window resize that changes render target dimensions, a scene change that adds/removes passes, etc.
-
void Reset()#
Reset the graph to allow rebuilding.
Clears all passes, resources, and compilation state. After reset, the graph is empty and dirty — ready for fresh pass registration.
-
inline const std::vector<RenderPassNode> &GetPasses() const noexcept#
-
inline std::vector<RenderPassNode> &GetPasses() noexcept#
-
inline const std::vector<DependencyLevel> &GetDependencyLevels() const noexcept#
-
inline std::vector<DependencyLevel> &GetDependencyLevels() noexcept#
-
inline uint32_t GetDetectedQueueCount() const noexcept#
-
inline ResourceManager &GetResourceManager() noexcept#
-
inline const ResourceManager &GetResourceManager() const noexcept#
-
inline const boost::unordered_flat_map<ResourceId, Hush::Graphics::EResourceState> &GetImportedResourceInitialStates() const noexcept#
Get the initial states declared for imported resources. The executor uses this to initialize its resource state tracker.
Public Static Attributes
-
static constexpr std::string_view RESOURCE_UPLOAD_SYNC_TOKEN_NAME = "Hush__UploadSyncToken__"#
Sync token name for the resource upload system. Passes that consume uploaded resources should Read this resource in their build callback to create a dependency edge on the Transfer pass.
-
static constexpr uint32_t PASS_TYPE_COUNT = 3#
Number of distinct EPassType values (Graphics, Compute, Transfer).
Construct a render graph.
Note: the graph itself has no device dependency. The device is only needed by the executor at execution time.
-
class BuildContext#
- #include <RenderGraph.hpp>
Allows creating resources and declaring usage (read/write) during the build phase of a pass.
Resource creation is deferred: Create() stores a descriptor and a default-constructed resource instance but does NOT allocate the GPU resource. The executor calls ResourceHandle::CreateResource() during its realization step before execution begins.
Public Functions
-
ResourceId Read(ResourceId id, Hush::Graphics::EResourceState desiredState = Hush::Graphics::EResourceState::AnyShaderAccess)#
Read a resource inside of the pass.
-
ResourceId Write(ResourceId id, Hush::Graphics::EResourceState desiredState = Hush::Graphics::EResourceState::UnorderedAccess)#
Write a resource inside of the pass.
-
template<Hush::RenderGraph::ResourceConcept T>
inline ResourceId Create(std::string_view name, const typename T::Descriptor &&desc)# Create a transient resource inside of the pass.
The resource descriptor is stored and a default-constructed resource instance is created, but actual GPU allocation is deferred until the executor’s realization phase. This allows the graph to be built without any device dependency.
-
template<Hush::RenderGraph::ResourceConcept T>
inline ResourceId Import(std::string_view name, T &&externalResource, Hush::Graphics::EResourceState initialState = Hush::Graphics::EResourceState::Undefined)# Import an external resource into the graph (e.g. swapchain image).
Imported resources are considered already realized because they are created and managed outside the graph. The executor will NOT call CreateResource() on these.
- Template Parameters:
T – Must satisfy ResourceConcept
- Parameters:
name – Debug name for the resource
externalResource – The actual resource instance created outside the graph
initialState – The current resource state of the imported resource
- Returns:
ResourceId that can be used to reference this resource in the graph
-
void SetCullingMode(RenderPassNode::EPassCullingMode cullMode)#
Set the culling mode for this pass.
-
inline ResourceId GetResourceIdByName(std::string_view name) const#
-
ResourceId Read(ResourceId id, Hush::Graphics::EResourceState desiredState = Hush::Graphics::EResourceState::AnyShaderAccess)#
-
class DependencyLevel#
- #include <RenderGraph.hpp>
Represents a dependency level — a group of passes that can execute in parallel.
Passes within a single dependency level share the same maximum recursion depth (longest path from root). They have no dependencies on each other and can be executed in arbitrary order, which enables parallel work execution across queues.
Public Types
-
using NodeList = std::list<RenderPassNode*>#
Public Functions
-
inline const std::vector<std::vector<RenderPassNode*>> &GetNodesPerQueue() const noexcept#
-
inline const boost::unordered_flat_set<uint32_t> &GetQueuesInvolvedInCrossDependencies() const noexcept#
-
inline const boost::unordered_flat_set<ResourceId> &GetResourcesReadByMultipleQueues() const noexcept#
-
inline uint32_t GetLevelIndex() const noexcept#
Friends
- friend class RenderGraph
- friend class RenderGraphExecutor
-
using NodeList = std::list<RenderPassNode*>#
-
struct RenderGraphBuilderComponent#
- #include <RenderGraphBuilderComponent.hpp>
Component that encapsulates a builder function for constructing the render graph.
When the RenderGraph is reset, it will invoke the builder function to allow the user to declare the render passes and resources for the new frame. This component is designed to be instantiated only once and persist across frames, as it holds the logic for building the graph structure.
An optional
frameUpdateFunccan be provided to perform lightweight per-frame updates (e.g. swapping the swapchain backbuffer pointer via UpdateImport) without tearing down and recompiling the entire graph. When the graph is already compiled, onlyframeUpdateFuncis invoked; when the graph is dirty (first frame, after a resize, after an explicit reset, etc.),builderFuncis invoked to perform the full rebuild and the update callback is skipped for that frame since the builder already set up all resources.Public Types
-
using BuilderFunc = std::function<void(RenderGraph &graph)>#
Public Members
-
BuilderFunc builderFunc#
Function to build the render graph from scratch.
Called when the graph is dirty and needs a full rebuild (first frame, after a resize, after an explicit invalidation, etc.). The callback should declare all passes and resources via AddPass / Create / Import.
-
BuilderFunc frameUpdateFunc#
Optional lightweight per-frame update function.
Called every frame when the graph is already compiled and does NOT need a full rebuild. Use this to update per-frame imported resources (e.g. swapchain backbuffer) via
RenderGraph::UpdateImportwithout modifying graph topology or triggering recompilation.If this is null, the system falls back to a full reset + rebuild + compile every frame (the previous behaviour).
-
using BuilderFunc = std::function<void(RenderGraph &graph)>#
-
class RenderGraphExecutor#
- #include <RenderGraphExecutor.hpp>
Executes a compiled RenderGraph on the GPU.
The executor is the runtime counterpart to the RenderGraph. While the graph describes what work to do and in what order (computed at compile time), the executor determines how to do it on the GPU:
Resource realization: creates actual GPU resources from the deferred handles declared during the graph’s build phase.
Resource state tracking: maintains the current GPU state of every resource and computes resource barriers.
Transition rerouting
: detects when a receiving queue cannot perform a state transition and reroutes it to the “most competent
queue” (usually graphics).
Command list batching: groups command lists between fence waits and signals for optimal submission.
Fence management: creates and manages per-queue timeline fences for cross-queue synchronization.
Owned by RenderDevice alongside the RenderGraph.
Public Functions
-
explicit RenderGraphExecutor(Hush::Graphics::IGraphicsDevice *device)#
Construct an executor bound to a graphics device.
- Parameters:
device – The graphics device used to create command lists, fences, and query queue capabilities. Must outlive the executor.
-
~RenderGraphExecutor() = default#
-
RenderGraphExecutor(const RenderGraphExecutor&) = delete#
-
RenderGraphExecutor &operator=(const RenderGraphExecutor&) = delete#
-
RenderGraphExecutor(RenderGraphExecutor&&) = default#
-
RenderGraphExecutor &operator=(RenderGraphExecutor&&) = default#
-
void Execute(RenderGraph &graph)#
Execute a compiled render graph.
- Parameters:
graph – A compiled (non-dirty) render graph. The graph is passed by mutable reference because execution may update per-node fence signal values.
-
void ResetFrameState()#
Reset execution state between frames (or when the graph is reset).
Clears resource state tracking and resets fence value counters. Fences themselves are NOT destroyed (they are reused across frames).
-
class RenderPassNode#
- #include <RenderGraph.hpp>
Represents a single pass inside of the render graph.
A pass is a unit of work that reads and writes GPU resources. There are two execution contexts when creating a pass:
Build context: Used to declare resource usage (reads/writes) and create resources.
Execute context: Used to perform the actual rendering work.
Public Types
Public Functions
-
inline RenderPassNode(std::string_view name, uint32_t nodeId, EPassType passType, std::unique_ptr<PassBase> &&pass, uint32_t queueIndex = std::numeric_limits<uint32_t>::max())#
-
inline std::string_view GetName() const noexcept#
-
inline uint32_t GetQueueIndex() const noexcept#
-
inline uint32_t GetUnorderedIndex() const noexcept#
-
inline uint32_t GetDependencyLevelIndex() const noexcept#
-
inline bool IsSyncSignalRequired() const noexcept#
-
inline const boost::unordered_flat_set<ResourceId> &GetReadResources() const noexcept#
-
inline const boost::unordered_flat_set<ResourceId> &GetWrittenResources() const noexcept#
-
inline const std::vector<RenderPassNode*> &GetNodesToSync() const noexcept#
-
inline const std::vector<uint64_t> &GetSyncIndexSet() const noexcept#
-
class ResourceHandle#
Public Functions
-
ResourceHandle() = delete#
-
ResourceHandle(const ResourceHandle&) = delete#
-
ResourceHandle(ResourceHandle&&) noexcept = default#
-
~ResourceHandle() = default#
-
ResourceHandle &operator=(const ResourceHandle&) = delete#
-
ResourceHandle &operator=(ResourceHandle&&) noexcept = delete#
-
inline EHandleType GetHandleType() const noexcept#
-
inline uint32_t GetResourceId() const noexcept#
-
inline bool IsRealized() const noexcept#
Check whether the underlying GPU resource has been allocated.
During the render graph build phase, transient resources are declared but not yet created on the GPU. The executor calls CreateResource() during a realization step, after which this returns true.
External (imported) resources are always considered realized because they are created outside the graph and provided fully formed.
-
inline void CreateResource(Hush::Graphics::IGraphicsDevice *ctx)#
Create the underlying GPU resource and mark the handle as realized.
This should only be called once per handle (typically by the executor during its resource realization phase). Calling it on an already-realized handle is a no-op.
- Parameters:
ctx – The graphics device used to allocate the GPU resource.
-
inline void DestroyResource(Hush::Graphics::IGraphicsDevice *ctx)#
-
inline void BeforeRead(uint32_t flags, void *ctx)#
-
inline void BeforeWrite(uint32_t flags, void *ctx)#
-
inline void *GetNativePtr() const#
Get an opaque pointer to the underlying native GPU resource.
Used by the render graph’s barrier computation to populate ResourceBarrierDescriptor::resource. The actual type depends on the concrete resource (e.g. ID3D12Resource*, VkImage, wgpu::Texture, etc.).
- Returns:
Opaque pointer to the native resource, or nullptr if not yet created.
-
template<ResourceConcept T>
inline void UpdateExternalResource(T &&newResource)# Replace the resource instance of an External (imported) handle in-place.
This is used to update per-frame imported resources (e.g. the current swapchain backbuffer) without tearing down and rebuilding the entire render graph. The graph topology, compilation state, and resource IDs all remain unchanged — only the underlying data pointer is swapped.
- Template Parameters:
T – Must satisfy ResourceConcept and match the type originally used when the resource was imported.
- Parameters:
newResource – The new resource instance to move into the handle.
- Pre:
The handle must be External (imported). Calling this on a Transient handle is a logic error and will assert.
Public Static Attributes
-
static constexpr uint32_t RESOURCE_INITIAL_VERSION = 1#
-
ResourceHandle() = delete#
-
struct ResourceId#
Public Functions
-
inline bool operator==(const ResourceId &other) const#
-
inline bool operator!=(const ResourceId &other) const#
Public Members
-
uint32_t id = 0#
-
inline bool operator==(const ResourceId &other) const#
-
class ResourceManager#
- #include <RenderGraph.hpp>
Manages logical resources within the render graph, including creation, tracking, and resolution.
Note
Resources declared here are logical: the ResourceHandle holds a descriptor and (for transient resources) a default-constructed resource instance. Actual GPU allocation is deferred to the executor’s realization phase (ResourceHandle::CreateResource). For imported resources, the GPU object is provided at declaration time and is already realized.
Public Functions
-
ResourceManager() = default#
-
~ResourceManager() = default#
-
ResourceManager(const ResourceManager&) = delete#
-
ResourceManager &operator=(const ResourceManager&) = delete#
-
ResourceManager(ResourceManager&&) = delete#
-
ResourceManager &operator=(ResourceManager&&) = delete#
-
inline void AddResource(std::string name, ResourceId id, Hush::RenderGraph::ResourceHandle handle)#
-
inline Hush::RenderGraph::ResourceHandle *GetResourceHandle(const ResourceId &id) const#
-
inline Hush::RenderGraph::ResourceHandle *GetResourceHandle(std::string_view name) const#
-
inline ResourceId GetResourceId(std::string_view name) const#
-
template<typename T>
inline T *GetResource(const ResourceId &id) const#
-
template<ResourceConcept T>
inline void UpdateResource(const ResourceId &id, T &&newResource)# Update the resource instance of an existing imported (External) handle.
This swaps the underlying data (e.g. swapchain backbuffer pointer) without modifying graph topology, resource IDs, or compilation state.
- Template Parameters:
T – Must satisfy ResourceConcept and match the type used at import time.
- Parameters:
id – The ResourceId of the imported resource to update.
newResource – The replacement resource instance.
-
template<typename Fn>
inline void ForEachResource(Fn &&fn) const# Iterate over all resource handles (used by the executor for realization)
-
inline size_t GetResourceCount() const noexcept#
Get the total number of resources in the manager.
-
inline void Clear()#
-
ResourceManager() = default#
-
struct ResourceStateEntry#
- #include <RenderGraphExecutor.hpp>
Tracks the current GPU state of a resource across passes and queues.
The executor maintains one of these per resource. It is used during execution to compute resource barriers:
Which state a resource is currently in.
Which queue last accessed it (needed for cross-queue transitions).
Whether the resource is currently being read by multiple queues simultaneously (multi-queue read).
Public Members
-
Hush::Graphics::EResourceState currentState = Hush::Graphics::EResourceState::Undefined#
-
uint32_t owningQueueIndex = std::numeric_limits<uint32_t>::max()#
Index of the queue that last wrote or transitioned this resource. UINT32_MAX means “unknown / never accessed.”
-
bool inMultiQueueRead = false#
True when the resource is being read by more than one queue in the same dependency level. In that case barriers must be rerouted.
-
class ResourceStateTracker#
- #include <RenderGraphExecutor.hpp>
Manages per-resource GPU state for the duration of a frame’s execution.
Initialized from the graph’s imported resource initial states and reset each frame. The executor updates entries as it inserts barriers.
Public Functions
-
ResourceStateTracker() = default#
-
~ResourceStateTracker() = default#
-
ResourceStateTracker(const ResourceStateTracker&) = delete#
-
ResourceStateTracker &operator=(const ResourceStateTracker&) = delete#
-
ResourceStateTracker(ResourceStateTracker&&) = default#
-
ResourceStateTracker &operator=(ResourceStateTracker&&) = default#
-
inline void InitializeFromGraph(const RenderGraph &graph)#
Initialize state tracking from a compiled graph.
Creates entries for every resource in the graph. Imported resources get their initial state from the graph’s stored initial-state map; transient resources start as Undefined.
-
inline ResourceStateEntry *GetState(const ResourceId &id)#
Get the current tracked state of a resource.
-
inline const ResourceStateEntry *GetState(const ResourceId &id) const#
Get the current tracked state of a resource (const).
-
inline void SetState(const ResourceId &id, Hush::Graphics::EResourceState newState, uint32_t owningQueueIndex)#
Update the tracked state of a resource after a transition.
-
inline void SetMultiQueueRead(const ResourceId &id, bool value)#
Mark a resource as being in a multi-queue read state.
-
inline void Clear()#
Clear all tracked state (call between frames or on graph reset).
-
ResourceStateTracker() = default#
-
inline Hush::Graphics::EQueueType PassTypeToQueueType(EPassType passType)#
-
namespace Serialization#
Enums
-
enum class EFormatDescribingType#
Describing format type. A self-describing format is a format that includes the type information in the format itself. For instance, JSON contains the name of the field along with the value (which is of a specific type). A non-self-describing format is a format that does not include the type information in the format itself. For instance, a binary format may not include the name of the field along with the value.
Values:
-
enumerator SelfDescribing#
Self-describing format.
-
enumerator NonSelfDescribing#
Non-self-describing format.
-
enumerator SelfDescribing#
Functions
-
template<typename T>
inline Result<T, EDeserializationError> DeserializeJson(std::string_view json)#
-
template<typename T>
inline Result<std::string, ESerializationError> SerializeJson(const T &value)#
-
class IVisitor#
- #include <Deserialization.hpp>
Base class for visitors. A Serialization visitor is a class that implements the visitor pattern to visit the different types of data that a format passes. For instance, when a JSON parser sees a number, it will call the VisitInt method of the visitor.
TODO(Alan): how a non-self-describing format will work? We might need to implement a VisitRaw(const char* data,
size_t maxSize, size_t currentOffset)?
Subclassed by Hush::Serialization::BuiltinVisitors::FloatVisitor< double >, Hush::Serialization::BuiltinVisitors::FloatVisitor< float >, Hush::Serialization::BuiltinVisitors::IntVisitor< int16_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< int32_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< int64_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< int8_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< uint16_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< uint32_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< uint64_t >, Hush::Serialization::BuiltinVisitors::IntVisitor< uint8_t >, Hush::Serialization::Visitor< T, typename >
Public Types
-
using Result = Hush::Result<IVisitor*, EDeserializationError>#
Public Functions
-
inline IVisitor(IVisitor *parent, EFormatDescribingType format)#
-
virtual ~IVisitor() = default#
-
inline virtual Result VisitInt8(std::int8_t value)#
Visit a signed 8-bit integer.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitInt16(std::int16_t value)#
Visit a signed 16-bit integer.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitInt32(std::int32_t value)#
Visit a signed 32-bit integer.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitInt64(std::int64_t value)#
Visit a signed 64-bit integer.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitUInt8(std::uint8_t value)#
Visit an unsigned 8-bit integer.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitUInt16(std::uint16_t value)#
Visit an unsigned 16-bit integer.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitUInt32(std::uint32_t value)#
Visit an unsigned 32-bit integer.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitUInt64(std::uint64_t value)#
Visit an unsigned 64-bit integer.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitFloat(float value)#
Visit a float value.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitDouble(double value)#
Visit a double value.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitBool(bool value)#
Visit a boolean value.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitString(std::string_view value)#
Visit a string value.
- Parameters:
value – Value to visit
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitNull()#
Visit a null value.
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitArrayStart()#
Visit an array start.
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitArrayEnd()#
Visit the end of an array.
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitObjectStart()#
Visit the start of an object.
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitObjectEnd()#
Visit the end of an object.
- Returns:
Result with the next visitor or an error.
-
inline virtual Result VisitKey(std::string_view value)#
Visit a key in an object.
- Parameters:
value – Key to visit
- Returns:
Result with the next visitor or an error.
-
using Result = Hush::Result<IVisitor*, EDeserializationError>#
-
class JsonDeserializer#
Public Functions
-
inline JsonDeserializer(std::string_view json)#
-
template<typename T>
inline Result<T, EDeserializationError> Deserialize()#
-
template<typename T>
inline Result<T, EDeserializationError> Deserialize()
-
inline JsonDeserializer(std::string_view json)#
-
class JsonSerializer#
- #include <JsonSerializer.hpp>
JsonSerializer class.
This class is used to serialize data to a JSON string. It has member functions to set keys, start and end objects, and serialize data. It also supports serializing custom types that follow the IsSerializable concept.
Public Functions
-
inline JsonSerializer()#
-
inline ESerializationError SetKey(std::string_view key)#
Sets the key for the next value to be serialized.
- Parameters:
key – Key to serialize
- Returns:
SerializationError
-
inline ESerializationError BeginObject()#
Begins an object in the JSON string.
- Returns:
SerializationError
-
inline ESerializationError EndObject()#
Ends an object in the JSON string.
- Returns:
SerializationError
-
template<IsSerializable<JsonSerializer> T>
inline ESerializationError Serialize(const T &value)# Serializes an object to a JSON string.
- Template Parameters:
T – Serializable object
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<typename T>
inline ESerializationError Serialize(const T&)#
-
template<typename T>
inline ESerializationError Serialize(const T)#
-
template<typename T>
inline ESerializationError SerializeArray(const std::span<const T> values)# Serializes a span of values to a JSON array.
- Parameters:
values – Value to serialize
- Returns:
SerializationError
-
template<typename V, IsMapIterator<std::string, V> It>
inline ESerializationError SerializeMap(It begin, It end)# Serializes a map of values to a JSON object.
- Template Parameters:
V – Value type
It – Iterator type
- Parameters:
begin – Begin iterator
end – End iterator
- Returns:
SerializationError
-
template<typename T>
inline ESerializationError Serialize(std::string_view key, const T &value)# Serializes a key-value pair to a JSON object.
- Template Parameters:
T – Type
- Parameters:
key – Key
value – Value
- Returns:
SerializationError
-
template<typename T>
inline ESerializationError Serialize(std::string_view key, const std::span<const T> values)# Serializes an array of values to a JSON array.
- Template Parameters:
T – Type
- Parameters:
key – Key
values – Values
- Returns:
SerializationError
-
template<typename V, IsMapIterator<std::string, V> It>
inline ESerializationError Serialize(std::string_view key, It begin, It end)# Serializes a map of values to a JSON object.
- Template Parameters:
V – Value type
It – Iterator type
- Parameters:
key – Key
begin – Iterator begin
end – Iterator end
- Returns:
SerializationError
-
inline std::string FinishSerialization()#
Finalizes the serialization process and returns the serialized JSON string. You should not call any other function after this one.
- Returns:
Serialized JSON string
-
template<>
inline ESerializationError Serialize(const double value)# Serializes a double value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const float value)# Serializes a float value to a JSON string.
- Parameters:
key – Key to serialize
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const bool value)# Serializes a boolean value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::uint8_t value)# Serializes an uint8 value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::uint16_t value)# Serializes an uint16 value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::uint32_t value)# Serializes an uint32 value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::uint64_t value)# Serializes an uint64 value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::int8_t value)# Serializes an int8 value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::int16_t value)# Serializes an int16 value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::int32_t value)# Serializes an int32 value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::int64_t value)# Serializes an int64 value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::string &value)# Serializes a string value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
template<>
inline ESerializationError Serialize(const std::string_view value)# Serializes a string_view value to a JSON string.
- Parameters:
value – Value to serialize
- Returns:
SerializationError
-
inline JsonSerializer()#
-
template<typename T, typename = void>
struct Visitor : public Hush::Serialization::IVisitor# Public Functions
-
inline Visitor(IVisitor *parent, T *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, T *value, EFormatDescribingType describingType)#
- template<typename T> Visitor< T > : public Hush::Serialization::BuiltinVisitors::Visitor< T > , public decltypestd::declval< T & >Deserializestd::declval , public EFormatDescribingType::NonSelfDescribing
Public Types
-
using Parent = decltype(std::declval<T&>().Deserialize(std::declval<IVisitor*>(), EFormatDescribingType::NonSelfDescribing))#
-
using Type = T#
Public Functions
-
inline Visitor(IVisitor *parent, T *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, T *value, EFormatDescribingType describingType)
-
using Parent = decltype(std::declval<T&>().Deserialize(std::declval<IVisitor*>(), EFormatDescribingType::NonSelfDescribing))#
-
namespace BuiltinVisitors#
-
template<typename F>
struct FloatVisitor : public Hush::Serialization::IVisitor# Public Types
-
using Exists = std::true_type#
Public Functions
-
inline FloatVisitor(IVisitor *parent, F *value, EFormatDescribingType describingType)#
-
using Exists = std::true_type#
-
template<typename IntType>
struct IntVisitor : public Hush::Serialization::IVisitor# Public Types
-
using Exists = std::true_type#
Public Functions
-
inline IntVisitor(IVisitor *parent, IntType *value, EFormatDescribingType describingType)#
-
using Exists = std::true_type#
-
template<typename T>
struct Visitor : public Hush::Serialization::IVisitor# Subclassed by Hush::Serialization::Visitor< T >
Public Types
-
using Exists = std::false_type#
-
using Exists = std::false_type#
-
template<>
struct Visitor<bool> : public Hush::Serialization::IVisitor# Public Functions
-
inline Visitor(IVisitor *parent, bool *value, EFormatDescribingType describingType)#
Public Members
-
bool *value = {}#
-
inline Visitor(IVisitor *parent, bool *value, EFormatDescribingType describingType)#
-
template<>
struct Visitor<double> : public Hush::Serialization::BuiltinVisitors::FloatVisitor<double># Public Functions
-
inline Visitor(IVisitor *parent, double *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, double *value, EFormatDescribingType describingType)#
-
template<>
struct Visitor<float> : public Hush::Serialization::BuiltinVisitors::FloatVisitor<float># Public Types
-
using Exists = std::true_type#
Public Functions
-
inline Visitor(IVisitor *parent, float *value, EFormatDescribingType describingType)#
-
using Exists = std::true_type#
-
template<>
struct Visitor<int16_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<int16_t># Public Functions
-
inline Visitor(IVisitor *parent, int16_t *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, int16_t *value, EFormatDescribingType describingType)#
-
template<>
struct Visitor<int32_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<int32_t># Public Functions
-
inline Visitor(IVisitor *parent, int32_t *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, int32_t *value, EFormatDescribingType describingType)#
-
template<>
struct Visitor<int64_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<int64_t># Public Functions
-
inline Visitor(IVisitor *parent, int64_t *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, int64_t *value, EFormatDescribingType describingType)#
-
template<>
struct Visitor<int8_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<int8_t># Public Types
-
using Exists = std::true_type#
Public Functions
-
inline Visitor(IVisitor *parent, int8_t *value, EFormatDescribingType describingType)#
-
using Exists = std::true_type#
-
template<>
struct Visitor<std::map<std::string, std::string>> : public Hush::Serialization::IVisitor# Public Types
-
using Exists = std::true_type#
Public Functions
-
inline Visitor(IVisitor *parent, std::map<std::string, std::string> *value, EFormatDescribingType describingType)#
-
using Exists = std::true_type#
-
template<>
struct Visitor<std::string> : public Hush::Serialization::IVisitor# Public Types
-
using Exists = std::true_type#
Public Functions
-
inline Visitor(IVisitor *parent, std::string *value, EFormatDescribingType describingType)#
Public Members
-
std::string *value = {}#
-
using Exists = std::true_type#
-
template<>
struct Visitor<uint16_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<uint16_t># Public Functions
-
inline Visitor(IVisitor *parent, uint16_t *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, uint16_t *value, EFormatDescribingType describingType)#
-
template<>
struct Visitor<uint32_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<uint32_t># Public Functions
-
inline Visitor(IVisitor *parent, uint32_t *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, uint32_t *value, EFormatDescribingType describingType)#
-
template<>
struct Visitor<uint64_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<uint64_t># Public Functions
-
inline Visitor(IVisitor *parent, uint64_t *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, uint64_t *value, EFormatDescribingType describingType)#
-
template<>
struct Visitor<uint8_t> : public Hush::Serialization::BuiltinVisitors::IntVisitor<uint8_t># Public Functions
-
inline Visitor(IVisitor *parent, uint8_t *value, EFormatDescribingType describingType)#
-
inline Visitor(IVisitor *parent, uint8_t *value, EFormatDescribingType describingType)#
-
template<typename F>
-
enum class EFormatDescribingType#
-
namespace StringUtils#
Provides utility functions for handling strings (C and std strings)
Functions
-
std::wstring ToWString(const char *data)#
Converts the given char* to a standard wstring, used for Windows, since char_t* is wchar_t*.
- Parameters:
data – String to convert
- Returns:
wstring of the converted string, from 8B to 16B chars
-
std::string FromWString(const std::wstring &str)#
-
inline std::string ToUpper(const std::string_view &str)#
-
constexpr std::string_view SubstrView(const std::string &str, int32_t offset, int32_t endIdx)#
-
std::wstring ToWString(const char *data)#
-
namespace Tests#
-
namespace Threading#
Enums
Functions
-
constexpr uint64_t Pack(uint32_t workerHead, uint32_t stealerHead) noexcept#
Pack two 32-bit integers into a 64-bit integer.
-
constexpr std::tuple<uint32_t, uint32_t> Unpack(uint64_t value) noexcept#
Unpack a 64-bit integer into two 32-bit integers.
- Parameters:
value – The 64-bit integer to unpack.
- Returns:
A tuple containing the worker’s head index and the stealer’s head index.
-
template<typename T>
Task<void> RunOn(Hush::Threading::Concepts::Executor auto *executor, Task<T> task)#
-
inline impl::SelfDeleteTask MakeSelfDeleteTask(Task<void> task) noexcept#
-
template<Concepts::Awaitable A, typename T = typename Concepts::AwaitableTraits<A>::ResultType>
decltype(auto) Wait(A &&awaitable)#
-
template<Concepts::Awaitable... Awaitables>
auto WhenAll(Awaitables&&... awaitables)#
-
template<std::ranges::range RangeType, Concepts::Awaitable AwaitableType = typename std::ranges::range_value_t<RangeType>, typename T = typename Concepts::AwaitableTraits<AwaitableType>::ResultType>
auto WhenAll(RangeType awaitables)#
Variables
-
static constexpr size_t MAX_PARALLEL_TASKS = 1024#
-
static constexpr size_t MIN_CHUNK_SIZE = 1000#
-
template<typename T, size_t Size>
class Stealer# - #include <StealingQueue.hpp>
Handle for multi-threaded stealing operations.
- Template Parameters:
T – The type of the items in the queue.
Size – The size of the queue. It must be a power of 2 and less than 2^31.
-
template<typename T, size_t Size>
class StealingQueue# - #include <StealingQueue.hpp>
This queue is heavily inspired by the work of asynchronics/st3, which is a Rust implementation of a stealing queue. Its work is MIT-licensed and can be found at: asynchronics/st3
Its work is based on Tokio’s worker queue, itself based on Go scheduler work-stealing queues.
Unlike his implementation, we use a statically-sized array to store the data because it is meant to be used by our thread pool.
This queue is a ring buffer with wrap-around semantics with a tail and a head positions. The actual buffer index is the least significant bits of the tail and head positions.
- Template Parameters:
T – The type of the elements stored in the queue. It must be a trivial type (non trivial types could be implemented in the future).
Size – The size of the queue. It must be a power of 2 and less than 2^31.
Public Functions
-
inline StealingQueue() noexcept#
-
StealingQueue(const StealingQueue&) = delete#
-
StealingQueue &operator=(const StealingQueue&) = delete#
-
StealingQueue(StealingQueue&&) = delete#
-
StealingQueue &operator=(StealingQueue&&) = delete#
-
~StealingQueue() noexcept#
-
T &ReadAt(uint32_t index) noexcept#
Read an item at the given index in the queue.
This position is mapped to a valid ring buffer index using the mask.
For this to work correctly, the item must have been previously initialized at that index.
- Parameters:
index – The index to read from. It must be less than the capacity of the queue.
- Returns:
A reference to the item at the given index.
-
void WriteAt(uint32_t index, T &&value) noexcept#
Write an item at the given index in the queue.
This position is mapped to a valid ring buffer index using the mask.
If a previous item was at that index, it will be overwritten and not destructed. So care must be taken.
- Parameters:
index – The index to write to.
value – The value to write at the given index. It must be a valid item.
-
template<typename F>
Result<std::tuple<uint32_t, uint32_t>, EStealError> MarkForSteal(F &countFunc, uint32_t maxCount)# Attempt to mark a range of items for stealing. The amount of items is determined by the provided function
countFunc, which is invoked with the number of items available in the queue.In case of success, it returns a tuple containing the stealer’s head index and the number of items. The number of items is guaranteed to be at least 1.
If the queue is empty, it returns
EStealError::Empty. If the queue is busy (concurrent stealing operation), it returnsEStealError::Busy.- Template Parameters:
F – The type of the function that will be used to determine the number of items to steal. It must take a size_t and return a size_t.
- Parameters:
countFunc – The function that will be used to determine the number of items to steal. It is invoked with the number of items available in the queue.
maxCount – The maximum number of items to steal. It is used to limit the number of items stolen in case the function returns a larger value than the available items.
- Returns:
A Result containing a tuple with the stealer’s head index and the number of items stolen, or an EStealError in case of failure.
-
inline constexpr uint32_t Capacity() const noexcept#
-
template<typename T>
class SyncWait#
-
template<typename T>
class SyncWaitTask# - #include <SyncWait.hpp>
Sync wait task.
Public Types
-
using promise_type = impl::SyncWaitPromise<T>#
-
using CoroutineType = std::coroutine_handle<promise_type>#
Public Functions
-
inline SyncWaitTask(CoroutineType coroutine) noexcept#
Constructor
- Parameters:
coroutine – coroutine handle
-
inline SyncWaitTask(SyncWaitTask &&other) noexcept#
Move constructor
- Parameters:
other – Other SyncWaitTask to move from
-
inline SyncWaitTask &operator=(SyncWaitTask &&other) noexcept#
Move assignment operator
- Parameters:
other – Other SyncWaitTask to move from
- Returns:
self
-
SyncWaitTask(const SyncWaitTask&) = delete#
-
SyncWaitTask &operator=(const SyncWaitTask&) = delete#
-
inline ~SyncWaitTask()#
Destructor.
-
inline promise_type &promise() & noexcept#
Returns the promise
- Returns:
The promise
-
inline const promise_type &promise() const & noexcept#
Returns the promise
- Returns:
The promise
-
inline promise_type &&promise() && noexcept#
Returns the promise
- Returns:
The promise
-
inline CoroutineType GetCoroutine() const noexcept#
Returns the coroutine
- Returns:
The coroutine
-
inline CoroutineType GetCoroutine() noexcept#
Returns the coroutine
- Returns:
The coroutine
-
using promise_type = impl::SyncWaitPromise<T>#
-
template<typename T>
struct Task# -
Public Functions
-
inline Task() noexcept#
-
inline explicit Task(std::coroutine_handle<promise_type> coroutine) noexcept#
-
inline ~Task()#
-
inline bool Ready() const noexcept#
-
inline bool Resume()#
-
inline auto operator co_await() const & noexcept#
-
inline std::coroutine_handle<promise_type> GetCoroutine() const noexcept#
-
inline Task() noexcept#
-
template<typename T, size_t Size>
class Worker# - #include <StealingQueue.hpp>
Handle for single-threaded FIFO operations.
- Template Parameters:
T – The type of the items in the queue.
Size – The size of the queue. It must be a power of 2 and less than 2^31.
Public Functions
-
Worker() noexcept#
-
Stealer<T, Size> MakeStealer() noexcept#
Creates a new stealer associated with this worker queue.
Any number of stealers can be created from a single worker queue.
- Returns:
A new Stealer instance that can be used to steal items from this worker queue.
-
size_t Capacity() const noexcept#
Returns the capacity of the worker queue.
- Returns:
The capacity of the worker queue, which is equal to Size.
-
size_t SpareCapacity() const noexcept#
Returns the number of items that can be succesfully pushed onto the queue.
This number might not reflect the real number due to concurrent stealing operations.
- Returns:
The number of items that can be succesfully pushed onto the queue.
-
bool IsEmpty() const noexcept#
Returns true if the worker queue is empty, false otherwise.
While the queue size might not be accurate, it is guaranteed that if a call to
IsEmpty()returns true, a subsequent call toPop()will fail.- Returns:
True if the worker queue is empty, false otherwise.
-
namespace Concepts#
-
-
template<Awaitable A, typename = void>
struct AwaitableTraits#
-
template<Awaitable A>
struct AwaitableTraits<A># Public Types
-
using AwaiterType = decltype(GetAwaiter(std::declval<A>()))#
-
using ResultType = decltype(std::declval<AwaiterType>().await_resume())#
-
using AwaiterType = decltype(GetAwaiter(std::declval<A>()))#
-
template<typename T, typename = void>
struct ExecutorTraits#
-
template<Awaitable A, typename = void>
-
namespace Executors#
Variables
-
static constexpr size_t WORKER_QUEUE_SIZE = 256#
-
static constexpr size_t GLOBAL_QUEUE_STEALING_COUNT = 64#
-
thread_local WorkerThread *G_CURRENT_WORKER_THREAD = nullptr#
-
class TaskOperation#
-
class ThreadPool#
Public Functions
-
ThreadPool(const ThreadPool &other) = delete#
-
ThreadPool &operator=(const ThreadPool &other) = delete#
-
ThreadPool(ThreadPool &&other) noexcept = delete#
-
ThreadPool &operator=(ThreadPool &&other) noexcept = delete#
-
ThreadPool() = delete#
-
~ThreadPool()#
-
TaskOperation Schedule()#
-
inline uint32_t GetNumThreads() const noexcept#
Public Static Functions
-
static ThreadPool Create(ThreadPoolOptions options = ThreadPoolOptions())#
-
ThreadPool(const ThreadPool &other) = delete#
-
struct ThreadPoolOptions#
-
class WorkerThread#
Public Functions
-
inline WorkerThread(ThreadPool &threadpool, std::barrier<> &startBarrier, int32_t threadAffinity)#
-
inline void SetStealers(std::vector<Stealer<TaskOperation*, WORKER_QUEUE_SIZE>> workers) noexcept#
-
inline void Wake() noexcept#
-
inline Stealer<TaskOperation*, WORKER_QUEUE_SIZE> MakeStealer() noexcept#
-
inline void Stop() noexcept#
-
inline void Join() noexcept#
-
inline WorkerThread(ThreadPool &threadpool, std::barrier<> &startBarrier, int32_t threadAffinity)#
-
static constexpr size_t WORKER_QUEUE_SIZE = 256#
-
namespace impl#
Functions
-
template<Concepts::Awaitable A, typename T = typename Concepts::AwaitableTraits<A>::ResultType>
static SyncWaitTask<T> MakeSyncWaitTask(A &&awaitable)#
-
template<Concepts::Awaitable A, typename T = typename Concepts::AwaitableTraits<A>::ResultType>
static WhenAllTask<T> MakeWhenAllTask(A awaitable)#
-
struct PromiseBase#
Subclassed by Hush::Threading::impl::TaskPromise< T >, Hush::Threading::impl::TaskPromise< T & >, Hush::Threading::impl::TaskPromise< void >
Public Functions
-
PromiseBase() noexcept = default#
-
inline std::suspend_always initial_suspend() noexcept#
-
inline FinalAwaiter final_suspend() noexcept#
-
inline void SetContinuation(std::coroutine_handle<> coroContinuation) noexcept#
Public Members
-
std::coroutine_handle continuation#
-
struct FinalAwaiter#
Public Functions
-
inline bool await_ready() const noexcept#
-
template<typename PromiseType>
inline std::coroutine_handle await_suspend(std::coroutine_handle<PromiseType> coroutine) noexcept#
-
inline void await_resume() noexcept#
-
inline bool await_ready() const noexcept#
-
PromiseBase() noexcept = default#
-
class SelfDeletePromise#
Public Functions
-
SelfDeletePromise() noexcept = default#
-
SelfDeletePromise(SelfDeletePromise&&) noexcept = default#
-
SelfDeletePromise(const SelfDeletePromise&) = delete#
-
SelfDeletePromise &operator=(SelfDeletePromise&&) noexcept = default#
-
SelfDeletePromise &operator=(const SelfDeletePromise&) = delete#
-
~SelfDeletePromise() noexcept = default#
-
inline SelfDeleteTask get_return_object() noexcept#
-
inline std::suspend_always initial_suspend() noexcept#
-
inline std::suspend_never final_suspend() noexcept#
-
inline void return_void() noexcept#
-
inline void unhandled_exception() noexcept#
-
SelfDeletePromise() noexcept = default#
-
class SelfDeleteTask#
Public Types
-
using promise_type = SelfDeletePromise#
Public Functions
-
inline explicit SelfDeleteTask(promise_type &promise) noexcept#
-
inline SelfDeleteTask(SelfDeleteTask &&other) noexcept#
-
inline SelfDeleteTask &operator=(SelfDeleteTask &&other) noexcept#
-
SelfDeleteTask(const SelfDeleteTask&) = delete#
-
SelfDeleteTask &operator=(const SelfDeleteTask&) = delete#
-
inline promise_type *GetPromise() const noexcept#
-
inline std::coroutine_handle<promise_type> GetCoroutineHandle() const noexcept#
-
inline bool Resume() const noexcept#
-
using promise_type = SelfDeletePromise#
-
template<typename T>
struct SyncWaitPromise : public Hush::Threading::impl::SyncWaitPromiseBase# Public Types
-
using ResultType = std::conditional_t<std::is_reference_v<T>, std::remove_reference_t<T>*, std::remove_const_t<T>>#
-
using VariantType = std::variant<std::monostate, ResultType, std::exception_ptr>#
-
using coroutine_type = std::coroutine_handle<SyncWaitPromise>#
Public Functions
-
SyncWaitPromise() noexcept = default#
-
SyncWaitPromise(SyncWaitPromise&&) noexcept = delete#
-
SyncWaitPromise &operator=(SyncWaitPromise&&) noexcept = delete#
-
SyncWaitPromise(const SyncWaitPromise&) noexcept = delete#
-
SyncWaitPromise &operator=(const SyncWaitPromise&) noexcept = delete#
-
~SyncWaitPromise() = default#
-
inline std::suspend_always initial_suspend() noexcept#
-
inline void Start(std::atomic_flag &done) noexcept#
-
inline auto get_return_object() noexcept#
-
inline void Wait() noexcept#
-
inline void return_value(ResultType value) noexcept#
-
inline auto final_suspend() noexcept#
-
inline decltype(auto) Result() &#
-
inline decltype(auto) Result() const &#
-
inline decltype(auto) Result() && noexcept#
-
inline void unhandled_exception() noexcept#
-
using ResultType = std::conditional_t<std::is_reference_v<T>, std::remove_reference_t<T>*, std::remove_const_t<T>>#
-
template<>
struct SyncWaitPromise<void> : public Hush::Threading::impl::SyncWaitPromiseBase# Public Types
-
using CoroutineType = std::coroutine_handle<SyncWaitPromise>#
Public Functions
-
SyncWaitPromise() noexcept = default#
-
SyncWaitPromise(const SyncWaitPromise&) = default#
-
SyncWaitPromise(SyncWaitPromise&&) = delete#
-
SyncWaitPromise &operator=(const SyncWaitPromise&) = default#
-
SyncWaitPromise &operator=(SyncWaitPromise&&) = delete#
-
~SyncWaitPromise() = default#
-
inline void Start(std::atomic_flag &done) noexcept#
-
inline void Wait() noexcept#
-
inline auto get_return_object() noexcept#
-
inline auto final_suspend() noexcept#
-
inline void return_void() noexcept#
-
inline void Result() noexcept#
-
inline void unhandled_exception() noexcept#
-
using CoroutineType = std::coroutine_handle<SyncWaitPromise>#
-
struct SyncWaitPromiseBase#
Subclassed by Hush::Threading::impl::SyncWaitPromise< T >, Hush::Threading::impl::SyncWaitPromise< void >
Public Functions
-
SyncWaitPromiseBase() noexcept = default#
-
SyncWaitPromiseBase(const SyncWaitPromiseBase&) = default#
-
SyncWaitPromiseBase(SyncWaitPromiseBase&&) = delete#
-
SyncWaitPromiseBase &operator=(const SyncWaitPromiseBase&) = default#
-
SyncWaitPromiseBase &operator=(SyncWaitPromiseBase&&) = delete#
-
inline std::suspend_always initial_suspend() noexcept#
-
inline void SetFlag(std::atomic_flag &done) noexcept#
-
SyncWaitPromiseBase() noexcept = default#
-
template<typename T>
struct TaskPromise : public Hush::Threading::impl::PromiseBase# Public Functions
-
TaskPromise() noexcept = default#
-
TaskPromise(const TaskPromise&) = delete#
-
TaskPromise(TaskPromise&&) = delete#
-
TaskPromise &operator=(const TaskPromise&) = delete#
-
TaskPromise &operator=(TaskPromise&&) = delete#
-
inline ~TaskPromise()#
-
inline void unhandled_exception() noexcept#
-
TaskPromise() noexcept = default#
-
template<>
struct TaskPromise<void> : public Hush::Threading::impl::PromiseBase#
-
class WhenAllLatch#
Public Functions
-
inline WhenAllLatch(size_t count) noexcept#
-
WhenAllLatch(const WhenAllLatch&) = delete#
-
inline WhenAllLatch(WhenAllLatch &&rhs) noexcept#
-
WhenAllLatch &operator=(const WhenAllLatch&) = delete#
-
inline WhenAllLatch &operator=(WhenAllLatch &&rhs) noexcept#
-
~WhenAllLatch() = default#
-
inline bool IsReady() const noexcept#
-
inline bool TryAwait(std::coroutine_handle<> handle) noexcept#
-
inline void NotifyCompleted() noexcept#
-
inline WhenAllLatch(size_t count) noexcept#
-
template<typename TaskContainerType>
class WhenAllReadyAwaitable# Public Functions
-
inline explicit WhenAllReadyAwaitable(TaskContainerType &&tasks) noexcept#
-
WhenAllReadyAwaitable(const WhenAllReadyAwaitable&) = delete#
-
inline WhenAllReadyAwaitable(WhenAllReadyAwaitable &&rhs) noexcept#
-
WhenAllReadyAwaitable &operator=(const WhenAllReadyAwaitable&) = delete#
-
WhenAllReadyAwaitable &operator=(WhenAllReadyAwaitable&&) noexcept = delete#
-
~WhenAllReadyAwaitable() = default#
-
inline auto operator co_await() & noexcept#
-
inline auto operator co_await() && noexcept#
-
inline explicit WhenAllReadyAwaitable(TaskContainerType &&tasks) noexcept#
-
template<typename ...TaskTypes>
class WhenAllReadyAwaitable<std::tuple<TaskTypes...>># Public Functions
-
inline explicit WhenAllReadyAwaitable(TaskTypes&&... tasks) noexcept(std::conjunction_v<std::is_nothrow_move_constructible<TaskTypes>...>)#
-
WhenAllReadyAwaitable(const WhenAllReadyAwaitable&) = delete#
-
inline WhenAllReadyAwaitable(WhenAllReadyAwaitable &&rhs) noexcept#
-
inline WhenAllReadyAwaitable &operator=(WhenAllReadyAwaitable &&rhs) noexcept#
-
WhenAllReadyAwaitable &operator=(const WhenAllReadyAwaitable&) = delete#
-
~WhenAllReadyAwaitable() = default#
-
inline auto operator co_await() & noexcept#
-
inline auto operator co_await() && noexcept#
-
inline explicit WhenAllReadyAwaitable(TaskTypes&&... tasks) noexcept(std::conjunction_v<std::is_nothrow_move_constructible<TaskTypes>...>)#
-
template<>
class WhenAllReadyAwaitable<std::tuple<>># Public Functions
-
constexpr WhenAllReadyAwaitable() noexcept = default#
-
inline explicit constexpr WhenAllReadyAwaitable(std::tuple<>) noexcept#
-
inline constexpr bool await_ready() const noexcept#
-
inline void await_suspend(std::coroutine_handle<> handle) noexcept#
-
inline std::tuple await_resume() const noexcept#
-
constexpr WhenAllReadyAwaitable() noexcept = default#
-
template<typename T>
class WhenAllTask# Public Types
-
using promise_type = WhenAllTasksPromise<T>#
-
using coroutine_handle_type = typename promise_type::coroutine_handle_type#
Public Functions
-
inline WhenAllTask(coroutine_handle_type handle) noexcept#
-
WhenAllTask(const WhenAllTask&) = delete#
-
inline WhenAllTask(WhenAllTask &&rhs) noexcept#
-
WhenAllTask &operator=(const WhenAllTask&) = delete#
-
inline WhenAllTask &operator=(WhenAllTask &&rhs) noexcept#
-
inline ~WhenAllTask() noexcept#
-
inline decltype(auto) return_value() &#
-
inline decltype(auto) return_value() &&#
Friends
- friend class WhenAllReadyAwaitable
-
using promise_type = WhenAllTasksPromise<T>#
-
template<typename T>
class WhenAllTasksPromise# Public Types
-
using coroutine_handle_type = std::coroutine_handle<WhenAllTasksPromise<T>>#
Public Functions
-
WhenAllTasksPromise() = default#
-
inline auto get_return_object() noexcept#
-
inline std::suspend_always initial_suspend() const noexcept#
-
inline auto final_suspend() noexcept#
-
inline void unhandle_exception() noexcept#
-
inline void Start(WhenAllLatch &latch) noexcept#
-
inline void return_void() noexcept#
-
using coroutine_handle_type = std::coroutine_handle<WhenAllTasksPromise<T>>#
-
template<>
class WhenAllTasksPromise<void># Public Types
-
using coroutine_handle_type = std::coroutine_handle<WhenAllTasksPromise<void>>#
Public Functions
-
WhenAllTasksPromise() = default#
-
inline auto get_return_object() noexcept#
-
inline std::suspend_always initial_suspend() const noexcept#
-
inline auto final_suspend() noexcept#
-
inline void unhandled_exception() noexcept#
-
inline void return_void() noexcept#
-
inline void Result()#
-
inline void Start(WhenAllLatch &latch)#
-
using coroutine_handle_type = std::coroutine_handle<WhenAllTasksPromise<void>>#
-
template<Concepts::Awaitable A, typename T = typename Concepts::AwaitableTraits<A>::ResultType>
-
constexpr uint64_t Pack(uint32_t workerHead, uint32_t stealerHead) noexcept#
-
namespace TypeUtils#
-
namespace Vector3Math#
-
enum class EEditorState : uint16_t#