ObjectivelyGPU
Object oriented graphics framework for SDL3 and C
Loading...
Searching...
No Matches
CommandBuffer.h
Go to the documentation of this file.
1/*
2 * ObjectivelyGPU: Object oriented graphics framework for SDL3 and C.
3 * Copyright (C) 2026 Jay Dolan <jay@jaydolan.com>
4 *
5 * This software is provided 'as-is', without any express or implied
6 * warranty. In no event will the authors be held liable for any damages
7 * arising from the use of this software.
8 *
9 * Permission is granted to anyone to use this software for any purpose,
10 * including commercial applications, and to alter it and redistribute it
11 * freely, subject to the following restrictions:
12 *
13 * 1. The origin of this software must not be misrepresented; you must not
14 * claim that you wrote the original software. If you use this software
15 * in a product, an acknowledgment in the product documentation would be
16 * appreciated but is not required.
17 *
18 * 2. Altered source versions must be plainly marked as such, and must not be
19 * misrepresented as being the original software.
20 *
21 * 3. This notice may not be removed or altered from any source distribution.
22 */
23
24#pragma once
25
26#include <Objectively/Object.h>
27
29
35typedef struct ComputePass ComputePass;
36typedef struct CopyPass CopyPass;
37typedef struct Fence Fence;
38typedef struct Framebuffer Framebuffer;
39typedef struct RenderPass RenderPass;
42typedef struct CommandBufferInterface CommandBufferInterface;
44
51
55 SDL_GPUTexture *texture;
56
60 SDL_GPUTextureFormat format;
61
66};
67
82
86 Object object;
87
92 CommandBufferInterface *interface;
93
97 SDL_GPUCommandBuffer *commands;
98
103
110 Object *pass;
111
116 bool submitted;
117
121 ident data;
122};
123
127struct CommandBufferInterface {
128
132 ObjectInterface objectInterface;
133
147 bool (*acquireSwapchainTexture)(const CommandBuffer *self, SwapchainTexture *swapchain);
148
162 ComputePass *(*beginComputePass)(CommandBuffer *self, const SDL_GPUStorageTextureReadWriteBinding *storageTextures, Uint32 numStorageTextures, const SDL_GPUStorageBufferReadWriteBinding *storageBuffers, Uint32 numStorageBuffers);
163
173 CopyPass *(*beginCopyPass)(CommandBuffer *self);
174
187 RenderPass *(*beginRenderPass)(CommandBuffer *self, const SDL_GPUColorTargetInfo *colorTargets, Uint32 numColorTargets, const SDL_GPUDepthStencilTargetInfo *depthStencil);
188
206 RenderPass *(*beginRenderPassWithFramebuffer)(CommandBuffer *self, const Framebuffer *framebuffer, SDL_GPULoadOp loadOp, SDL_GPUStoreOp storeOp);
207
213 void (*blitTexture)(const CommandBuffer *self, const SDL_GPUBlitInfo *info);
214
224 bool (*cancel)(CommandBuffer *self);
225
231 void (*generateMipmaps)(const CommandBuffer *self, SDL_GPUTexture *texture);
232
242 CommandBuffer *(*initWithCommandBuffer)(CommandBuffer *self, const RenderDevice *device, SDL_GPUCommandBuffer *commands);
243
249 void (*insertDebugLabel)(const CommandBuffer *self, const char *text);
250
256 void (*popDebugGroup)(const CommandBuffer *self);
257
263 void (*pushComputeUniformData)(const CommandBuffer *self, Uint32 slot, const void *data, Uint32 length);
264
270 void (*pushDebugGroup)(const CommandBuffer *self, const char *name);
271
277 void (*pushFragmentUniformData)(const CommandBuffer *self, Uint32 slot, const void *data, Uint32 length);
278
293 void (*pushUniformData)(const CommandBuffer *self, Uint32 slot, const void *data, Uint32 length);
294
300 void (*pushVertexUniformData)(const CommandBuffer *self, Uint32 slot, const void *data, Uint32 length);
301
311 bool (*submit)(CommandBuffer *self);
312
321 Fence *(*submitAndFence)(CommandBuffer *self);
322
339 bool (*waitAndAcquireSwapchainTexture)(const CommandBuffer *self, SwapchainTexture *swapchain);
340};
341
OBJECTIVELYGPU_EXPORT Class * _CommandBuffer(void)
Definition CommandBuffer.c:356
#define OBJECTIVELYGPU_EXPORT
Definition Types.h:35
A recorded sequence of GPU commands for a single frame.
Definition CommandBuffer.h:81
RenderDevice * device
The RenderDevice that this CommandBuffer belongs to.
Definition CommandBuffer.h:102
Object object
The superclass.
Definition CommandBuffer.h:86
CommandBufferInterface * interface
The interface.
Definition CommandBuffer.h:92
ident data
User data.
Definition CommandBuffer.h:121
SDL_GPUCommandBuffer * commands
The underlying SDL command buffer.
Definition CommandBuffer.h:97
A scoped compute pass for recording GPU compute dispatches.
Definition ComputePass.h:56
A scoped copy pass for uploading CPU data and copying GPU resources.
Definition CopyPass.h:55
An SDL_GPUFence, signaled once a submitted CommandBuffer's GPU work completes.
Definition Fence.h:55
An off-screen render target grouping a color and/or depth texture.
Definition Framebuffer.h:177
The RenderDevice encapsulates an SDL_GPUDevice and provides methods for allocating GPU resources,...
Definition RenderDevice.h:63
A scoped render pass for recording draw commands into a CommandBuffer.
Definition RenderPass.h:57
The SDL_Size type.
Definition Types.h:47
The swapchain texture acquired for a single frame.
Definition CommandBuffer.h:50
SDL_GPUTexture * texture
The swapchain render target for this frame.
Definition CommandBuffer.h:55
SDL_Size size
The swapchain dimensions in pixels.
Definition CommandBuffer.h:65
SDL_GPUTextureFormat format
The swapchain texture format.
Definition CommandBuffer.h:60