4#include <SDL3/SDL_gpu.h>
6#include <spdlog/spdlog.h>
12 std::is_standard_layout_v<T> && !std::is_array_v<T> &&
13 !std::is_pointer_v<T> &&
14 (
alignof(T) == 4 ||
alignof(T) == 8 ||
alignof(T) == 16);
17 SDL_GPUCommandBuffer *m_handle;
23 operator SDL_GPUCommandBuffer *()
const {
return m_handle; }
30 other.m_handle =
nullptr;
41 m_handle = other.m_handle;
42 other.m_handle =
nullptr;
48 if (!(
active() && SDL_SubmitGPUCommandBuffer(m_handle)))
55 SDL_GPUFence *fence = SDL_SubmitGPUCommandBufferAndAcquireFence(m_handle);
67 bool active() const noexcept {
return m_handle; }
72 "CommandBuffer object is being destroyed while still active. "
73 "It will be cancelled.");
74 [[maybe_unused]]
bool ret =
cancel();
79 template <GpuCompatibleData T>
84 template <GpuCompatibleData T>
89 template <GpuCompatibleData T>
94 template <GpuCompatibleData T>
96 std::span<const T> data) {
100 template <GpuCompatibleData T,
size_t N>
105 template <GpuCompatibleData T,
size_t N>
113 SDL_PushGPUVertexUniformData(m_handle, slot_index, data, length);
119 SDL_PushGPUFragmentUniformData(m_handle, slot_index, data, length);
#define CANDLEWICK_ASSERT(condition, msg)
Definition Core.h:7
CommandBuffer & pushVertexUniform(Uint32 slot_index, const T(&data)[N])
Definition CommandBuffer.h:101
CommandBuffer & pushFragmentUniform(Uint32 slot_index, const T &data)
Definition CommandBuffer.h:85
CommandBuffer & pushFragmentUniform(Uint32 slot_index, std::span< const T > data)
Definition CommandBuffer.h:95
CommandBuffer(const CommandBuffer &)=delete
Deleted copy constructor.
SDL_GPUFence * submitAndAcquireFence() noexcept
Definition CommandBuffer.h:54
bool active() const noexcept
Check if the command buffer is still active.
Definition CommandBuffer.h:67
~CommandBuffer() noexcept
Definition CommandBuffer.h:69
CommandBuffer & pushVertexUniform(Uint32 slot_index, const T &data)
Definition CommandBuffer.h:80
CommandBuffer & operator=(CommandBuffer &&other) noexcept
Move assignment operator.
Definition CommandBuffer.h:37
CommandBuffer & pushVertexUniform(Uint32 slot_index, std::span< const T > data)
Definition CommandBuffer.h:90
CommandBuffer & pushVertexUniformRaw(Uint32 slot_index, const void *data, Uint32 length)
Push uniform data to the vertex shader.
Definition CommandBuffer.h:111
CommandBuffer & pushFragmentUniformRaw(Uint32 slot_index, const void *data, Uint32 length)
Push uniform data to the fragment shader.
Definition CommandBuffer.h:117
CommandBuffer & pushFragmentUniform(Uint32 slot_index, const T(&data)[N])
Definition CommandBuffer.h:106
CommandBuffer(CommandBuffer &&other) noexcept
Move constructor.
Definition CommandBuffer.h:29
bool submit() noexcept
Definition CommandBuffer.h:47
CommandBuffer & operator=(const CommandBuffer &)=delete
Deleted copy assignment operator.
CommandBuffer(const Device &device)
bool cancel() noexcept
Cancel the command buffer, returning the bool value from the wrapped SDL API.
Definition CommandBuffer.h:11
RAII wrapper for SDL_GPUDevice.
Definition Device.h:17