@@ -58,7 +58,7 @@ typedef struct _plAppData
5858 // buffers
5959 plBufferHandle tStagingBuffer ;
6060 plBufferHandle tIndexBuffer ;
61- plBufferHandle tVertexBuffer ;
61+ plBufferHandle atVertexBuffer [ 2 ] ;
6262
6363 // textures
6464 plTextureHandle tTexture ;
@@ -181,7 +181,8 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
181181 "../shaders/" ,
182182 "../examples/shaders/"
183183 },
184- .tFlags = PL_SHADER_FLAGS_AUTO_OUTPUT | PL_SHADER_FLAGS_NEVER_CACHE
184+ .pcCacheOutputDirectory = "../shader-temp/" ,
185+ .tFlags = PL_SHADER_FLAGS_AUTO_OUTPUT | PL_SHADER_FLAGS_ALWAYS_COMPILE | PL_SHADER_FLAGS_INCLUDE_DEBUG
185186 };
186187 gptShader -> initialize (& tDefaultShaderOptions );
187188
@@ -192,33 +193,49 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
192193 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~vertex buffer~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
193194
194195 // vertex buffer data
195- const float atVertexData [] = { // x, y, u, v
196- -0.5f , -0.5f , 0.0f , 0.0f ,
197- -0.5f , 0.5f , 0.0f , 1.0f ,
198- 0.5f , 0.5f , 1.0f , 1.0f ,
199- 0.5f , -0.5f , 1.0f , 0.0f
196+ const float atVertexData0 [] = { // x, y
197+ -0.5f , -0.5f ,
198+ -0.5f , 0.5f ,
199+ 0.5f , 0.5f ,
200+ 0.5f , -0.5f
201+ };
202+
203+ const float atVertexData1 [] = { // u, v
204+ 0.0f , 0.0f ,
205+ 0.0f , 1.0f ,
206+ 1.0f , 1.0f ,
207+ 1.0f , 0.0f
200208 };
201209
202210 // create vertex buffer
203211 const plBufferDesc tVertexBufferDesc = {
204212 .tUsage = PL_BUFFER_USAGE_VERTEX ,
205- .szByteSize = sizeof (float ) * PL_ARRAYSIZE (atVertexData ),
213+ .szByteSize = sizeof (float ) * PL_ARRAYSIZE (atVertexData0 ),
206214 .pcDebugName = "vertex buffer"
207215 };
208- ptAppData -> tVertexBuffer = gptGfx -> create_buffer (ptDevice , & tVertexBufferDesc , NULL );
216+ ptAppData -> atVertexBuffer [0 ] = gptGfx -> create_buffer (ptDevice , & tVertexBufferDesc , NULL );
217+ ptAppData -> atVertexBuffer [1 ] = gptGfx -> create_buffer (ptDevice , & tVertexBufferDesc , NULL );
209218
210219 // retrieve buffer to get memory allocation requirements (do not store buffer pointer)
211- plBuffer * ptVertexBuffer = gptGfx -> get_buffer (ptDevice , ptAppData -> tVertexBuffer );
220+ plBuffer * ptVertexBuffer0 = gptGfx -> get_buffer (ptDevice , ptAppData -> atVertexBuffer [0 ]);
221+ plBuffer * ptVertexBuffer1 = gptGfx -> get_buffer (ptDevice , ptAppData -> atVertexBuffer [1 ]);
212222
213223 // allocate memory for the vertex buffer
214- const plDeviceMemoryAllocation tVertexBufferAllocation = gptGfx -> allocate_memory (ptDevice ,
215- ptVertexBuffer -> tMemoryRequirements .ulSize ,
224+ const plDeviceMemoryAllocation tVertexBufferAllocation0 = gptGfx -> allocate_memory (ptDevice ,
225+ ptVertexBuffer0 -> tMemoryRequirements .ulSize ,
226+ PL_MEMORY_FLAGS_DEVICE_LOCAL ,
227+ ptVertexBuffer0 -> tMemoryRequirements .uMemoryTypeBits ,
228+ "vertex buffer memory" );
229+
230+ const plDeviceMemoryAllocation tVertexBufferAllocation1 = gptGfx -> allocate_memory (ptDevice ,
231+ ptVertexBuffer1 -> tMemoryRequirements .ulSize ,
216232 PL_MEMORY_FLAGS_DEVICE_LOCAL ,
217- ptVertexBuffer -> tMemoryRequirements .uMemoryTypeBits ,
233+ ptVertexBuffer1 -> tMemoryRequirements .uMemoryTypeBits ,
218234 "vertex buffer memory" );
219235
220236 // bind the buffer to the new memory allocation
221- gptGfx -> bind_buffer_to_memory (ptDevice , ptAppData -> tVertexBuffer , & tVertexBufferAllocation );
237+ gptGfx -> bind_buffer_to_memory (ptDevice , ptAppData -> atVertexBuffer [0 ], & tVertexBufferAllocation0 );
238+ gptGfx -> bind_buffer_to_memory (ptDevice , ptAppData -> atVertexBuffer [1 ], & tVertexBufferAllocation1 );
222239
223240 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~index buffer~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
224241
@@ -274,11 +291,13 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
274291
275292 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~transfers~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
276293
277- memcpy (ptStagingBuffer -> tMemoryAllocation .pHostMapped , atVertexData , sizeof (float ) * PL_ARRAYSIZE (atVertexData ));
294+ memcpy (ptStagingBuffer -> tMemoryAllocation .pHostMapped , atVertexData0 , sizeof (float ) * PL_ARRAYSIZE (atVertexData0 ));
295+ memcpy (& ptStagingBuffer -> tMemoryAllocation .pHostMapped [512 ], atVertexData1 , sizeof (float ) * PL_ARRAYSIZE (atVertexData1 ));
278296 memcpy (& ptStagingBuffer -> tMemoryAllocation .pHostMapped [1024 ], atIndexData , sizeof (uint32_t ) * PL_ARRAYSIZE (atIndexData ));
279297
280298 plBlitEncoder * ptEncoder = gptStarter -> get_blit_encoder ();
281- gptGfx -> copy_buffer (ptEncoder , ptAppData -> tStagingBuffer , ptAppData -> tVertexBuffer , 0 , 0 , sizeof (float ) * PL_ARRAYSIZE (atVertexData ));
299+ gptGfx -> copy_buffer (ptEncoder , ptAppData -> tStagingBuffer , ptAppData -> atVertexBuffer [0 ], 0 , 0 , sizeof (float ) * PL_ARRAYSIZE (atVertexData0 ));
300+ gptGfx -> copy_buffer (ptEncoder , ptAppData -> tStagingBuffer , ptAppData -> atVertexBuffer [1 ], 512 , 0 , sizeof (float ) * PL_ARRAYSIZE (atVertexData1 ));
282301 gptGfx -> copy_buffer (ptEncoder , ptAppData -> tStagingBuffer , ptAppData -> tIndexBuffer , 1024 , 0 , sizeof (uint32_t ) * PL_ARRAYSIZE (atIndexData ));
283302
284303 //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~textures~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -431,10 +450,17 @@ pl_app_load(plApiRegistryI* ptApiRegistry, plAppData* ptAppData)
431450 },
432451 .atVertexBufferLayouts = {
433452 {
434- .uByteStride = sizeof (float ) * 4 ,
453+ // .uByteStride = sizeof(float) * 2,
454+ .atAttributes = {
455+ {.tFormat = PL_VERTEX_FORMAT_FLOAT2 }
456+ // {.uByteOffset = 0, .tFormat = PL_VERTEX_FORMAT_FLOAT2}
457+ }
458+ },
459+ {
460+ // .uByteStride = sizeof(float) * 2,
435461 .atAttributes = {
436- {.uByteOffset = 0 , .tFormat = PL_VERTEX_FORMAT_FLOAT2 },
437- {. uByteOffset = sizeof ( float ) * 2 , .tFormat = PL_VERTEX_FORMAT_FLOAT2 },
462+ {.uLocation = 3 , .tFormat = PL_VERTEX_FORMAT_FLOAT2 }
463+ // {.uLocation = 3, .uByteOffset = 0 , .tFormat = PL_VERTEX_FORMAT_FLOAT2}
438464 }
439465 }
440466 },
@@ -474,7 +500,8 @@ pl_app_shutdown(plAppData* ptAppData)
474500 gptGfx -> flush_device (ptDevice );
475501
476502 // cleanup our resources
477- gptGfx -> destroy_buffer (ptDevice , ptAppData -> tVertexBuffer );
503+ gptGfx -> destroy_buffer (ptDevice , ptAppData -> atVertexBuffer [0 ]);
504+ gptGfx -> destroy_buffer (ptDevice , ptAppData -> atVertexBuffer [1 ]);
478505 gptGfx -> destroy_buffer (ptDevice , ptAppData -> tIndexBuffer );
479506 gptGfx -> destroy_buffer (ptDevice , ptAppData -> tStagingBuffer );
480507 gptGfx -> destroy_texture (ptDevice , ptAppData -> tTexture );
@@ -513,7 +540,7 @@ pl_app_update(plAppData* ptAppData)
513540
514541 // submit nonindexed draw using basic API
515542 gptGfx -> bind_shader (ptEncoder , ptAppData -> tShader );
516- gptGfx -> bind_vertex_buffer (ptEncoder , ptAppData -> tVertexBuffer );
543+ gptGfx -> bind_vertex_buffers (ptEncoder , 0 , 2 , ptAppData -> atVertexBuffer , NULL );
517544
518545 // retrieve dynamic binding data
519546 // NOTE: This system is meant frequently updated shader data. Underneath its just simple
0 commit comments