@@ -227,93 +227,6 @@ void cSokolRender::RegisterPipeline(SokolPipelineContext context) {
227
227
fprintf (stderr, " RegisterPipeline: invalid shader ID pipeline '%s'\n " , desc.label );
228
228
return ;
229
229
}
230
- SOKOL_SHADER_ID shader_id = context.shader_funcs ->get_id ();
231
- switch (shader_id) {
232
- case SOKOL_SHADER_ID_mesh_color_tex1:
233
- case SOKOL_SHADER_ID_mesh_color_tex2:
234
- if (0 > context.shader_funcs ->uniformblock_slot (SG_SHADERSTAGE_VS, " mesh_color_texture_vs_params" )) {
235
- fprintf (stderr, " RegisterPipeline: 'mesh_color_texture_vs_params' uniform slot not found at pipeline '%s'\n " , desc.label );
236
- xassert (0 );
237
- return ;
238
- } else if (context.shader_funcs ->uniformblock_size (SG_SHADERSTAGE_VS, " mesh_color_texture_vs_params" ) != sizeof (mesh_color_texture_vs_params_t )) {
239
- fprintf (stderr, " RegisterPipeline: 'mesh_color_texture_vs_params' uniform size doesnt match at pipeline '%s'\n " , desc.label );
240
- xassert (0 );
241
- return ;
242
- } else if (0 > context.shader_funcs ->uniformblock_slot (SG_SHADERSTAGE_FS, " mesh_color_texture_fs_params" )) {
243
- fprintf (stderr, " RegisterPipeline: 'mesh_color_texture_fs_params' uniform slot not found at pipeline '%s'\n " , desc.label );
244
- xassert (0 );
245
- return ;
246
- } else if (context.shader_funcs ->uniformblock_size (SG_SHADERSTAGE_FS, " mesh_color_texture_fs_params" ) != sizeof (mesh_color_texture_fs_params_t )) {
247
- fprintf (stderr, " RegisterPipeline: 'mesh_color_texture_fs_params' uniform size doesnt match at pipeline '%s'\n " , desc.label );
248
- xassert (0 );
249
- return ;
250
- }
251
- break ;
252
- case SOKOL_SHADER_ID_mesh_normal_tex1:
253
- if (0 > context.shader_funcs ->uniformblock_slot (SG_SHADERSTAGE_VS, " mesh_normal_texture_vs_params" )) {
254
- fprintf (stderr, " RegisterPipeline: 'mesh_normal_texture_vs_params' uniform slot not found at pipeline '%s'\n " , desc.label );
255
- xassert (0 );
256
- return ;
257
- } else if (context.shader_funcs ->uniformblock_size (SG_SHADERSTAGE_VS, " mesh_normal_texture_vs_params" ) != sizeof (mesh_normal_texture_vs_params_t )) {
258
- fprintf (stderr, " RegisterPipeline: 'mesh_normal_texture_vs_params' uniform size doesnt match at pipeline '%s'\n " , desc.label );
259
- xassert (0 );
260
- return ;
261
- }
262
- break ;
263
- case SOKOL_SHADER_ID_shadow_tex1:
264
- case SOKOL_SHADER_ID_shadow_normal_tex1:
265
- if (0 > context.shader_funcs ->uniformblock_slot (SG_SHADERSTAGE_VS, " shadow_texture_vs_params" )) {
266
- fprintf (stderr, " RegisterPipeline: 'shadow_texture_vs_params' uniform slot not found at pipeline '%s'\n " , desc.label );
267
- xassert (0 );
268
- return ;
269
- } else if (context.shader_funcs ->uniformblock_size (SG_SHADERSTAGE_VS, " shadow_texture_vs_params" ) != sizeof (shadow_texture_vs_params_t )) {
270
- fprintf (stderr, " RegisterPipeline: 'shadow_texture_vs_params' uniform size doesnt match at pipeline '%s'\n " , desc.label );
271
- xassert (0 );
272
- return ;
273
- } else if (0 > context.shader_funcs ->uniformblock_slot (SG_SHADERSTAGE_FS, " shadow_texture_fs_params" )) {
274
- fprintf (stderr, " RegisterPipeline: 'shadow_texture_fs_params' uniform slot not found at pipeline '%s'\n " , desc.label );
275
- xassert (0 );
276
- return ;
277
- } else if (context.shader_funcs ->uniformblock_size (SG_SHADERSTAGE_FS, " shadow_texture_fs_params" ) != sizeof (mesh_color_texture_fs_params_t )) {
278
- fprintf (stderr, " RegisterPipeline: 'shadow_texture_fs_params' uniform size doesnt match at pipeline '%s'\n " , desc.label );
279
- xassert (0 );
280
- return ;
281
- }
282
- break ;
283
- case SOKOL_SHADER_ID_mesh_tex1:
284
- if (0 > context.shader_funcs ->uniformblock_slot (SG_SHADERSTAGE_VS, " mesh_texture_vs_params" )) {
285
- fprintf (stderr, " RegisterPipeline: 'mesh_texture_vs_params' uniform slot not found at pipeline '%s'\n " , desc.label );
286
- xassert (0 );
287
- return ;
288
- } else if (context.shader_funcs ->uniformblock_size (SG_SHADERSTAGE_VS, " mesh_texture_vs_params" ) != sizeof (mesh_texture_vs_params_t )) {
289
- fprintf (stderr, " RegisterPipeline: 'mesh_texture_vs_params' uniform size doesnt match at pipeline '%s'\n " , desc.label );
290
- xassert (0 );
291
- return ;
292
- }
293
- break ;
294
- case SOKOL_SHADER_ID_tile_map:
295
- if (0 > context.shader_funcs ->uniformblock_slot (SG_SHADERSTAGE_VS, " tile_map_vs_params" )) {
296
- fprintf (stderr, " RegisterPipeline: 'tile_map_vs_params' uniform slot not found at pipeline '%s'\n " , desc.label );
297
- xassert (0 );
298
- return ;
299
- } else if (context.shader_funcs ->uniformblock_size (SG_SHADERSTAGE_VS, " tile_map_vs_params" ) != sizeof (tile_map_vs_params_t )) {
300
- fprintf (stderr, " RegisterPipeline: 'tile_map_vs_params' uniform size doesnt match at pipeline '%s'\n " , desc.label );
301
- xassert (0 );
302
- return ;
303
- } else if (0 > context.shader_funcs ->uniformblock_slot (SG_SHADERSTAGE_FS, " tile_map_fs_params" )) {
304
- fprintf (stderr, " RegisterPipeline: 'tile_map_fs_params' uniform slot not found at pipeline '%s'\n " , desc.label );
305
- xassert (0 );
306
- return ;
307
- } else if (context.shader_funcs ->uniformblock_size (SG_SHADERSTAGE_FS, " tile_map_fs_params" ) != sizeof (tile_map_fs_params_t )) {
308
- fprintf (stderr, " RegisterPipeline: 'tile_map_fs_params' uniform size doesnt match at pipeline '%s'\n " , desc.label );
309
- xassert (0 );
310
- return ;
311
- }
312
- break ;
313
- default :
314
- fprintf (stderr, " RegisterPipeline: Unknown shader id '%d' at pipeline '%s'\n " , shader_id, desc.label );
315
- return ;
316
- }
317
230
318
231
// Check for any missing slots
319
232
if (context.vertex_fmt & VERTEX_FMT_TEX1 &&
@@ -339,7 +252,8 @@ void cSokolRender::RegisterPipeline(SokolPipelineContext context) {
339
252
bind_vertex_fmt (context, VERTEX_FMT_NORMAL);
340
253
341
254
// Created, store on our pipelines
342
- // printf("RegisterPipeline: '%s' at '%d'\n", desc.label, id);
255
+ SOKOL_SHADER_ID shader_id = context.shader_funcs ->get_id ();
256
+ // printf("RegisterPipeline: '%s' at '%d'\n", desc.label, shader_id);
343
257
SokolPipeline* pipeline = new SokolPipeline {
344
258
context,
345
259
sg_make_pipeline (desc),
@@ -354,6 +268,75 @@ void cSokolRender::RegisterPipeline(SokolPipelineContext context) {
354
268
xxassert (0 , " RegisterPipeline: invalid pipeline vertex format " + std::string (desc.label ));
355
269
return ;
356
270
}
271
+ const char * vs_params_name = nullptr ;
272
+ const char * fs_params_name = nullptr ;
273
+ size_t vs_params_size = 0 ;
274
+ size_t fs_params_size = 0 ;
275
+ switch (shader_id) {
276
+ case SOKOL_SHADER_ID_mesh_color_tex1:
277
+ case SOKOL_SHADER_ID_mesh_color_tex2:
278
+ vs_params_name = " mesh_color_texture_vs_params" ;
279
+ fs_params_name = " mesh_color_texture_fs_params" ;
280
+ vs_params_size = sizeof (mesh_color_texture_vs_params_t );
281
+ fs_params_size = sizeof (mesh_color_texture_fs_params_t );
282
+ break ;
283
+ case SOKOL_SHADER_ID_mesh_normal_tex1:
284
+ vs_params_name = " mesh_normal_texture_vs_params" ;
285
+ fs_params_name = " mesh_normal_texture_fs_params" ;
286
+ vs_params_size = sizeof (mesh_normal_texture_vs_params_t );
287
+ fs_params_size = sizeof (mesh_normal_texture_fs_params_t );
288
+ break ;
289
+ case SOKOL_SHADER_ID_shadow_tex1:
290
+ case SOKOL_SHADER_ID_shadow_normal_tex1:
291
+ vs_params_name = " shadow_texture_vs_params" ;
292
+ fs_params_name = " shadow_texture_fs_params" ;
293
+ vs_params_size = sizeof (shadow_texture_vs_params_t );
294
+ fs_params_size = sizeof (shadow_texture_fs_params_t );
295
+ break ;
296
+ case SOKOL_SHADER_ID_mesh_tex1:
297
+ vs_params_name = " mesh_texture_vs_params" ;
298
+ vs_params_size = sizeof (mesh_texture_vs_params_t );
299
+ break ;
300
+ case SOKOL_SHADER_ID_tile_map:
301
+ vs_params_name = " tile_map_vs_params" ;
302
+ fs_params_name = " tile_map_fs_params" ;
303
+ vs_params_size = sizeof (tile_map_vs_params_t );
304
+ fs_params_size = sizeof (tile_map_fs_params_t );
305
+ break ;
306
+ case SOKOL_SHADER_ID_NONE:
307
+ default :
308
+ fprintf (stderr, " RegisterPipeline: Unknown shader id '%d' at pipeline '%s'\n " , shader_id, desc.label );
309
+ break ;
310
+ }
311
+
312
+ if (vs_params_name) {
313
+ pipeline->vs_params_slot = context.shader_funcs ->uniformblock_slot (SG_SHADERSTAGE_VS, vs_params_name);
314
+ if (0 > pipeline->vs_params_slot ) {
315
+ fprintf (stderr, " RegisterPipeline: '%s' vs uniform slot not found at pipeline '%s'\n " , vs_params_name,
316
+ desc.label );
317
+ xassert (0 );
318
+ return ;
319
+ } else if (context.shader_funcs ->uniformblock_size (SG_SHADERSTAGE_VS, vs_params_name) != vs_params_size) {
320
+ fprintf (stderr, " RegisterPipeline: '%s' vs uniform size doesnt match at pipeline '%s'\n " ,
321
+ vs_params_name, desc.label );
322
+ xassert (0 );
323
+ return ;
324
+ }
325
+ }
326
+ if (fs_params_name) {
327
+ pipeline->fs_params_slot = context.shader_funcs ->uniformblock_slot (SG_SHADERSTAGE_FS, fs_params_name);
328
+ if (0 > pipeline->fs_params_slot ) {
329
+ fprintf (stderr, " RegisterPipeline: '%s' fs uniform slot not found at pipeline '%s'\n " ,
330
+ fs_params_name, desc.label );
331
+ xassert (0 );
332
+ return ;
333
+ } else if (context.shader_funcs ->uniformblock_size (SG_SHADERSTAGE_FS, fs_params_name) != fs_params_size) {
334
+ fprintf (stderr, " RegisterPipeline: '%s' fs uniform size doesnt match at pipeline '%s'\n " ,
335
+ fs_params_name, desc.label );
336
+ xassert (0 );
337
+ return ;
338
+ }
339
+ }
357
340
for (int i = 0 ; i < PERIMETER_SOKOL_TEXTURES; ++i) {
358
341
std::string name = " un_tex" + std::to_string (i);
359
342
pipeline->shader_fs_texture_slot [i] = context.shader_funcs ->image_slot (SG_SHADERSTAGE_FS, name.c_str ());
0 commit comments