@@ -358,15 +358,25 @@ bool VulkanCppConsumerBase::WriteSwapchainFiles()
358
358
int32_t result = util::platform::FileOpen (&header_file, header_filename.c_str (), " w" );
359
359
if (result == 0 )
360
360
{
361
+ fputs (sCommonHeaderOutputHeaders , header_file);
361
362
fputs (sSwapchainHeaderCode , header_file);
362
363
364
+ if (enable_virtual_swapchain_)
365
+ {
366
+ fputs (" \n\n // Enable the virtual swapchain code\n " , header_file);
367
+ fputs (" #define USE_VIRTUAL_SWAPCHAIN 1\n " , header_file);
368
+ }
369
+ else
370
+ {
371
+ fputs (" \n\n // Disable the virtual swapchain code\n " , header_file);
372
+ fputs (" #define USE_VIRTUAL_SWAPCHAIN 0\n " , header_file);
373
+ }
374
+
363
375
util::platform::FileClose (header_file);
364
376
365
377
result = util::platform::FileOpen (&source_file, source_filename.c_str (), " w" );
366
378
if (result == 0 )
367
379
{
368
- FILE* global_file = GetGlobalFile ();
369
- fputs (sCommonHeaderOutputHeaders , source_file);
370
380
fputs (sSwapchainSourceCode , source_file);
371
381
372
382
util::platform::FileClose (source_file);
@@ -683,10 +693,17 @@ void VulkanCppConsumerBase::Generate_vkGetSwapchainImagesKHR(VkResult
683
693
684
694
pfn_loader_.AddMethodName (" vkGetSwapchainImagesKHR" );
685
695
696
+ uint32_t captured_swapchain_count = 0 ;
697
+ if (pSwapchainImageCount->GetPointer () != nullptr )
698
+ {
699
+ captured_swapchain_count = *pSwapchainImageCount->GetPointer ();
700
+ }
701
+
686
702
fprintf (file,
687
- " \t VK_CALL_CHECK(loaded_vkGetSwapchainImagesKHR (%s, %s, &%s, %s), %s);\n " ,
703
+ " \t VK_CALL_CHECK(toCppGetSwapchainImagesKHR (%s, %s, %u , &%s, %s), %s);\n " ,
688
704
GetHandle (device).c_str (),
689
705
handle_id_map_[swapchain].c_str (),
706
+ captured_swapchain_count,
690
707
ptr_map_[pSwapchainImageCount].c_str (),
691
708
swapchain_images_var_name.c_str (),
692
709
util::ToString<VkResult>(returnValue).c_str ());
@@ -1792,30 +1809,18 @@ void VulkanCppConsumerBase::Generate_vkAcquireNextImageKHR(VkResult
1792
1809
AddKnownVariables (" uint32_t" , image_index_var_name);
1793
1810
1794
1811
pfn_loader_.AddMethodName (" vkAcquireNextImageKHR" );
1795
- if (returnValue == VK_SUCCESS)
1796
- {
1797
- fprintf (file,
1798
- " \t while (loaded_vkAcquireNextImageKHR(%s, %s, %" PRIu64
1799
- " UL, %s, %s, &%s) != VK_SUCCESS) { usleep(5000); };\n " ,
1800
- GetHandle (device).c_str (),
1801
- GetHandle (swapchain).c_str (),
1802
- timeout,
1803
- GetHandle (semaphore).c_str (),
1804
- GetHandle (fence).c_str (),
1805
- image_index_var_name.c_str ());
1806
- }
1807
- else
1808
- {
1809
- fprintf (file,
1810
- " \t VK_CALL_CHECK(loaded_vkAcquireNextImageKHR(%s, %s, %" PRIu64 " UL, %s, %s, &%s), %s);\n " ,
1811
- GetHandle (device).c_str (),
1812
- GetHandle (swapchain).c_str (),
1813
- timeout,
1814
- GetHandle (semaphore).c_str (),
1815
- GetHandle (fence).c_str (),
1816
- image_index_var_name.c_str (),
1817
- util::ToString<VkResult>(returnValue).c_str ());
1818
- }
1812
+ fprintf (file,
1813
+ " \t VK_CALL_CHECK(toCppAcquireNextImageKHR(static_cast<VkResult>(0x%08x), %s, %s, %" PRIu64
1814
+ " UL, %s, %s, %u, &%s), %s);\n " ,
1815
+ returnValue,
1816
+ GetHandle (device).c_str (),
1817
+ GetHandle (swapchain).c_str (),
1818
+ timeout,
1819
+ GetHandle (semaphore).c_str (),
1820
+ GetHandle (fence).c_str (),
1821
+ (*pImageIndex->GetPointer ()),
1822
+ image_index_var_name.c_str (),
1823
+ util::ToString<VkResult>(returnValue).c_str ());
1819
1824
}
1820
1825
1821
1826
void VulkanCppConsumerBase::Generate_vkAcquireNextImage2KHR (
@@ -3283,6 +3288,25 @@ void VulkanCppConsumerBase::ProcessSetOpaqueAddressCommand(format::HandleId devi
3283
3288
}
3284
3289
}
3285
3290
3291
+ void VulkanCppConsumerBase::Generate_vkGetDeviceQueue (format::HandleId device,
3292
+ uint32_t queueFamilyIndex,
3293
+ uint32_t queueIndex,
3294
+ HandlePointerDecoder<VkQueue>* pQueue)
3295
+ {
3296
+ FILE* file = GetFrameFile ();
3297
+ fprintf (file, " \t {\n " );
3298
+ std::string pqueue_name = " pQueue_" + std::to_string (this ->GetNextId (VK_OBJECT_TYPE_QUEUE));
3299
+ AddKnownVariables (" VkQueue" , pqueue_name, pQueue->GetPointer ());
3300
+ this ->AddHandles (pqueue_name, pQueue->GetPointer ());
3301
+ fprintf (file,
3302
+ " \t\t toCppGetDeviceQueue(%s, %u, %u, &%s);\n " ,
3303
+ this ->GetHandle (device).c_str (),
3304
+ queueFamilyIndex,
3305
+ queueIndex,
3306
+ pqueue_name.c_str ());
3307
+ fprintf (file, " \t }\n " );
3308
+ }
3309
+
3286
3310
void VulkanCppConsumerBase::Generate_vkGetAndroidHardwareBufferPropertiesANDROID (
3287
3311
VkResult returnValue,
3288
3312
format::HandleId device,
@@ -3528,20 +3552,18 @@ void VulkanCppConsumerBase::Generate_vkQueuePresentKHR(VkResult
3528
3552
{
3529
3553
FILE* file = GetFrameFile ();
3530
3554
fprintf (file, " \t {\n " );
3531
- // queue
3532
- // pPresentInfo
3533
- std::stringstream stream_ppresent_info;
3534
- std::string ppresent_info_struct = GenerateStruct_VkPresentInfoKHR (stream_ppresent_info,
3535
- pPresentInfo->GetPointer (),
3536
- pPresentInfo->GetMetaStructPointer (),
3537
- imported_semaphores_,
3538
- *this );
3539
- fprintf (file, " %s" , stream_ppresent_info.str ().c_str ());
3555
+ std::stringstream stream_present_info;
3556
+ std::string present_info_struct = GenerateStruct_VkPresentInfoKHR (stream_present_info,
3557
+ pPresentInfo->GetPointer (),
3558
+ pPresentInfo->GetMetaStructPointer (),
3559
+ imported_semaphores_,
3560
+ *this );
3561
+ fprintf (file, " %s" , stream_present_info.str ().c_str ());
3540
3562
pfn_loader_.AddMethodName (" vkQueuePresentKHR" );
3541
3563
fprintf (file,
3542
- " \t\t VK_CALL_CHECK(loaded_vkQueuePresentKHR (%s, &%s), %s);\n " ,
3564
+ " \t\t VK_CALL_CHECK(toCppQueuePresentKHR (%s, &%s), %s);\n " ,
3543
3565
this ->GetHandle (queue).c_str (),
3544
- ppresent_info_struct .c_str (),
3566
+ present_info_struct .c_str (),
3545
3567
util::ToString<VkResult>(returnValue).c_str ());
3546
3568
fprintf (file, " \t }\n " );
3547
3569
}
0 commit comments