4#include <SDL3/SDL_gpu.h>
5#include <SDL3/SDL_log.h>
13 std::is_standard_layout_v<T> && !std::is_array_v<T> &&
14 !std::is_pointer_v<T> &&
15 (
alignof(T) == 4 ||
alignof(T) == 8 ||
alignof(T) == 16);
18 SDL_GPUCommandBuffer *_cmdBuf;
24 operator SDL_GPUCommandBuffer *()
const {
return _cmdBuf; }
39 std::swap(lhs._cmdBuf, rhs._cmdBuf);
43 if (!(
active() && SDL_SubmitGPUCommandBuffer(_cmdBuf)))
50 SDL_GPUFence *fence = SDL_SubmitGPUCommandBufferAndAcquireFence(_cmdBuf);
62 bool active() const noexcept {
return _cmdBuf; }
66 SDL_LogWarn(SDL_LOG_CATEGORY_APPLICATION,
67 "CommandBuffer object is being destroyed while still active! "
68 "It will be cancelled.");
69 [[maybe_unused]]
bool ret =
cancel();
74 template <GpuCompatibleData T>
79 template <GpuCompatibleData T>
84 template <GpuCompatibleData T>
89 template <GpuCompatibleData T>
91 std::span<const T> data) {
98 SDL_PushGPUVertexUniformData(_cmdBuf, slot_index, data, length);
104 SDL_PushGPUFragmentUniformData(_cmdBuf, slot_index, data, length);
CommandBuffer & pushFragmentUniform(Uint32 slot_index, const T &data)
Definition CommandBuffer.h:80
CommandBuffer & pushFragmentUniform(Uint32 slot_index, std::span< const T > data)
Definition CommandBuffer.h:90
CommandBuffer(const CommandBuffer &)=delete
Deleted copy constructor.
SDL_GPUFence * submitAndAcquireFence() noexcept
Definition CommandBuffer.h:49
bool active() const noexcept
Check if the command buffer is still active.
Definition CommandBuffer.h:62
~CommandBuffer() noexcept
Definition CommandBuffer.h:64
CommandBuffer & pushVertexUniform(Uint32 slot_index, const T &data)
Definition CommandBuffer.h:75
CommandBuffer & operator=(CommandBuffer &&other) noexcept
Move assignment operator.
CommandBuffer & pushVertexUniform(Uint32 slot_index, std::span< const T > data)
Definition CommandBuffer.h:85
CommandBuffer & pushVertexUniformRaw(Uint32 slot_index, const void *data, Uint32 length)
Push uniform data to the vertex shader.
Definition CommandBuffer.h:96
friend void swap(CommandBuffer &lhs, CommandBuffer &rhs) noexcept
Definition CommandBuffer.h:38
CommandBuffer & pushFragmentUniformRaw(Uint32 slot_index, const void *data, Uint32 length)
Push uniform data to the fragment shader.
Definition CommandBuffer.h:102
CommandBuffer(CommandBuffer &&other) noexcept
Move constructor.
bool submit() noexcept
Definition CommandBuffer.h:42
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:12
RAII wrapper for SDL_GPUDevice.
Definition Device.h:17