Introduce hard-coded default values for some structure members. (#1658)

This commit is contained in:
Andreas Süßenbach 2023-09-19 12:05:06 +02:00 committed by GitHub
parent 39c8c02de0
commit d60453f6ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 22 deletions

View File

@ -10657,11 +10657,16 @@ std::string VulkanHppGenerator::generateStructConstructorArgument( bool listedAr
{ {
str += generateEnumInitializer( memberData.type, memberData.arraySizes, enumIt->second.values, enumIt->second.isBitmask ); str += generateEnumInitializer( memberData.type, memberData.arraySizes, enumIt->second.values, enumIt->second.isBitmask );
} }
else if ( memberData.defaultValue.empty() )
{
// if there's no default value, it can be initialized with just {}
str += "{}";
}
else else
{ {
assert( memberData.value.empty() ); assert( memberData.defaultValue.starts_with( "VK_" ) );
// all the rest can be initialized with just {} std::string tag = findTag( memberData.defaultValue );
str += "{}"; str += "VULKAN_HPP_NAMESPACE::" + toCamelCase( stripPostfix( stripPrefix( memberData.defaultValue, "VK_" ), tag ) ) + tag;
} }
} }
} }
@ -11129,8 +11134,7 @@ std::tuple<std::string, std::string, std::string, std::string>
} }
else else
{ {
// as we don't have any meaningful default initialization values, everything can be initialized by just '{}' // when we don't have any default initialization value, everything can be initialized by just '{}'
// !
assert( member.arraySizes.empty() || member.bitCount.empty() ); assert( member.arraySizes.empty() || member.bitCount.empty() );
if ( !member.bitCount.empty() ) if ( !member.bitCount.empty() )
{ {
@ -11145,10 +11149,16 @@ std::tuple<std::string, std::string, std::string, std::string>
{ {
members += generateEnumInitializer( member.type, member.arraySizes, enumIt->second.values, enumIt->second.isBitmask ); members += generateEnumInitializer( member.type, member.arraySizes, enumIt->second.values, enumIt->second.isBitmask );
} }
else else if ( member.defaultValue.empty() )
{ {
members += "{}"; members += "{}";
} }
else
{
assert( member.defaultValue.starts_with( "VK_" ) );
std::string tag = findTag( member.defaultValue );
members += "VULKAN_HPP_NAMESPACE::" + toCamelCase( stripPostfix( stripPrefix( member.defaultValue, "VK_" ), tag ) ) + tag;
}
} }
} }
members += ";\n"; members += ";\n";
@ -14703,6 +14713,20 @@ void VulkanHppGenerator::readTypeStruct( tinyxml2::XMLElement const * element, b
} }
it->second.subStruct = determineSubStruct( *it ); it->second.subStruct = determineSubStruct( *it );
// add some default values for some structures here!
if ( ( it->first == "VkRayTracingShaderGroupCreateInfoNV" ) || ( it->first == "VkRayTracingShaderGroupCreateInfoKHR" ) )
{
assert( ( ( it->first != "VkRayTracingShaderGroupCreateInfoNV" ) || ( it->second.members.size() == 7 ) ) &&
( ( it->first != "VkRayTracingShaderGroupCreateInfoKHR" ) || ( it->second.members.size() == 8 ) ) );
assert( ( it->second.members[3].name == "generalShader" ) && ( it->second.members[4].name == "closestHitShader" ) &&
( it->second.members[5].name == "anyHitShader" ) && ( it->second.members[6].name == "intersectionShader" ) );
bool isKHR = ( it->first == "VkRayTracingShaderGroupCreateInfoKHR" );
for ( size_t i : { 3, 4, 5, 6 } )
{
it->second.members[i].defaultValue = isKHR ? "VK_SHADER_UNUSED_KHR" : "VK_SHADER_UNUSED_NV";
}
}
// check if multiple structure members use the very same (not empty) len attribute // check if multiple structure members use the very same (not empty) len attribute
// Note: even though the arrays are not marked as optional, they still might be mutually exclusive (like in // Note: even though the arrays are not marked as optional, they still might be mutually exclusive (like in
// VkWriteDescriptorSet)! That is, there's not enough information available in vk.xml to decide on that, so we // VkWriteDescriptorSet)! That is, there's not enough information available in vk.xml to decide on that, so we

View File

@ -312,6 +312,7 @@ private:
struct MemberData struct MemberData
{ {
std::string defaultValue = {};
TypeInfo type = {}; TypeInfo type = {};
std::string name = {}; std::string name = {};
std::vector<std::string> arraySizes = {}; std::vector<std::string> arraySizes = {};

View File

@ -93338,10 +93338,10 @@ namespace VULKAN_HPP_NAMESPACE
#if !defined( VULKAN_HPP_NO_STRUCT_CONSTRUCTORS ) #if !defined( VULKAN_HPP_NO_STRUCT_CONSTRUCTORS )
VULKAN_HPP_CONSTEXPR RayTracingShaderGroupCreateInfoKHR( VULKAN_HPP_CONSTEXPR RayTracingShaderGroupCreateInfoKHR(
VULKAN_HPP_NAMESPACE::RayTracingShaderGroupTypeKHR type_ = VULKAN_HPP_NAMESPACE::RayTracingShaderGroupTypeKHR::eGeneral, VULKAN_HPP_NAMESPACE::RayTracingShaderGroupTypeKHR type_ = VULKAN_HPP_NAMESPACE::RayTracingShaderGroupTypeKHR::eGeneral,
uint32_t generalShader_ = {}, uint32_t generalShader_ = VULKAN_HPP_NAMESPACE::ShaderUnusedKHR,
uint32_t closestHitShader_ = {}, uint32_t closestHitShader_ = VULKAN_HPP_NAMESPACE::ShaderUnusedKHR,
uint32_t anyHitShader_ = {}, uint32_t anyHitShader_ = VULKAN_HPP_NAMESPACE::ShaderUnusedKHR,
uint32_t intersectionShader_ = {}, uint32_t intersectionShader_ = VULKAN_HPP_NAMESPACE::ShaderUnusedKHR,
const void * pShaderGroupCaptureReplayHandle_ = {}, const void * pShaderGroupCaptureReplayHandle_ = {},
const void * pNext_ = nullptr ) VULKAN_HPP_NOEXCEPT const void * pNext_ = nullptr ) VULKAN_HPP_NOEXCEPT
: pNext( pNext_ ) : pNext( pNext_ )
@ -93468,10 +93468,10 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_NAMESPACE::StructureType sType = StructureType::eRayTracingShaderGroupCreateInfoKHR; VULKAN_HPP_NAMESPACE::StructureType sType = StructureType::eRayTracingShaderGroupCreateInfoKHR;
const void * pNext = {}; const void * pNext = {};
VULKAN_HPP_NAMESPACE::RayTracingShaderGroupTypeKHR type = VULKAN_HPP_NAMESPACE::RayTracingShaderGroupTypeKHR::eGeneral; VULKAN_HPP_NAMESPACE::RayTracingShaderGroupTypeKHR type = VULKAN_HPP_NAMESPACE::RayTracingShaderGroupTypeKHR::eGeneral;
uint32_t generalShader = {}; uint32_t generalShader = VULKAN_HPP_NAMESPACE::ShaderUnusedKHR;
uint32_t closestHitShader = {}; uint32_t closestHitShader = VULKAN_HPP_NAMESPACE::ShaderUnusedKHR;
uint32_t anyHitShader = {}; uint32_t anyHitShader = VULKAN_HPP_NAMESPACE::ShaderUnusedKHR;
uint32_t intersectionShader = {}; uint32_t intersectionShader = VULKAN_HPP_NAMESPACE::ShaderUnusedKHR;
const void * pShaderGroupCaptureReplayHandle = {}; const void * pShaderGroupCaptureReplayHandle = {};
}; };
@ -93879,10 +93879,10 @@ namespace VULKAN_HPP_NAMESPACE
#if !defined( VULKAN_HPP_NO_STRUCT_CONSTRUCTORS ) #if !defined( VULKAN_HPP_NO_STRUCT_CONSTRUCTORS )
VULKAN_HPP_CONSTEXPR RayTracingShaderGroupCreateInfoNV( VULKAN_HPP_CONSTEXPR RayTracingShaderGroupCreateInfoNV(
VULKAN_HPP_NAMESPACE::RayTracingShaderGroupTypeKHR type_ = VULKAN_HPP_NAMESPACE::RayTracingShaderGroupTypeKHR::eGeneral, VULKAN_HPP_NAMESPACE::RayTracingShaderGroupTypeKHR type_ = VULKAN_HPP_NAMESPACE::RayTracingShaderGroupTypeKHR::eGeneral,
uint32_t generalShader_ = {}, uint32_t generalShader_ = VULKAN_HPP_NAMESPACE::ShaderUnusedNV,
uint32_t closestHitShader_ = {}, uint32_t closestHitShader_ = VULKAN_HPP_NAMESPACE::ShaderUnusedNV,
uint32_t anyHitShader_ = {}, uint32_t anyHitShader_ = VULKAN_HPP_NAMESPACE::ShaderUnusedNV,
uint32_t intersectionShader_ = {}, uint32_t intersectionShader_ = VULKAN_HPP_NAMESPACE::ShaderUnusedNV,
const void * pNext_ = nullptr ) VULKAN_HPP_NOEXCEPT const void * pNext_ = nullptr ) VULKAN_HPP_NOEXCEPT
: pNext( pNext_ ) : pNext( pNext_ )
, type( type_ ) , type( type_ )
@ -93998,10 +93998,10 @@ namespace VULKAN_HPP_NAMESPACE
VULKAN_HPP_NAMESPACE::StructureType sType = StructureType::eRayTracingShaderGroupCreateInfoNV; VULKAN_HPP_NAMESPACE::StructureType sType = StructureType::eRayTracingShaderGroupCreateInfoNV;
const void * pNext = {}; const void * pNext = {};
VULKAN_HPP_NAMESPACE::RayTracingShaderGroupTypeKHR type = VULKAN_HPP_NAMESPACE::RayTracingShaderGroupTypeKHR::eGeneral; VULKAN_HPP_NAMESPACE::RayTracingShaderGroupTypeKHR type = VULKAN_HPP_NAMESPACE::RayTracingShaderGroupTypeKHR::eGeneral;
uint32_t generalShader = {}; uint32_t generalShader = VULKAN_HPP_NAMESPACE::ShaderUnusedNV;
uint32_t closestHitShader = {}; uint32_t closestHitShader = VULKAN_HPP_NAMESPACE::ShaderUnusedNV;
uint32_t anyHitShader = {}; uint32_t anyHitShader = VULKAN_HPP_NAMESPACE::ShaderUnusedNV;
uint32_t intersectionShader = {}; uint32_t intersectionShader = VULKAN_HPP_NAMESPACE::ShaderUnusedNV;
}; };
template <> template <>