@@ -390,7 +390,7 @@ int main()
390
390
{
391
391
// lp.loaderFlags = asset::IAssetLoader::ELPF_DONT_COMPILE_GLSL;
392
392
meshes_bundle = am->getAsset (file.result ()[0 ], lp);
393
- if (meshes_bundle.isEmpty ())
393
+ if (meshes_bundle.getContents (). empty ())
394
394
{
395
395
pfd::message (" Choose file to open" , " Chosen file could not be loaded. Choose another OBJ file to open or press cancel to open a default scene." , pfd::choice::ok);
396
396
continue ;
@@ -402,7 +402,7 @@ int main()
402
402
403
403
fs->addFileArchive (" ../../media/sponza.zip" );
404
404
meshes_bundle = am->getAsset (" sponza.obj" , lp);
405
- if (meshes_bundle.isEmpty ())
405
+ if (meshes_bundle.getContents (). empty ())
406
406
{
407
407
std::cout << " Could not open Sponza.zip. Quitting program" ;
408
408
return 1 ;
@@ -423,21 +423,21 @@ int main()
423
423
if (!asset::IMeshManipulator::getPolyCount (triangleCount, mesh_raw))
424
424
assert (false );
425
425
426
- const asset::CMTLPipelineMetadata* pipelineMetadata = nullptr ;
426
+ const auto meta = meshes_bundle.getMetadata ()->selfCast <const asset::COBJMetadata>();
427
+ const asset::CMTLMetadata::CRenderpassIndependentPipeline* pipelineMetadata = nullptr ;
427
428
core::map<const asset::ICPURenderpassIndependentPipeline*,core::smart_refctd_ptr<asset::ICPURenderpassIndependentPipeline>> modifiedPipelines;
428
- for (uint32_t i= 0u ; i< mesh_raw->getMeshBufferCount (); i++ )
429
+ for (auto mb : mesh_raw->getMeshBuffers () )
429
430
{
430
- auto mb = mesh_raw->getMeshBuffer (i);
431
431
auto * pipeline = mb->getPipeline ();
432
432
auto found = modifiedPipelines.find (pipeline);
433
433
if (found==modifiedPipelines.end ())
434
434
{
435
+ pipelineMetadata = static_cast <const asset::CMTLMetadata::CRenderpassIndependentPipeline*>(meta->getAssetSpecificMetadata (pipeline));
436
+
435
437
// new pipeline to modify, copy the pipeline
436
438
auto pipeline_cp = core::smart_refctd_ptr_static_cast<asset::ICPURenderpassIndependentPipeline>(pipeline->clone (1u ));
437
439
438
440
// insert a geometry shader into the pipeline
439
- assert (pipelineMetadata->getLoaderName () == " CGraphicsPipelineLoaderMTL" );
440
- pipelineMetadata = static_cast <const asset::CMTLPipelineMetadata*>(pipeline->getMetadata ());
441
441
pipeline_cp->setShaderAtIndex (asset::ICPURenderpassIndependentPipeline::ESSI_GEOMETRY_SHADER_IX,(pipelineMetadata->usesShaderWithUVs () ? geomShaderUV:geomShaderNOUV).get ());
442
442
443
443
// add descriptor set layout with one that has an SSBO and UBO
@@ -454,7 +454,7 @@ int main()
454
454
455
455
// we can safely assume that all meshbuffers within mesh loaded from OBJ has same DS1 layout (used for camera-specific data)
456
456
// so we can create just one DS
457
- asset::ICPUDescriptorSetLayout* ds1layout = mesh_raw->getMeshBuffer ( 0u ) ->getPipeline ()->getLayout ()->getDescriptorSetLayout (1u );
457
+ asset::ICPUDescriptorSetLayout* ds1layout = mesh_raw->getMeshBuffers (). begin ()[ 0 ] ->getPipeline ()->getLayout ()->getDescriptorSetLayout (1u );
458
458
uint32_t ds1UboBinding = 0u ;
459
459
for (const auto & bnd : ds1layout->getBindings ())
460
460
if (bnd.type ==asset::EDT_UNIFORM_BUFFER)
@@ -465,8 +465,8 @@ int main()
465
465
466
466
size_t neededDS1UBOsz = 0ull ;
467
467
{
468
- for (const auto & shdrIn : pipelineMetadata->getCommonRequiredInputs ())
469
- if (shdrIn.descriptorSection .type ==asset::IPipelineMetadata ::ShaderInput::ET_UNIFORM_BUFFER && shdrIn.descriptorSection .uniformBufferObject .set ==1u && shdrIn.descriptorSection .uniformBufferObject .binding ==ds1UboBinding)
468
+ for (const auto & shdrIn : pipelineMetadata->getRequiredShaderInputs ())
469
+ if (shdrIn.descriptorSection .type ==asset::IRenderpassIndependentPipelineMetadata ::ShaderInput::ET_UNIFORM_BUFFER && shdrIn.descriptorSection .uniformBufferObject .set ==1u && shdrIn.descriptorSection .uniformBufferObject .binding ==ds1UboBinding)
470
470
neededDS1UBOsz = std::max<size_t >(neededDS1UBOsz, shdrIn.descriptorSection .uniformBufferObject .relByteoffset +shdrIn.descriptorSection .uniformBufferObject .bytesize );
471
471
}
472
472
@@ -545,25 +545,25 @@ int main()
545
545
546
546
547
547
core::vector<uint8_t > uboData (gpuubo->getSize ());
548
- for (const auto & shdrIn : pipelineMetadata->getCommonRequiredInputs ())
548
+ for (const auto & shdrIn : pipelineMetadata->getRequiredShaderInputs ())
549
549
{
550
- if (shdrIn.descriptorSection .type ==asset::IPipelineMetadata ::ShaderInput::ET_UNIFORM_BUFFER && shdrIn.descriptorSection .uniformBufferObject .set ==1u && shdrIn.descriptorSection .uniformBufferObject .binding ==ds1UboBinding)
550
+ if (shdrIn.descriptorSection .type ==asset::IRenderpassIndependentPipelineMetadata ::ShaderInput::ET_UNIFORM_BUFFER && shdrIn.descriptorSection .uniformBufferObject .set ==1u && shdrIn.descriptorSection .uniformBufferObject .binding ==ds1UboBinding)
551
551
{
552
552
switch (shdrIn.type )
553
553
{
554
- case asset::IPipelineMetadata ::ECSI_WORLD_VIEW_PROJ:
554
+ case asset::IRenderpassIndependentPipelineMetadata ::ECSI_WORLD_VIEW_PROJ:
555
555
{
556
556
core::matrix4SIMD mvp = camera->getConcatenatedMatrix ();
557
557
memcpy (uboData.data ()+shdrIn.descriptorSection .uniformBufferObject .relByteoffset , mvp.pointer (), shdrIn.descriptorSection .uniformBufferObject .bytesize );
558
558
}
559
559
break ;
560
- case asset::IPipelineMetadata ::ECSI_WORLD_VIEW:
560
+ case asset::IRenderpassIndependentPipelineMetadata ::ECSI_WORLD_VIEW:
561
561
{
562
562
core::matrix3x4SIMD MV = camera->getViewMatrix ();
563
563
memcpy (uboData.data () + shdrIn.descriptorSection .uniformBufferObject .relByteoffset , MV.pointer (), shdrIn.descriptorSection .uniformBufferObject .bytesize );
564
564
}
565
565
break ;
566
- case asset::IPipelineMetadata ::ECSI_WORLD_VIEW_INVERSE_TRANSPOSE:
566
+ case asset::IRenderpassIndependentPipelineMetadata ::ECSI_WORLD_VIEW_INVERSE_TRANSPOSE:
567
567
{
568
568
core::matrix3x4SIMD MV = camera->getViewMatrix ();
569
569
memcpy (uboData.data ()+shdrIn.descriptorSection .uniformBufferObject .relByteoffset , MV.pointer (), shdrIn.descriptorSection .uniformBufferObject .bytesize );
@@ -575,9 +575,8 @@ int main()
575
575
driver->updateBufferRangeViaStagingBuffer (gpuubo.get (), 0ull , gpuubo->getSize (), uboData.data ());
576
576
577
577
// draw the meshbuffers and compute lines
578
- for (uint32_t i = 0u ; i < gpumesh->getMeshBufferCount (); ++i )
578
+ for (auto gpumb : gpumesh->getMeshBuffers () )
579
579
{
580
- video::IGPUMeshBuffer* gpumb = gpumesh->getMeshBuffer (i);
581
580
const video::IGPURenderpassIndependentPipeline* pipeline = gpumb->getPipeline ();
582
581
const video::IGPUDescriptorSet* ds3 = gpumb->getAttachedDescriptorSet ();
583
582
0 commit comments