Skip to content

Commit f99cbfc

Browse files
jdolanCopilot
andcommitted
Reorder pass init params: (self, cmd, pass) for RenderPass and ComputePass
CommandBuffer is the owning object and takes precedence over the wrapped SDL pass. Matches CopyPass convention. Updated @fn docs, @param order, struct member order, and all call sites. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 0a3cc70 commit f99cbfc

7 files changed

Lines changed: 29 additions & 29 deletions

File tree

Sources/ObjectivelyGPU/CommandBuffer.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static ComputePass *beginComputePass(const CommandBuffer *self, const SDL_GPUSto
5757
SDL_GPUComputePass *pass = SDL_BeginGPUComputePass(self->cmd, storageTextures, numStorageTextures, storageBuffers, numStorageBuffers);
5858
GPU_Assert(pass, "SDL_BeginGPUComputePass");
5959

60-
return $(alloc(ComputePass), init, pass, (CommandBuffer *) self);
60+
return $(alloc(ComputePass), init, (CommandBuffer *) self, pass);
6161
}
6262

6363
/**
@@ -69,7 +69,7 @@ static CopyPass *beginCopyPass(const CommandBuffer *self) {
6969
SDL_GPUCopyPass *pass = SDL_BeginGPUCopyPass(self->cmd);
7070
GPU_Assert(pass, "SDL_BeginGPUCopyPass");
7171

72-
return $(alloc(CopyPass), init, pass, (CommandBuffer *) self);
72+
return $(alloc(CopyPass), init, (CommandBuffer *) self, pass);
7373
}
7474

7575
/**
@@ -81,7 +81,7 @@ static RenderPass *beginRenderPass(const CommandBuffer *self, const SDL_GPUColor
8181
SDL_GPURenderPass *pass = SDL_BeginGPURenderPass(self->cmd, colorTargets, numColorTargets, depthStencil);
8282
GPU_Assert(pass, "SDL_BeginGPURenderPass");
8383

84-
return $(alloc(RenderPass), init, pass, (CommandBuffer *) self);
84+
return $(alloc(RenderPass), init, (CommandBuffer *) self, pass);
8585
}
8686

8787
/**

Sources/ObjectivelyGPU/ComputePass.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,17 @@ static void dispatchComputeIndirect(const ComputePass *self, SDL_GPUBuffer *buff
9494
}
9595

9696
/**
97-
* @fn ComputePass *ComputePass::init(ComputePass *self, SDL_GPUComputePass *pass, CommandBuffer *cmd)
97+
* @fn ComputePass *ComputePass::init(ComputePass *self, CommandBuffer *cmd, SDL_GPUComputePass *pass)
9898
* @memberof ComputePass
9999
*/
100-
static ComputePass *init(ComputePass *self, SDL_GPUComputePass *pass, CommandBuffer *cmd) {
100+
static ComputePass *init(ComputePass *self, CommandBuffer *cmd, SDL_GPUComputePass *pass) {
101101

102102
self = (ComputePass *) super(Object, self, init);
103103
if (self) {
104-
self->pass = pass;
105-
assert(self->pass);
106104
self->cmd = cmd;
107105
assert(self->cmd);
106+
self->pass = pass;
107+
assert(self->pass);
108108
}
109109

110110
return self;

Sources/ObjectivelyGPU/ComputePass.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,15 @@ struct ComputePassInterface {
136136
void (*dispatchComputeIndirect)(const ComputePass *self, SDL_GPUBuffer *buffer, Uint32 offset);
137137

138138
/**
139-
* @fn ComputePass *ComputePass::init(ComputePass *self, SDL_GPUComputePass *pass, CommandBuffer *cmd)
139+
* @fn ComputePass *ComputePass::init(ComputePass *self, CommandBuffer *cmd, SDL_GPUComputePass *pass)
140140
* @brief Initializes this ComputePass wrapping the given SDL compute pass.
141141
* @param self The ComputePass.
142-
* @param pass The SDL compute pass to wrap. Must not be NULL.
143142
* @param cmd The CommandBuffer this pass was begun from.
143+
* @param pass The SDL compute pass to wrap. Must not be NULL.
144144
* @return The initialized ComputePass, or NULL on failure.
145145
* @memberof ComputePass
146146
*/
147-
ComputePass *(*init)(ComputePass *self, SDL_GPUComputePass *pass, CommandBuffer *cmd);
147+
ComputePass *(*init)(ComputePass *self, CommandBuffer *cmd, SDL_GPUComputePass *pass);
148148
};
149149

150150
/**

Sources/ObjectivelyGPU/CopyPass.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,17 @@ static void downloadTexture(const CopyPass *self, const SDL_GPUTextureRegion *sr
8080
}
8181

8282
/**
83-
* @fn CopyPass *CopyPass::init(CopyPass *self, SDL_GPUCopyPass *pass, CommandBuffer *cmd)
83+
* @fn CopyPass *CopyPass::init(CopyPass *self, CommandBuffer *cmd, SDL_GPUCopyPass *pass)
8484
* @memberof CopyPass
8585
*/
86-
static CopyPass *init(CopyPass *self, SDL_GPUCopyPass *pass, CommandBuffer *cmd) {
86+
static CopyPass *init(CopyPass *self, CommandBuffer *cmd, SDL_GPUCopyPass *pass) {
8787

8888
self = (CopyPass *) super(Object, self, init);
8989
if (self) {
90-
self->pass = pass;
91-
assert(self->pass);
9290
self->cmd = cmd;
9391
assert(self->cmd);
92+
self->pass = pass;
93+
assert(self->pass);
9494
}
9595

9696
return self;

Sources/ObjectivelyGPU/CopyPass.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,17 @@ struct CopyPass {
6565
CopyPassInterface *interface;
6666

6767
/**
68-
* @brief The underlying SDL copy pass.
69-
* @details Set to NULL by `dealloc` after `SDL_EndGPUCopyPass` is called.
68+
* @brief The CommandBuffer this pass was begun from.
7069
* @private
7170
*/
72-
SDL_GPUCopyPass *pass;
71+
CommandBuffer *cmd;
7372

7473
/**
75-
* @brief The CommandBuffer this pass was begun from.
74+
* @brief The underlying SDL copy pass.
75+
* @details Set to NULL by `dealloc` after `SDL_EndGPUCopyPass` is called.
7676
* @private
7777
*/
78-
CommandBuffer *cmd;
78+
SDL_GPUCopyPass *pass;
7979
};
8080

8181
/**
@@ -117,15 +117,15 @@ struct CopyPassInterface {
117117
void (*downloadTexture)(const CopyPass *self, const SDL_GPUTextureRegion *src, const SDL_GPUTextureTransferInfo *dst);
118118

119119
/**
120-
* @fn CopyPass *CopyPass::init(CopyPass *self, SDL_GPUCopyPass *pass, CommandBuffer *cmd)
120+
* @fn CopyPass *CopyPass::init(CopyPass *self, CommandBuffer *cmd, SDL_GPUCopyPass *pass)
121121
* @brief Initializes this CopyPass wrapping the given SDL copy pass.
122122
* @param self The CopyPass.
123+
* @param cmd The CommandBuffer that created this pass.
123124
* @param pass The SDL copy pass to wrap. Must not be NULL.
124-
* @param cmd The CommandBuffer this pass was begun from.
125125
* @return The initialized CopyPass, or NULL on failure.
126126
* @memberof CopyPass
127127
*/
128-
CopyPass *(*init)(CopyPass *self, SDL_GPUCopyPass *pass, CommandBuffer *cmd);
128+
CopyPass *(*init)(CopyPass *self, CommandBuffer *cmd, SDL_GPUCopyPass *pass);
129129

130130
/**
131131
* @fn void CopyPass::uploadBuffer(const CopyPass *self, const SDL_GPUTransferBufferLocation *src, const SDL_GPUBufferRegion *dst, bool cycle)

Sources/ObjectivelyGPU/RenderPass.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,17 +151,17 @@ static void drawPrimitivesIndirect(const RenderPass *self, SDL_GPUBuffer *buffer
151151
}
152152

153153
/**
154-
* @fn RenderPass *RenderPass::init(RenderPass *self, SDL_GPURenderPass *pass, CommandBuffer *cmd)
154+
* @fn RenderPass *RenderPass::init(RenderPass *self, CommandBuffer *cmd, SDL_GPURenderPass *pass)
155155
* @memberof RenderPass
156156
*/
157-
static RenderPass *init(RenderPass *self, SDL_GPURenderPass *pass, CommandBuffer *cmd) {
157+
static RenderPass *init(RenderPass *self, CommandBuffer *cmd, SDL_GPURenderPass *pass) {
158158

159159
self = (RenderPass *) super(Object, self, init);
160160
if (self) {
161-
self->pass = pass;
162-
assert(self->pass);
163161
self->cmd = cmd;
164162
assert(self->cmd);
163+
self->pass = pass;
164+
assert(self->pass);
165165
}
166166

167167
return self;

Sources/ObjectivelyGPU/RenderPass.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,15 @@ struct RenderPassInterface {
193193
void (*drawPrimitivesIndirect)(const RenderPass *self, SDL_GPUBuffer *buffer, Uint32 offset, Uint32 drawCount);
194194

195195
/**
196-
* @fn RenderPass *RenderPass::init(RenderPass *self, SDL_GPURenderPass *pass, CommandBuffer *cmd)
196+
* @fn RenderPass *RenderPass::init(RenderPass *self, CommandBuffer *cmd, SDL_GPURenderPass *pass)
197197
* @brief Initializes this RenderPass wrapping the given SDL render pass.
198198
* @param self The RenderPass.
199-
* @param pass The SDL render pass to wrap. Must not be NULL.
200199
* @param cmd The CommandBuffer this pass was begun from.
200+
* @param pass The SDL render pass to wrap. Must not be NULL.
201201
* @return The initialized RenderPass, or NULL on failure.
202202
* @memberof RenderPass
203203
*/
204-
RenderPass *(*init)(RenderPass *self, SDL_GPURenderPass *pass, CommandBuffer *cmd);
204+
RenderPass *(*init)(RenderPass *self, CommandBuffer *cmd, SDL_GPURenderPass *pass);
205205

206206
/**
207207
* @fn void RenderPass::setBlendConstants(const RenderPass *self, SDL_FColor blendConstants)

0 commit comments

Comments
 (0)