@@ -185,6 +185,21 @@ struct IndexBufferBind : public CommandBuffer::Command
185
185
const VkIndexType indexType;
186
186
};
187
187
188
+ void CommandBuffer::ExecutionState::bindVertexInputs (sw::Context& context, int firstVertex)
189
+ {
190
+ for (uint32_t i = 0 ; i < MAX_VERTEX_INPUT_BINDINGS; i++)
191
+ {
192
+ auto &attrib = context.input [i];
193
+ if (attrib.count )
194
+ {
195
+ const auto &vertexInput = vertexInputBindings[attrib.binding ];
196
+ Buffer *buffer = Cast (vertexInput.buffer );
197
+ attrib.buffer = buffer ? buffer->getOffsetPointer (
198
+ attrib.offset + vertexInput.offset + attrib.stride * firstVertex) : nullptr ;
199
+ }
200
+ }
201
+ }
202
+
188
203
void CommandBuffer::ExecutionState::bindAttachments ()
189
204
{
190
205
// Binds all the attachments for the current subpass
@@ -230,17 +245,7 @@ struct Draw : public CommandBuffer::Command
230
245
executionState.pipelines [VK_PIPELINE_BIND_POINT_GRAPHICS]);
231
246
232
247
sw::Context context = pipeline->getContext ();
233
- for (uint32_t i = 0 ; i < MAX_VERTEX_INPUT_BINDINGS; i++)
234
- {
235
- auto &attrib = context.input [i];
236
- if (attrib.count )
237
- {
238
- const auto &vertexInput = executionState.vertexInputBindings [attrib.binding ];
239
- Buffer *buffer = Cast (vertexInput.buffer );
240
- attrib.buffer = buffer ? buffer->getOffsetPointer (
241
- attrib.offset + vertexInput.offset + attrib.stride * firstVertex) : nullptr ;
242
- }
243
- }
248
+ executionState.bindVertexInputs (context, firstVertex);
244
249
245
250
context.pushConstants = executionState.pushConstants ;
246
251
@@ -279,17 +284,7 @@ struct DrawIndexed : public CommandBuffer::Command
279
284
executionState.pipelines [VK_PIPELINE_BIND_POINT_GRAPHICS]);
280
285
281
286
sw::Context context = pipeline->getContext ();
282
- for (uint32_t i = 0 ; i < MAX_VERTEX_INPUT_BINDINGS; i++)
283
- {
284
- auto &attrib = context.input [i];
285
- if (attrib.count )
286
- {
287
- const auto &vertexInput = executionState.vertexInputBindings [attrib.binding ];
288
- Buffer *buffer = Cast (vertexInput.buffer );
289
- attrib.buffer = buffer ? buffer->getOffsetPointer (
290
- attrib.offset + vertexInput.offset + attrib.stride * vertexOffset) : nullptr ;
291
- }
292
- }
287
+ executionState.bindVertexInputs (context, vertexOffset);
293
288
294
289
context.pushConstants = executionState.pushConstants ;
295
290
0 commit comments