Utility/PixelFormat: use std::string_view to store name
This commit is contained in:
parent
dfe6b2ddcf
commit
68b3e31eec
|
|
@ -26,9 +26,9 @@ namespace Nz
|
||||||
{
|
{
|
||||||
inline PixelFormatDescription();
|
inline PixelFormatDescription();
|
||||||
inline PixelFormatDescription(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType);
|
inline PixelFormatDescription(PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType);
|
||||||
inline PixelFormatDescription(const std::string& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType);
|
inline PixelFormatDescription(std::string_view formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType);
|
||||||
inline PixelFormatDescription(const std::string& formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType);
|
inline PixelFormatDescription(std::string_view formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType);
|
||||||
inline PixelFormatDescription(const std::string& formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp = 0);
|
inline PixelFormatDescription(std::string_view formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp = 0);
|
||||||
|
|
||||||
inline void Clear();
|
inline void Clear();
|
||||||
|
|
||||||
|
|
@ -39,7 +39,7 @@ namespace Nz
|
||||||
|
|
||||||
inline bool Validate() const;
|
inline bool Validate() const;
|
||||||
|
|
||||||
std::string name;
|
std::string_view name;
|
||||||
// Warning: Masks bit order is reversed
|
// Warning: Masks bit order is reversed
|
||||||
Bitset<> redMask;
|
Bitset<> redMask;
|
||||||
Bitset<> greenMask;
|
Bitset<> greenMask;
|
||||||
|
|
@ -72,7 +72,7 @@ namespace Nz
|
||||||
static inline PixelFormatContent GetContent(PixelFormat format);
|
static inline PixelFormatContent GetContent(PixelFormat format);
|
||||||
static inline UInt8 GetBytesPerPixel(PixelFormat format);
|
static inline UInt8 GetBytesPerPixel(PixelFormat format);
|
||||||
static inline const PixelFormatDescription& GetInfo(PixelFormat format);
|
static inline const PixelFormatDescription& GetInfo(PixelFormat format);
|
||||||
static inline const std::string& GetName(PixelFormat format);
|
static inline std::string_view GetName(PixelFormat format);
|
||||||
|
|
||||||
static inline bool HasAlpha(PixelFormat format);
|
static inline bool HasAlpha(PixelFormat format);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline PixelFormatDescription::PixelFormatDescription(const std::string& formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) :
|
inline PixelFormatDescription::PixelFormatDescription(std::string_view formatName, PixelFormatContent formatContent, UInt8 bpp, PixelFormatSubType subType) :
|
||||||
name(formatName),
|
name(formatName),
|
||||||
content(formatContent),
|
content(formatContent),
|
||||||
redType(subType),
|
redType(subType),
|
||||||
|
|
@ -37,12 +37,12 @@ namespace Nz
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline PixelFormatDescription::PixelFormatDescription(const std::string& formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType) :
|
inline PixelFormatDescription::PixelFormatDescription(std::string_view formatName, PixelFormatContent formatContent, Bitset<> rMask, Bitset<> gMask, Bitset<> bMask, Bitset<> aMask, PixelFormatSubType subType) :
|
||||||
PixelFormatDescription(formatName, formatContent, subType, rMask, subType, gMask, subType, bMask, subType, aMask)
|
PixelFormatDescription(formatName, formatContent, subType, rMask, subType, gMask, subType, bMask, subType, aMask)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline PixelFormatDescription::PixelFormatDescription(const std::string& formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp) :
|
inline PixelFormatDescription::PixelFormatDescription(std::string_view formatName, PixelFormatContent formatContent, PixelFormatSubType rType, Bitset<> rMask, PixelFormatSubType gType, Bitset<> gMask, PixelFormatSubType bType, Bitset<> bMask, PixelFormatSubType aType, Bitset<> aMask, UInt8 bpp) :
|
||||||
name(formatName),
|
name(formatName),
|
||||||
redMask(rMask),
|
redMask(rMask),
|
||||||
greenMask(gMask),
|
greenMask(gMask),
|
||||||
|
|
@ -70,7 +70,7 @@ namespace Nz
|
||||||
blueMask.Clear();
|
blueMask.Clear();
|
||||||
greenMask.Clear();
|
greenMask.Clear();
|
||||||
redMask.Clear();
|
redMask.Clear();
|
||||||
name.clear();
|
name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool PixelFormatDescription::IsCompressed() const
|
inline bool PixelFormatDescription::IsCompressed() const
|
||||||
|
|
@ -233,7 +233,7 @@ namespace Nz
|
||||||
return s_pixelFormatInfos[format];
|
return s_pixelFormatInfos[format];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const std::string& PixelFormatInfo::GetName(PixelFormat format)
|
inline std::string_view PixelFormatInfo::GetName(PixelFormat format)
|
||||||
{
|
{
|
||||||
return s_pixelFormatInfos[format].name;
|
return s_pixelFormatInfos[format].name;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@ namespace Nz
|
||||||
|
|
||||||
case PixelFormatContent::Undefined:
|
case PixelFormatContent::Undefined:
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error("unhandled pixel format " + PixelFormatInfo::GetName(textureFormat));
|
throw std::runtime_error("unhandled pixel format " + std::string(PixelFormatInfo::GetName(textureFormat)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glTexture.RequiresTextureViewEmulation())
|
if (glTexture.RequiresTextureViewEmulation())
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ namespace Nz
|
||||||
|
|
||||||
if (!PixelFormatInfo::IsConversionSupported(m_sharedImage->format, newFormat))
|
if (!PixelFormatInfo::IsConversionSupported(m_sharedImage->format, newFormat))
|
||||||
{
|
{
|
||||||
NazaraError("Conversion from " + PixelFormatInfo::GetName(m_sharedImage->format) + " to " + PixelFormatInfo::GetName(newFormat) + " is not supported");
|
NazaraError("Conversion from " + std::string(PixelFormatInfo::GetName(m_sharedImage->format)) + " to " + std::string(PixelFormatInfo::GetName(newFormat)) + " is not supported");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -313,7 +313,7 @@ namespace Nz
|
||||||
std::unique_ptr<UInt8[]> colorBuffer(new UInt8[bpp]);
|
std::unique_ptr<UInt8[]> colorBuffer(new UInt8[bpp]);
|
||||||
if (!PixelFormatInfo::Convert(PixelFormat::RGBA8, m_sharedImage->format, &color.r, colorBuffer.get()))
|
if (!PixelFormatInfo::Convert(PixelFormat::RGBA8, m_sharedImage->format, &color.r, colorBuffer.get()))
|
||||||
{
|
{
|
||||||
NazaraError("Failed to convert RGBA8 to " + PixelFormatInfo::GetName(m_sharedImage->format));
|
NazaraError("Failed to convert RGBA8 to " + std::string(PixelFormatInfo::GetName(m_sharedImage->format)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -391,7 +391,7 @@ namespace Nz
|
||||||
std::unique_ptr<UInt8[]> colorBuffer(new UInt8[bpp]);
|
std::unique_ptr<UInt8[]> colorBuffer(new UInt8[bpp]);
|
||||||
if (!PixelFormatInfo::Convert(PixelFormat::RGBA8, m_sharedImage->format, &color.r, colorBuffer.get()))
|
if (!PixelFormatInfo::Convert(PixelFormat::RGBA8, m_sharedImage->format, &color.r, colorBuffer.get()))
|
||||||
{
|
{
|
||||||
NazaraError("Failed to convert RGBA8 to " + PixelFormatInfo::GetName(m_sharedImage->format));
|
NazaraError("Failed to convert RGBA8 to " + std::string(PixelFormatInfo::GetName(m_sharedImage->format)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -463,7 +463,7 @@ namespace Nz
|
||||||
std::unique_ptr<UInt8[]> colorBuffer(new UInt8[bpp]);
|
std::unique_ptr<UInt8[]> colorBuffer(new UInt8[bpp]);
|
||||||
if (!PixelFormatInfo::Convert(PixelFormat::RGBA8, m_sharedImage->format, &color.r, colorBuffer.get()))
|
if (!PixelFormatInfo::Convert(PixelFormat::RGBA8, m_sharedImage->format, &color.r, colorBuffer.get()))
|
||||||
{
|
{
|
||||||
NazaraError("Failed to convert RGBA8 to " + PixelFormatInfo::GetName(m_sharedImage->format));
|
NazaraError("Failed to convert RGBA8 to " + std::string(PixelFormatInfo::GetName(m_sharedImage->format)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
PixelFormatContent formatContent = PixelFormatInfo::GetContent(format);
|
PixelFormatContent formatContent = PixelFormatInfo::GetContent(format);
|
||||||
if (formatContent != PixelFormatContent::DepthStencil && formatContent != PixelFormatContent::Stencil)
|
if (formatContent != PixelFormatContent::DepthStencil && formatContent != PixelFormatContent::Stencil)
|
||||||
NazaraWarning("Invalid format " + PixelFormatInfo::GetName(format) + " for depth-stencil attachment");
|
NazaraWarning("Invalid format " + std::string(PixelFormatInfo::GetName(format)) + " for depth-stencil attachment");
|
||||||
|
|
||||||
m_depthStencilFormat = ToVulkan(format);
|
m_depthStencilFormat = ToVulkan(format);
|
||||||
if (m_depthStencilFormat == VK_FORMAT_UNDEFINED)
|
if (m_depthStencilFormat == VK_FORMAT_UNDEFINED)
|
||||||
|
|
|
||||||
|
|
@ -553,7 +553,7 @@ namespace Nz
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error("Unsupported pixel format " + PixelFormatInfo::GetName(pixelFormat));
|
throw std::runtime_error("Unsupported pixel format " + std::string(PixelFormatInfo::GetName(pixelFormat)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue