@@ -341,22 +341,22 @@ [.. usings]
341341 CppFunction cppFunction = command . Value ;
342342
343343 bool canUseOut = _outReturnFunctions . Contains ( cppFunction . Name ) ;
344- WriteFunctionInvocation ( writer , cppFunction , false , instance : true ) ;
344+ WriteFunctionInvocation ( writer , cppFunction , false , instance : true , firstParameterType : "VkInstance" , firstParameterValue : "Instance" ) ;
345345
346346 if ( command . Key . StartsWith ( "vkCreate" )
347347 && command . Key != "vkCreateDeferredOperationKHR" )
348348 {
349- WriteFunctionInvocation ( writer , cppFunction , false , true , instance : true ) ;
349+ WriteFunctionInvocation ( writer , cppFunction , false , true , instance : true , firstParameterType : "VkInstance" , firstParameterValue : "Instance" ) ;
350350 }
351351
352352 if ( canUseOut )
353353 {
354- WriteFunctionInvocation ( writer , cppFunction , true , instance : true ) ;
354+ WriteFunctionInvocation ( writer , cppFunction , true , instance : true , firstParameterType : "VkInstance" , firstParameterValue : "Instance" ) ;
355355
356356 if ( command . Key . StartsWith ( "vkCreate" )
357357 && command . Key != "vkCreateDeferredOperationKHR" )
358358 {
359- WriteFunctionInvocation ( writer , cppFunction , true , true , instance : true ) ;
359+ WriteFunctionInvocation ( writer , cppFunction , true , true , instance : true , firstParameterType : "VkInstance" , firstParameterValue : "Instance" ) ;
360360 }
361361 }
362362 }
@@ -388,22 +388,22 @@ [.. usings]
388388 CppFunction cppFunction = command . Value ;
389389
390390 bool canUseOut = _outReturnFunctions . Contains ( cppFunction . Name ) ;
391- WriteFunctionInvocation ( writer , cppFunction , false , instance : true ) ;
391+ WriteFunctionInvocation ( writer , cppFunction , false , instance : true , firstParameterType : "VkDevice" , firstParameterValue : "Device" ) ;
392392
393393 if ( command . Key . StartsWith ( "vkCreate" )
394394 && command . Key != "vkCreateDeferredOperationKHR" )
395395 {
396- WriteFunctionInvocation ( writer , cppFunction , false , true , instance : true ) ;
396+ WriteFunctionInvocation ( writer , cppFunction , false , true , instance : true , firstParameterType : "VkDevice" , firstParameterValue : "Device" ) ;
397397 }
398398
399399 if ( canUseOut )
400400 {
401- WriteFunctionInvocation ( writer , cppFunction , true , instance : true ) ;
401+ WriteFunctionInvocation ( writer , cppFunction , true , instance : true , firstParameterType : "VkDevice" , firstParameterValue : "Device" ) ;
402402
403403 if ( command . Key . StartsWith ( "vkCreate" )
404404 && command . Key != "vkCreateDeferredOperationKHR" )
405405 {
406- WriteFunctionInvocation ( writer , cppFunction , true , true , instance : true ) ;
406+ WriteFunctionInvocation ( writer , cppFunction , true , true , instance : true , firstParameterType : "VkDevice" , firstParameterValue : "Device" ) ;
407407 }
408408 }
409409 }
@@ -458,14 +458,16 @@ private void WriteFunctionInvocation(CodeWriter writer,
458458 CppFunction cppFunction ,
459459 bool canUseOut ,
460460 bool inParameters = false ,
461- bool instance = false )
461+ bool instance = false ,
462+ string ? firstParameterType = default ,
463+ string ? firstParameterValue = default )
462464 {
463465 bool hasAllocationCallbacks = _options . IsVulkan ? HasAllocationCallbacks ( cppFunction ) : false ;
464- WriteFunctionInvocationInner ( writer , cppFunction , canUseOut , inParameters , instance , true ) ;
466+ WriteFunctionInvocationInner ( writer , cppFunction , canUseOut , inParameters , instance , true , firstParameterType , firstParameterValue ) ;
465467
466468 if ( hasAllocationCallbacks )
467469 {
468- WriteFunctionInvocationInner ( writer , cppFunction , canUseOut , inParameters , instance , false ) ;
470+ WriteFunctionInvocationInner ( writer , cppFunction , canUseOut , inParameters , instance , false , firstParameterType , firstParameterValue ) ;
469471 }
470472 }
471473
@@ -474,10 +476,12 @@ private void WriteFunctionInvocationInner(CodeWriter writer,
474476 bool canUseOut ,
475477 bool inParameters ,
476478 bool instance ,
477- bool skipAllocationCallbacks )
479+ bool skipAllocationCallbacks ,
480+ string ? firstParameterType = default ,
481+ string ? firstParameterValue = default )
478482 {
479483 string returnCsName = GetCsTypeName ( cppFunction . ReturnType ) ;
480- string argumentsString = GetParameterSignature ( cppFunction , canUseOut , inParameters , skipAllocationCallbacks ) ;
484+ string argumentsString = GetParameterSignature ( cppFunction , canUseOut , inParameters , skipAllocationCallbacks , firstParameterType ) ;
481485 string modifier = "public" ;
482486 if ( instance == false )
483487 modifier += " static" ;
@@ -584,7 +588,17 @@ private void WriteFunctionInvocationInner(CodeWriter writer,
584588 }
585589 else
586590 {
587- writer . Write ( $ "{ paramCsName } ") ;
591+ if ( index == 0
592+ && ! string . IsNullOrEmpty ( firstParameterType )
593+ && ! string . IsNullOrEmpty ( firstParameterValue )
594+ && paramCsTypeName == firstParameterType )
595+ {
596+ writer . Write ( $ "{ firstParameterValue } ") ;
597+ }
598+ else
599+ {
600+ writer . Write ( $ "{ paramCsName } ") ;
601+ }
588602 }
589603
590604 if ( index < cppFunction . Parameters . Count - 1 )
@@ -665,18 +679,22 @@ private bool IsInstanceFunction(string name)
665679 return _instanceFunctions . Contains ( name ) ;
666680 }
667681
668- public static string GetParameterSignature ( CppFunction cppFunction , bool canUseOut , bool inParameters , bool skipAllocationCallbacks = false )
682+ public static string GetParameterSignature ( CppFunction cppFunction ,
683+ bool canUseOut ,
684+ bool inParameters ,
685+ bool skipAllocationCallbacks = false ,
686+ string ? firstParameterType = default )
669687 {
670- return GetParameterSignature ( cppFunction . Parameters , canUseOut , inParameters , skipAllocationCallbacks ) ;
688+ return GetParameterSignature ( cppFunction . Parameters , canUseOut , inParameters , skipAllocationCallbacks , firstParameterType ) ;
671689 }
672690
673691 private static string GetParameterSignature ( IList < CppParameter > parameters ,
674692 bool canUseOut ,
675693 bool inParameters ,
676- bool skipAllocationCallbacks = false )
694+ bool skipAllocationCallbacks = false ,
695+ string ? firstParameterType = default )
677696 {
678697 StringBuilder argumentBuilder = new ( ) ;
679- int index = 0 ;
680698
681699 IList < CppParameter > processParameters ;
682700 if ( skipAllocationCallbacks )
@@ -687,6 +705,13 @@ private static string GetParameterSignature(IList<CppParameter> parameters,
687705 {
688706 string paramCsTypeName = GetCsTypeName ( cppParameter . Type ) ;
689707
708+ if ( processParameters . Count == 0
709+ && ! string . IsNullOrEmpty ( firstParameterType )
710+ && paramCsTypeName == firstParameterType )
711+ {
712+ continue ;
713+ }
714+
690715 if ( paramCsTypeName == "VkAllocationCallbacks*" )
691716 {
692717 continue ;
@@ -695,11 +720,30 @@ private static string GetParameterSignature(IList<CppParameter> parameters,
695720 processParameters . Add ( cppParameter ) ;
696721 }
697722 }
723+ else if ( ! string . IsNullOrEmpty ( firstParameterType ) )
724+ {
725+ processParameters = [ ] ;
726+
727+ foreach ( CppParameter cppParameter in parameters )
728+ {
729+ string paramCsTypeName = GetCsTypeName ( cppParameter . Type ) ;
730+
731+ if ( processParameters . Count == 0 &&
732+ paramCsTypeName == firstParameterType )
733+ {
734+ continue ;
735+ }
736+
737+ processParameters . Add ( cppParameter ) ;
738+ }
739+ }
698740 else
699741 {
700742 processParameters = parameters ;
701743 }
702744
745+
746+ int index = 0 ;
703747 foreach ( CppParameter cppParameter in processParameters )
704748 {
705749 string direction = string . Empty ;
0 commit comments