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 RenderPass RenderPass;
41typedef struct CommandBufferInterface CommandBufferInterface;
43
50
54 SDL_GPUTexture *texture;
55
59 SDL_GPUTextureFormat format;
60
65};
66
81
85 Object object;
86
91 CommandBufferInterface *interface;
92
96 SDL_GPUCommandBuffer *commands;
97
102
109 Object *pass;
110
115 bool submitted;
116
120 ident data;
121};
122
126struct CommandBufferInterface {
127
131 ObjectInterface objectInterface;
132
144 bool (*acquireSwapchainTexture)(const CommandBuffer *self, SwapchainTexture *swapchain);
145
159 ComputePass *(*beginComputePass)(CommandBuffer *self, const SDL_GPUStorageTextureReadWriteBinding *storageTextures, Uint32 numStorageTextures, const SDL_GPUStorageBufferReadWriteBinding *storageBuffers, Uint32 numStorageBuffers);
160
170 CopyPass *(*beginCopyPass)(CommandBuffer *self);
171
184 RenderPass *(*beginRenderPass)(CommandBuffer *self, const SDL_GPUColorTargetInfo *colorTargets, Uint32 numColorTargets, const SDL_GPUDepthStencilTargetInfo *depthStencil);
185
191 void (*blitTexture)(const CommandBuffer *self, const SDL_GPUBlitInfo *info);
192
202 bool (*cancel)(CommandBuffer *self);
203
209 void (*generateMipmaps)(const CommandBuffer *self, SDL_GPUTexture *texture);
210
220 CommandBuffer *(*initWithCommandBuffer)(CommandBuffer *self, const RenderDevice *device, SDL_GPUCommandBuffer *commands);
221
227 void (*insertDebugLabel)(const CommandBuffer *self, const char *text);
228
234 void (*popDebugGroup)(const CommandBuffer *self);
235
241 void (*pushComputeUniformData)(const CommandBuffer *self, Uint32 slot, const void *data, Uint32 length);
242
248 void (*pushDebugGroup)(const CommandBuffer *self, const char *name);
249
255 void (*pushFragmentUniformData)(const CommandBuffer *self, Uint32 slot, const void *data, Uint32 length);
256
271 void (*pushUniformData)(const CommandBuffer *self, Uint32 slot, const void *data, Uint32 length);
272
278 void (*pushVertexUniformData)(const CommandBuffer *self, Uint32 slot, const void *data, Uint32 length);
279
289 bool (*submit)(CommandBuffer *self);
290
299 Fence *(*submitAndFence)(CommandBuffer *self);
300
311 bool (*waitAndAcquireSwapchainTexture)(const CommandBuffer *self, SwapchainTexture *swapchain);
312};
313
OBJECTIVELYGPU_EXPORT Class * _CommandBuffer(void)
Definition CommandBuffer.c:325
#define OBJECTIVELYGPU_EXPORT
Definition Types.h:35
A recorded sequence of GPU commands for a single frame.
Definition CommandBuffer.h:80
RenderDevice * device
The RenderDevice that this CommandBuffer belongs to.
Definition CommandBuffer.h:101
Object object
The superclass.
Definition CommandBuffer.h:85
CommandBufferInterface * interface
The interface.
Definition CommandBuffer.h:91
ident data
User data.
Definition CommandBuffer.h:120
SDL_GPUCommandBuffer * commands
The underlying SDL command buffer.
Definition CommandBuffer.h:96
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
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:49
SDL_GPUTexture * texture
The swapchain render target for this frame.
Definition CommandBuffer.h:54
SDL_Size size
The swapchain dimensions in pixels.
Definition CommandBuffer.h:64
SDL_GPUTextureFormat format
The swapchain texture format.
Definition CommandBuffer.h:59