mirror of
https://github.com/KhronosGroup/Vulkan-Hpp.git
synced 2024-10-14 16:32:17 +00:00
Merge pull request #1207 from asuessenbach/format
Introduce trait function componentName() and componentNumericFormat() on vk::Format.
This commit is contained in:
commit
77ba1eeb27
@ -523,6 +523,10 @@ vulkan.hpp provides a couple of trait functions on `vk::Format`. With C++14 and
|
|||||||
True, if the components of this format are compressed, otherwise False.
|
True, if the components of this format are compressed, otherwise False.
|
||||||
- `uint8_t componentBits( vk::Format format, uint8_t component );`
|
- `uint8_t componentBits( vk::Format format, uint8_t component );`
|
||||||
Gets the number of bits in this component, if not compressed, otherwise 0.
|
Gets the number of bits in this component, if not compressed, otherwise 0.
|
||||||
|
- `char const * componentName( vk::Format format, uint8_t component );`
|
||||||
|
Gets the name of this component as a c-string.
|
||||||
|
- `char const * componentNumericFormat( vk::Format format, uint8_t component );`
|
||||||
|
Gets the numeric format of this component as a c-string.
|
||||||
- `uint8_t componentPlaneIndex( vk::Format format, uint8_t component );`
|
- `uint8_t componentPlaneIndex( vk::Format format, uint8_t component );`
|
||||||
Gets the plane index, this component lies in.
|
Gets the plane index, this component lies in.
|
||||||
- `uint8_t planeCount( vk::Format format );`
|
- `uint8_t planeCount( vk::Format format );`
|
||||||
|
@ -452,16 +452,6 @@ ${packedCases}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The number of components of this format.
|
|
||||||
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_14 uint8_t componentCount( VULKAN_HPP_NAMESPACE::Format format )
|
|
||||||
{
|
|
||||||
switch( format )
|
|
||||||
{
|
|
||||||
${componentCountCases}
|
|
||||||
default: return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// True, if the components of this format are compressed, otherwise false.
|
// True, if the components of this format are compressed, otherwise false.
|
||||||
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_14 bool componentsAreCompressed( VULKAN_HPP_NAMESPACE::Format format )
|
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_14 bool componentsAreCompressed( VULKAN_HPP_NAMESPACE::Format format )
|
||||||
{
|
{
|
||||||
@ -483,6 +473,36 @@ ${componentBitsCases}
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The number of components of this format.
|
||||||
|
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_14 uint8_t componentCount( VULKAN_HPP_NAMESPACE::Format format )
|
||||||
|
{
|
||||||
|
switch( format )
|
||||||
|
{
|
||||||
|
${componentCountCases}
|
||||||
|
default: return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The name of the component
|
||||||
|
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_14 char const * componentName( VULKAN_HPP_NAMESPACE::Format format, uint8_t component )
|
||||||
|
{
|
||||||
|
switch( format )
|
||||||
|
{
|
||||||
|
${componentNameCases}
|
||||||
|
default: return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The numeric format of the component
|
||||||
|
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_14 char const * componentNumericFormat( VULKAN_HPP_NAMESPACE::Format format, uint8_t component )
|
||||||
|
{
|
||||||
|
switch( format )
|
||||||
|
{
|
||||||
|
${componentNumericFormatCases}
|
||||||
|
default: return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// The plane this component lies in.
|
// The plane this component lies in.
|
||||||
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_14 uint8_t componentPlaneIndex( VULKAN_HPP_NAMESPACE::Format format, uint8_t component )
|
VULKAN_HPP_INLINE VULKAN_HPP_CONSTEXPR_14 uint8_t componentPlaneIndex( VULKAN_HPP_NAMESPACE::Format format, uint8_t component )
|
||||||
{
|
{
|
||||||
@ -539,8 +559,9 @@ ${planeWidthDivisorCases}
|
|||||||
assert( formatIt->second.values.front().name == "VK_FORMAT_UNDEFINED" );
|
assert( formatIt->second.values.front().name == "VK_FORMAT_UNDEFINED" );
|
||||||
|
|
||||||
std::string blockSizeCases, texelsPerBlockCases, blockExtentCases, compressionSchemeCases, packedCases,
|
std::string blockSizeCases, texelsPerBlockCases, blockExtentCases, compressionSchemeCases, packedCases,
|
||||||
componentCountCases, componentsAreCompressedCases, componentBitsCases, componentPlaneIndexCases, planeCountCases,
|
componentsAreCompressedCases, componentCountCases, componentBitsCases, componentNameCases,
|
||||||
planeCompatibleCases, planeHeightDivisorCases, planeWidthDivisorCases;
|
componentNumericFormatCases, componentPlaneIndexCases, planeCountCases, planeCompatibleCases,
|
||||||
|
planeHeightDivisorCases, planeWidthDivisorCases;
|
||||||
for ( auto formatValuesIt = std::next( formatIt->second.values.begin() );
|
for ( auto formatValuesIt = std::next( formatIt->second.values.begin() );
|
||||||
formatValuesIt != formatIt->second.values.end();
|
formatValuesIt != formatIt->second.values.end();
|
||||||
++formatValuesIt )
|
++formatValuesIt )
|
||||||
@ -570,7 +591,7 @@ ${planeWidthDivisorCases}
|
|||||||
componentCountCases += caseString + " return " + std::to_string( traitIt->second.components.size() ) + ";\n";
|
componentCountCases += caseString + " return " + std::to_string( traitIt->second.components.size() ) + ";\n";
|
||||||
if ( traitIt->second.components.front().bits == "compressed" )
|
if ( traitIt->second.components.front().bits == "compressed" )
|
||||||
{
|
{
|
||||||
componentsAreCompressedCases += caseString += "\n";
|
componentsAreCompressedCases += caseString + "\n";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -592,6 +613,47 @@ ${componentCases}
|
|||||||
componentBitsCases += replaceWithMap( componentBitsCaseTemplate,
|
componentBitsCases += replaceWithMap( componentBitsCaseTemplate,
|
||||||
{ { "caseString", caseString }, { "componentCases", componentCases } } );
|
{ { "caseString", caseString }, { "componentCases", componentCases } } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const std::string componentNameCaseTemplate = R"(${caseString}
|
||||||
|
switch( component )
|
||||||
|
{
|
||||||
|
${componentCases}
|
||||||
|
default: VULKAN_HPP_ASSERT( false ); return "";
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
std::string componentCases;
|
||||||
|
for ( size_t i = 0; i < traitIt->second.components.size(); ++i )
|
||||||
|
{
|
||||||
|
componentCases +=
|
||||||
|
" case " + std::to_string( i ) + ": return \"" + traitIt->second.components[i].name + "\";\n";
|
||||||
|
}
|
||||||
|
componentCases.pop_back();
|
||||||
|
componentNameCases += replaceWithMap( componentNameCaseTemplate,
|
||||||
|
{ { "caseString", caseString }, { "componentCases", componentCases } } );
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
const std::string componentNumericFormatCaseTemplate = R"(${caseString}
|
||||||
|
switch( component )
|
||||||
|
{
|
||||||
|
${componentCases}
|
||||||
|
default: VULKAN_HPP_ASSERT( false ); return "";
|
||||||
|
}
|
||||||
|
)";
|
||||||
|
|
||||||
|
std::string componentCases;
|
||||||
|
for ( size_t i = 0; i < traitIt->second.components.size(); ++i )
|
||||||
|
{
|
||||||
|
componentCases += " case " + std::to_string( i ) + ": return \"" +
|
||||||
|
traitIt->second.components[i].numericFormat + "\";\n";
|
||||||
|
}
|
||||||
|
componentCases.pop_back();
|
||||||
|
componentNumericFormatCases += replaceWithMap(
|
||||||
|
componentNumericFormatCaseTemplate, { { "caseString", caseString }, { "componentCases", componentCases } } );
|
||||||
|
}
|
||||||
|
|
||||||
if ( !traitIt->second.components.front().planeIndex.empty() )
|
if ( !traitIt->second.components.front().planeIndex.empty() )
|
||||||
{
|
{
|
||||||
const std::string componentPlaneIndexCaseTemplate = R"(${caseString}
|
const std::string componentPlaneIndexCaseTemplate = R"(${caseString}
|
||||||
@ -669,6 +731,8 @@ ${widthDivisorCases}
|
|||||||
{ "blockSizeCases", blockSizeCases },
|
{ "blockSizeCases", blockSizeCases },
|
||||||
{ "componentBitsCases", componentBitsCases },
|
{ "componentBitsCases", componentBitsCases },
|
||||||
{ "componentCountCases", componentCountCases },
|
{ "componentCountCases", componentCountCases },
|
||||||
|
{ "componentNameCases", componentNameCases },
|
||||||
|
{ "componentNumericFormatCases", componentNumericFormatCases },
|
||||||
{ "componentPlaneIndexCases", componentPlaneIndexCases },
|
{ "componentPlaneIndexCases", componentPlaneIndexCases },
|
||||||
{ "componentsAreCompressedCases", componentsAreCompressedCases },
|
{ "componentsAreCompressedCases", componentsAreCompressedCases },
|
||||||
{ "compressionSchemeCases", compressionSchemeCases },
|
{ "compressionSchemeCases", compressionSchemeCases },
|
||||||
@ -10738,7 +10802,8 @@ std::tuple<std::string, std::string, std::string, std::string, std::string, std:
|
|||||||
if ( multiSuccessCodeContructor )
|
if ( multiSuccessCodeContructor )
|
||||||
{
|
{
|
||||||
clearMembers += "\n m_constructorSuccessCode = VULKAN_HPP_NAMESPACE::Result::eErrorUnknown;";
|
clearMembers += "\n m_constructorSuccessCode = VULKAN_HPP_NAMESPACE::Result::eErrorUnknown;";
|
||||||
memberVariables += "\n VULKAN_HPP_NAMESPACE::Result m_constructorSuccessCode = VULKAN_HPP_NAMESPACE::Result::eErrorUnknown;";
|
memberVariables +=
|
||||||
|
"\n VULKAN_HPP_NAMESPACE::Result m_constructorSuccessCode = VULKAN_HPP_NAMESPACE::Result::eErrorUnknown;";
|
||||||
swapMembers += "\n std::swap( m_constructorSuccessCode, rhs.m_constructorSuccessCode );";
|
swapMembers += "\n std::swap( m_constructorSuccessCode, rhs.m_constructorSuccessCode );";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user