Renderer: Handle more depthstencil formats (as Depth24Stencil8 may not be supported everywhere)
This commit is contained in:
@@ -133,5 +133,79 @@ namespace Nz
|
||||
{
|
||||
return std::make_shared<OpenGLTextureSampler>(*this, params);
|
||||
}
|
||||
|
||||
|
||||
bool OpenGLDevice::IsTextureFormatSupported(PixelFormat format, TextureUsage usage) const
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
case PixelFormat::Undefined:
|
||||
return false;
|
||||
|
||||
case PixelFormat::A8:
|
||||
case PixelFormat::BGR8:
|
||||
case PixelFormat::BGR8_SRGB:
|
||||
case PixelFormat::BGRA8:
|
||||
case PixelFormat::BGRA8_SRGB:
|
||||
case PixelFormat::L8:
|
||||
case PixelFormat::LA8:
|
||||
case PixelFormat::R8:
|
||||
case PixelFormat::R8I:
|
||||
case PixelFormat::R8UI:
|
||||
case PixelFormat::R16:
|
||||
case PixelFormat::R16F:
|
||||
case PixelFormat::R16I:
|
||||
case PixelFormat::R16UI:
|
||||
case PixelFormat::R32F:
|
||||
case PixelFormat::R32I:
|
||||
case PixelFormat::R32UI:
|
||||
case PixelFormat::RG8:
|
||||
case PixelFormat::RG8I:
|
||||
case PixelFormat::RG8UI:
|
||||
case PixelFormat::RG16:
|
||||
case PixelFormat::RG16F:
|
||||
case PixelFormat::RG16I:
|
||||
case PixelFormat::RG16UI:
|
||||
case PixelFormat::RG32F:
|
||||
case PixelFormat::RG32I:
|
||||
case PixelFormat::RG32UI:
|
||||
case PixelFormat::RGB5A1:
|
||||
case PixelFormat::RGB8:
|
||||
case PixelFormat::RGB8_SRGB:
|
||||
case PixelFormat::RGB16F:
|
||||
case PixelFormat::RGB16I:
|
||||
case PixelFormat::RGB16UI:
|
||||
case PixelFormat::RGB32F:
|
||||
case PixelFormat::RGB32I:
|
||||
case PixelFormat::RGB32UI:
|
||||
case PixelFormat::RGBA4:
|
||||
case PixelFormat::RGBA8:
|
||||
case PixelFormat::RGBA8_SRGB:
|
||||
case PixelFormat::RGBA16F:
|
||||
case PixelFormat::RGBA16I:
|
||||
case PixelFormat::RGBA16UI:
|
||||
case PixelFormat::RGBA32F:
|
||||
case PixelFormat::RGBA32I:
|
||||
case PixelFormat::RGBA32UI:
|
||||
return usage == TextureUsage::ColorAttachment || usage == TextureUsage::InputAttachment || usage == TextureUsage::ShaderSampling || usage == TextureUsage::TransferDestination || usage == TextureUsage::TransferSource;
|
||||
|
||||
case PixelFormat::DXT1:
|
||||
case PixelFormat::DXT3:
|
||||
case PixelFormat::DXT5:
|
||||
return usage == TextureUsage::InputAttachment || usage == TextureUsage::ShaderSampling || usage == TextureUsage::TransferDestination || usage == TextureUsage::TransferSource;
|
||||
|
||||
case PixelFormat::Depth16:
|
||||
case PixelFormat::Depth16Stencil8:
|
||||
case PixelFormat::Depth24:
|
||||
case PixelFormat::Depth24Stencil8:
|
||||
case PixelFormat::Depth32F:
|
||||
case PixelFormat::Depth32FStencil8:
|
||||
case PixelFormat::Stencil1:
|
||||
case PixelFormat::Stencil4:
|
||||
case PixelFormat::Stencil8:
|
||||
case PixelFormat::Stencil16:
|
||||
return usage == TextureUsage::DepthStencilAttachment || usage == TextureUsage::ShaderSampling || usage == TextureUsage::TransferDestination || usage == TextureUsage::TransferSource;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Nz
|
||||
if (contextParams.stencilBits > 0)
|
||||
depthFormat = PixelFormat::Depth24Stencil8;
|
||||
else if (contextParams.depthBits > 24)
|
||||
depthFormat = PixelFormat::Depth32;
|
||||
depthFormat = PixelFormat::Depth32F;
|
||||
else if (contextParams.depthBits > 16)
|
||||
depthFormat = PixelFormat::Depth24;
|
||||
else if (contextParams.depthBits > 0)
|
||||
|
||||
@@ -1424,66 +1424,71 @@ namespace Nz
|
||||
s_pixelFormatInfos[UnderlyingCast(format)] = std::move(desc);
|
||||
};
|
||||
|
||||
Bitset<> b8(0xFF);
|
||||
b8.Resize(128);
|
||||
|
||||
Bitset<> b32(0xFFFFFFFF);
|
||||
b32.Resize(128);
|
||||
|
||||
// Setup informations about every pixel format
|
||||
SetupPixelFormat(PixelFormat::A8, PixelFormatDescription("A8", PixelFormatContent::ColorRGBA, 0, 0, 0, 0xFF, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::BGR8, PixelFormatDescription("BGR8", PixelFormatContent::ColorRGBA, 0x0000FF, 0x00FF00, 0xFF0000, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::BGR8_SRGB, PixelFormatDescription("BGR8_SRGB", PixelFormatContent::ColorRGBA, 0x0000FF, 0x00FF00, 0xFF0000, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::BGRA8, PixelFormatDescription("BGRA8", PixelFormatContent::ColorRGBA, 0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::BGRA8_SRGB, PixelFormatDescription("BGRA8_SRGB", PixelFormatContent::ColorRGBA, 0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::DXT1, PixelFormatDescription("DXT1", PixelFormatContent::ColorRGBA, 8, PixelFormatSubType::Compressed));
|
||||
SetupPixelFormat(PixelFormat::DXT3, PixelFormatDescription("DXT3", PixelFormatContent::ColorRGBA, 16, PixelFormatSubType::Compressed));
|
||||
SetupPixelFormat(PixelFormat::DXT5, PixelFormatDescription("DXT5", PixelFormatContent::ColorRGBA, 16, PixelFormatSubType::Compressed));
|
||||
SetupPixelFormat(PixelFormat::L8, PixelFormatDescription("L8", PixelFormatContent::ColorRGBA, 0xFF, 0xFF, 0xFF, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::LA8, PixelFormatDescription("LA8", PixelFormatContent::ColorRGBA, 0xFF00, 0xFF00, 0xFF00, 0x00FF, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::R8, PixelFormatDescription("R8", PixelFormatContent::ColorRGBA, 0xFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::R8I, PixelFormatDescription("R8I", PixelFormatContent::ColorRGBA, 0xFF, 0, 0, 0, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::R8UI, PixelFormatDescription("R8UI", PixelFormatContent::ColorRGBA, 0xFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::R16, PixelFormatDescription("R16", PixelFormatContent::ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::R16F, PixelFormatDescription("R16F", PixelFormatContent::ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType::Half));
|
||||
SetupPixelFormat(PixelFormat::R16I, PixelFormatDescription("R16I", PixelFormatContent::ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::R16UI, PixelFormatDescription("R16UI", PixelFormatContent::ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::R32F, PixelFormatDescription("R32F", PixelFormatContent::ColorRGBA, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType::Float));
|
||||
SetupPixelFormat(PixelFormat::R32I, PixelFormatDescription("R32I", PixelFormatContent::ColorRGBA, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::R32UI, PixelFormatDescription("R32UI", PixelFormatContent::ColorRGBA, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RG8, PixelFormatDescription("RG8", PixelFormatContent::ColorRGBA, 0xFF00, 0x00FF, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RG8I, PixelFormatDescription("RG8I", PixelFormatContent::ColorRGBA, 0xFF00, 0x00FF, 0, 0, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::RG8UI, PixelFormatDescription("RG8UI", PixelFormatContent::ColorRGBA, 0xFF00, 0x00FF, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RG16, PixelFormatDescription("RG16", PixelFormatContent::ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RG16F, PixelFormatDescription("RG16F", PixelFormatContent::ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType::Half));
|
||||
SetupPixelFormat(PixelFormat::RG16I, PixelFormatDescription("RG16I", PixelFormatContent::ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::RG16UI, PixelFormatDescription("RG16UI", PixelFormatContent::ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RG32F, PixelFormatDescription("RG32F", PixelFormatContent::ColorRGBA, 0xFFFFFFFF00000000, 0x00000000FFFFFFFF, 0, 0, PixelFormatSubType::Float));
|
||||
SetupPixelFormat(PixelFormat::RG32I, PixelFormatDescription("RG32I", PixelFormatContent::ColorRGBA, 0xFFFFFFFF00000000, 0x00000000FFFFFFFF, 0, 0, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::RG32UI, PixelFormatDescription("RG32UI", PixelFormatContent::ColorRGBA, 0xFFFFFFFF00000000, 0x00000000FFFFFFFF, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGB8, PixelFormatDescription("RGB8", PixelFormatContent::ColorRGBA, 0xFF000000, 0x00FF0000, 0x0000FF00, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGB8_SRGB, PixelFormatDescription("RGB8_SRGB", PixelFormatContent::ColorRGBA, 0xFF000000, 0x00FF0000, 0x0000FF00, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGB16F, PixelFormatDescription("RGB16F", PixelFormatContent::ColorRGBA, 0xFFFF00000000, 0x0000FFFF0000, 0x00000000FFFF, 0, PixelFormatSubType::Half));
|
||||
SetupPixelFormat(PixelFormat::RGB16I, PixelFormatDescription("RGB16I", PixelFormatContent::ColorRGBA, 0xFFFF00000000, 0x0000FFFF0000, 0x00000000FFFF, 0, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::RGB16UI, PixelFormatDescription("RGB16UI", PixelFormatContent::ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGB32F, PixelFormatDescription("RGB32F", PixelFormatContent::ColorRGBA, b32, b32 >> 32, b32 >> 64, 0, PixelFormatSubType::Float));
|
||||
SetupPixelFormat(PixelFormat::RGB32I, PixelFormatDescription("RGB32I", PixelFormatContent::ColorRGBA, b32, b32 >> 32, b32 >> 64, 0, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::RGB32UI, PixelFormatDescription("RGB32UI", PixelFormatContent::ColorRGBA, b32, b32 >> 32, b32 >> 64, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGBA4, PixelFormatDescription("RGBA4", PixelFormatContent::ColorRGBA, 0xF000, 0x0F00, 0x00F0, 0x000F, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGB5A1, PixelFormatDescription("RGB5A1", PixelFormatContent::ColorRGBA, 0xF800, 0x07C0, 0x003E, 0x0001, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGBA8, PixelFormatDescription("RGBA8", PixelFormatContent::ColorRGBA, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGBA8_SRGB, PixelFormatDescription("RGBA8_SRGB", PixelFormatContent::ColorRGBA, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGBA16F, PixelFormatDescription("RGBA16F", PixelFormatContent::ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType::Half));
|
||||
SetupPixelFormat(PixelFormat::RGBA16I, PixelFormatDescription("RGBA16I", PixelFormatContent::ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::RGBA16UI, PixelFormatDescription("RGBA16UI", PixelFormatContent::ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGBA32F, PixelFormatDescription("RGBA32F", PixelFormatContent::ColorRGBA, b32, b32 >> 32, b32 >> 64, b32 >> 96, PixelFormatSubType::Float));
|
||||
SetupPixelFormat(PixelFormat::RGBA32I, PixelFormatDescription("RGBA32I", PixelFormatContent::ColorRGBA, b32, b32 >> 32, b32 >> 64, b32 >> 96, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::RGBA32UI, PixelFormatDescription("RGBA32UI", PixelFormatContent::ColorRGBA, b32, b32 >> 32, b32 >> 64, b32 >> 96, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Depth16, PixelFormatDescription("Depth16", PixelFormatContent::Depth, 0xFFFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Depth24, PixelFormatDescription("Depth24", PixelFormatContent::Depth, 0xFFFFFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Depth24Stencil8, PixelFormatDescription("Depth24Stencil8", PixelFormatContent::DepthStencil, 0xFFFFFF00, 0x000000FF, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Depth32, PixelFormatDescription("Depth32", PixelFormatContent::Depth, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Stencil1, PixelFormatDescription("Stencil1", PixelFormatContent::Stencil, 0x1, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Stencil4, PixelFormatDescription("Stencil4", PixelFormatContent::Stencil, 0xF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Stencil8, PixelFormatDescription("Stencil8", PixelFormatContent::Stencil, 0xFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Stencil16, PixelFormatDescription("Stencil16", PixelFormatContent::Stencil, 0xFFFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::A8, PixelFormatDescription("A8", PixelFormatContent::ColorRGBA, 0, 0, 0, 0xFF, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::BGR8, PixelFormatDescription("BGR8", PixelFormatContent::ColorRGBA, 0x0000FF, 0x00FF00, 0xFF0000, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::BGR8_SRGB, PixelFormatDescription("BGR8_SRGB", PixelFormatContent::ColorRGBA, 0x0000FF, 0x00FF00, 0xFF0000, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::BGRA8, PixelFormatDescription("BGRA8", PixelFormatContent::ColorRGBA, 0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::BGRA8_SRGB, PixelFormatDescription("BGRA8_SRGB", PixelFormatContent::ColorRGBA, 0x0000FF00, 0x00FF0000, 0xFF000000, 0x000000FF, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::DXT1, PixelFormatDescription("DXT1", PixelFormatContent::ColorRGBA, 8, PixelFormatSubType::Compressed));
|
||||
SetupPixelFormat(PixelFormat::DXT3, PixelFormatDescription("DXT3", PixelFormatContent::ColorRGBA, 16, PixelFormatSubType::Compressed));
|
||||
SetupPixelFormat(PixelFormat::DXT5, PixelFormatDescription("DXT5", PixelFormatContent::ColorRGBA, 16, PixelFormatSubType::Compressed));
|
||||
SetupPixelFormat(PixelFormat::L8, PixelFormatDescription("L8", PixelFormatContent::ColorRGBA, 0xFF, 0xFF, 0xFF, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::LA8, PixelFormatDescription("LA8", PixelFormatContent::ColorRGBA, 0xFF00, 0xFF00, 0xFF00, 0x00FF, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::R8, PixelFormatDescription("R8", PixelFormatContent::ColorRGBA, 0xFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::R8I, PixelFormatDescription("R8I", PixelFormatContent::ColorRGBA, 0xFF, 0, 0, 0, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::R8UI, PixelFormatDescription("R8UI", PixelFormatContent::ColorRGBA, 0xFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::R16, PixelFormatDescription("R16", PixelFormatContent::ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::R16F, PixelFormatDescription("R16F", PixelFormatContent::ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType::Half));
|
||||
SetupPixelFormat(PixelFormat::R16I, PixelFormatDescription("R16I", PixelFormatContent::ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::R16UI, PixelFormatDescription("R16UI", PixelFormatContent::ColorRGBA, 0xFFFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::R32F, PixelFormatDescription("R32F", PixelFormatContent::ColorRGBA, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType::Float));
|
||||
SetupPixelFormat(PixelFormat::R32I, PixelFormatDescription("R32I", PixelFormatContent::ColorRGBA, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::R32UI, PixelFormatDescription("R32UI", PixelFormatContent::ColorRGBA, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RG8, PixelFormatDescription("RG8", PixelFormatContent::ColorRGBA, 0xFF00, 0x00FF, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RG8I, PixelFormatDescription("RG8I", PixelFormatContent::ColorRGBA, 0xFF00, 0x00FF, 0, 0, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::RG8UI, PixelFormatDescription("RG8UI", PixelFormatContent::ColorRGBA, 0xFF00, 0x00FF, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RG16, PixelFormatDescription("RG16", PixelFormatContent::ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RG16F, PixelFormatDescription("RG16F", PixelFormatContent::ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType::Half));
|
||||
SetupPixelFormat(PixelFormat::RG16I, PixelFormatDescription("RG16I", PixelFormatContent::ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::RG16UI, PixelFormatDescription("RG16UI", PixelFormatContent::ColorRGBA, 0xFFFF0000, 0x0000FFFF, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RG32F, PixelFormatDescription("RG32F", PixelFormatContent::ColorRGBA, 0xFFFFFFFF00000000, 0x00000000FFFFFFFF, 0, 0, PixelFormatSubType::Float));
|
||||
SetupPixelFormat(PixelFormat::RG32I, PixelFormatDescription("RG32I", PixelFormatContent::ColorRGBA, 0xFFFFFFFF00000000, 0x00000000FFFFFFFF, 0, 0, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::RG32UI, PixelFormatDescription("RG32UI", PixelFormatContent::ColorRGBA, 0xFFFFFFFF00000000, 0x00000000FFFFFFFF, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGB8, PixelFormatDescription("RGB8", PixelFormatContent::ColorRGBA, 0xFF000000, 0x00FF0000, 0x0000FF00, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGB8_SRGB, PixelFormatDescription("RGB8_SRGB", PixelFormatContent::ColorRGBA, 0xFF000000, 0x00FF0000, 0x0000FF00, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGB16F, PixelFormatDescription("RGB16F", PixelFormatContent::ColorRGBA, 0xFFFF00000000, 0x0000FFFF0000, 0x00000000FFFF, 0, PixelFormatSubType::Half));
|
||||
SetupPixelFormat(PixelFormat::RGB16I, PixelFormatDescription("RGB16I", PixelFormatContent::ColorRGBA, 0xFFFF00000000, 0x0000FFFF0000, 0x00000000FFFF, 0, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::RGB16UI, PixelFormatDescription("RGB16UI", PixelFormatContent::ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGB32F, PixelFormatDescription("RGB32F", PixelFormatContent::ColorRGBA, b32, b32 >> 32, b32 >> 64, 0, PixelFormatSubType::Float));
|
||||
SetupPixelFormat(PixelFormat::RGB32I, PixelFormatDescription("RGB32I", PixelFormatContent::ColorRGBA, b32, b32 >> 32, b32 >> 64, 0, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::RGB32UI, PixelFormatDescription("RGB32UI", PixelFormatContent::ColorRGBA, b32, b32 >> 32, b32 >> 64, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGBA4, PixelFormatDescription("RGBA4", PixelFormatContent::ColorRGBA, 0xF000, 0x0F00, 0x00F0, 0x000F, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGB5A1, PixelFormatDescription("RGB5A1", PixelFormatContent::ColorRGBA, 0xF800, 0x07C0, 0x003E, 0x0001, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGBA8, PixelFormatDescription("RGBA8", PixelFormatContent::ColorRGBA, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGBA8_SRGB, PixelFormatDescription("RGBA8_SRGB", PixelFormatContent::ColorRGBA, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGBA16F, PixelFormatDescription("RGBA16F", PixelFormatContent::ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType::Half));
|
||||
SetupPixelFormat(PixelFormat::RGBA16I, PixelFormatDescription("RGBA16I", PixelFormatContent::ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::RGBA16UI, PixelFormatDescription("RGBA16UI", PixelFormatContent::ColorRGBA, 0xFFFF000000000000, 0x0000FFFF00000000, 0x00000000FFFF0000, 0x000000000000FFFF, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::RGBA32F, PixelFormatDescription("RGBA32F", PixelFormatContent::ColorRGBA, b32, b32 >> 32, b32 >> 64, b32 >> 96, PixelFormatSubType::Float));
|
||||
SetupPixelFormat(PixelFormat::RGBA32I, PixelFormatDescription("RGBA32I", PixelFormatContent::ColorRGBA, b32, b32 >> 32, b32 >> 64, b32 >> 96, PixelFormatSubType::Int));
|
||||
SetupPixelFormat(PixelFormat::RGBA32UI, PixelFormatDescription("RGBA32UI", PixelFormatContent::ColorRGBA, b32, b32 >> 32, b32 >> 64, b32 >> 96, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Depth16, PixelFormatDescription("Depth16", PixelFormatContent::Depth, 0xFFFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Depth16Stencil8, PixelFormatDescription("Depth16Stencil8", PixelFormatContent::DepthStencil, 0xFFFF0000, 0x0000FF00, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Depth24, PixelFormatDescription("Depth24", PixelFormatContent::Depth, 0xFFFFFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Depth24Stencil8, PixelFormatDescription("Depth24Stencil8", PixelFormatContent::DepthStencil, 0xFFFFFF00, 0x000000FF, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Depth32F, PixelFormatDescription("Depth32F", PixelFormatContent::Depth, 0xFFFFFFFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Depth32FStencil8, PixelFormatDescription("Depth32FStencil8", PixelFormatContent::DepthStencil, b32, b8 >> 32, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Stencil1, PixelFormatDescription("Stencil1", PixelFormatContent::Stencil, 0x1, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Stencil4, PixelFormatDescription("Stencil4", PixelFormatContent::Stencil, 0xF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Stencil8, PixelFormatDescription("Stencil8", PixelFormatContent::Stencil, 0xFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
SetupPixelFormat(PixelFormat::Stencil16, PixelFormatDescription("Stencil16", PixelFormatContent::Stencil, 0xFFFF, 0, 0, 0, PixelFormatSubType::Unsigned));
|
||||
|
||||
for (unsigned int i = 0; i < PixelFormatCount; ++i)
|
||||
{
|
||||
|
||||
@@ -163,15 +163,23 @@ namespace Nz
|
||||
m_depthStencilFormat = VK_FORMAT_D16_UNORM;
|
||||
break;
|
||||
|
||||
case PixelFormat::Depth16Stencil8:
|
||||
m_depthStencilFormat = VK_FORMAT_D16_UNORM_S8_UINT;
|
||||
break;
|
||||
|
||||
case PixelFormat::Depth24:
|
||||
case PixelFormat::Depth24Stencil8:
|
||||
m_depthStencilFormat = VK_FORMAT_D24_UNORM_S8_UINT;
|
||||
break;
|
||||
|
||||
case PixelFormat::Depth32:
|
||||
case PixelFormat::Depth32F:
|
||||
m_depthStencilFormat = VK_FORMAT_D32_SFLOAT;
|
||||
break;
|
||||
|
||||
case PixelFormat::Depth32FStencil8:
|
||||
m_depthStencilFormat = VK_FORMAT_D32_SFLOAT_S8_UINT;
|
||||
break;
|
||||
|
||||
case PixelFormat::Stencil1:
|
||||
case PixelFormat::Stencil4:
|
||||
case PixelFormat::Stencil8:
|
||||
@@ -336,6 +344,14 @@ namespace Nz
|
||||
return false;
|
||||
}
|
||||
|
||||
PixelFormat format = FromVulkan(m_depthStencilFormat).value();
|
||||
|
||||
VkImageAspectFlags aspectMask;
|
||||
if (PixelFormatInfo::GetContent(format) == PixelFormatContent::DepthStencil)
|
||||
aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
else
|
||||
aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
|
||||
VkImageViewCreateInfo imageViewCreateInfo = {
|
||||
VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, // VkStructureType sType;
|
||||
nullptr, // const void* pNext;
|
||||
@@ -350,7 +366,7 @@ namespace Nz
|
||||
VK_COMPONENT_SWIZZLE_A // VkComponentSwizzle .a;
|
||||
},
|
||||
{ // VkImageSubresourceRange subresourceRange;
|
||||
VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT, // VkImageAspectFlags .aspectMask;
|
||||
aspectMask, // VkImageAspectFlags .aspectMask;
|
||||
0, // uint32_t .baseMipLevel;
|
||||
1, // uint32_t .levelCount;
|
||||
0, // uint32_t .baseArrayLayer;
|
||||
|
||||
@@ -83,4 +83,35 @@ namespace Nz
|
||||
{
|
||||
return std::make_shared<VulkanTextureSampler>(*this, params);
|
||||
}
|
||||
|
||||
bool VulkanDevice::IsTextureFormatSupported(PixelFormat format, TextureUsage usage) const
|
||||
{
|
||||
VkFormatFeatureFlags flags = 0;
|
||||
switch (usage)
|
||||
{
|
||||
case TextureUsage::ColorAttachment:
|
||||
flags = VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
|
||||
break;
|
||||
|
||||
case TextureUsage::DepthStencilAttachment:
|
||||
flags = VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
|
||||
break;
|
||||
|
||||
case TextureUsage::InputAttachment:
|
||||
case TextureUsage::ShaderSampling:
|
||||
flags = VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT;
|
||||
break;
|
||||
|
||||
case TextureUsage::TransferSource:
|
||||
flags = VK_FORMAT_FEATURE_TRANSFER_SRC_BIT;
|
||||
break;
|
||||
|
||||
case TextureUsage::TransferDestination:
|
||||
flags = VK_FORMAT_FEATURE_TRANSFER_DST_BIT;
|
||||
break;
|
||||
}
|
||||
|
||||
VkFormatProperties formatProperties = GetInstance().GetPhysicalDeviceFormatProperties(GetPhysicalDevice(), ToVulkan(format));
|
||||
return formatProperties.optimalTilingFeatures & flags; //< Assume optimal tiling
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +263,22 @@ namespace Nz
|
||||
break;
|
||||
}
|
||||
|
||||
case PixelFormat::Depth16:
|
||||
{
|
||||
createImage.format = VK_FORMAT_D16_UNORM;
|
||||
createImageView.format = createImage.format;
|
||||
createImageView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
break;
|
||||
}
|
||||
|
||||
case PixelFormat::Depth16Stencil8:
|
||||
{
|
||||
createImage.format = VK_FORMAT_D16_UNORM_S8_UINT;
|
||||
createImageView.format = createImage.format;
|
||||
createImageView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
break;
|
||||
}
|
||||
|
||||
case PixelFormat::Depth24Stencil8:
|
||||
{
|
||||
createImage.format = VK_FORMAT_D24_UNORM_S8_UINT;
|
||||
@@ -271,6 +287,22 @@ namespace Nz
|
||||
break;
|
||||
}
|
||||
|
||||
case PixelFormat::Depth32F:
|
||||
{
|
||||
createImage.format = VK_FORMAT_D32_SFLOAT;
|
||||
createImageView.format = createImage.format;
|
||||
createImageView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
break;
|
||||
}
|
||||
|
||||
case PixelFormat::Depth32FStencil8:
|
||||
{
|
||||
createImage.format = VK_FORMAT_D32_SFLOAT_S8_UINT;
|
||||
createImageView.format = createImage.format;
|
||||
createImageView.subresourceRange.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||
break;
|
||||
}
|
||||
|
||||
case PixelFormat::L8:
|
||||
{
|
||||
createImage.format = VK_FORMAT_R8_UNORM;
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Instance::EnumeratePhysicalDevices(std::vector<VkPhysicalDevice>* devices)
|
||||
bool Instance::EnumeratePhysicalDevices(std::vector<VkPhysicalDevice>* devices) const
|
||||
{
|
||||
NazaraAssert(devices, "Invalid device vector");
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Instance::GetPhysicalDeviceExtensions(VkPhysicalDevice device, std::vector<VkExtensionProperties>* extensionProperties)
|
||||
bool Instance::GetPhysicalDeviceExtensions(VkPhysicalDevice device, std::vector<VkExtensionProperties>* extensionProperties) const
|
||||
{
|
||||
NazaraAssert(extensionProperties, "Invalid extension properties vector");
|
||||
|
||||
@@ -188,7 +188,7 @@ namespace Nz
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Instance::GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector<VkQueueFamilyProperties>* queueFamilyProperties)
|
||||
bool Instance::GetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice device, std::vector<VkQueueFamilyProperties>* queueFamilyProperties) const
|
||||
{
|
||||
NazaraAssert(queueFamilyProperties, "Invalid family properties vector");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user