mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-03 05:11:06 +00:00
Encode information for ASTC/PVRTC blocks in ResourceFormat
This commit is contained in:
@@ -365,6 +365,7 @@ EXTEND_ARRAY_CLASS_METHODS(StructuredBufferList)
|
||||
// or in qrenderdoc.i, depending on which one is appropriate
|
||||
TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, float, 2)
|
||||
TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, float, 4)
|
||||
TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, uint32_t, 2)
|
||||
TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, uint32_t, 3)
|
||||
TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, uint32_t, 4)
|
||||
TEMPLATE_FIXEDARRAY_INSTANTIATE(rdcfixedarray, uint64_t, 4)
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include "apidefs.h"
|
||||
#include "rdcarray.h"
|
||||
#include "rdcpair.h"
|
||||
#include "replay_enums.h"
|
||||
#include "resourceid.h"
|
||||
#include "stringise.h"
|
||||
@@ -400,6 +401,161 @@ Invalid values will result in 1 being set.
|
||||
return false;
|
||||
}
|
||||
|
||||
DOCUMENT(R"(Set PVRTC properties. See :meth:`PVRTCVersion` and :meth:`PVRTCBpp`.
|
||||
|
||||
Invalid values will result in undefined format properties. Has no effect if the format is
|
||||
not already set to be PVRTC.
|
||||
|
||||
:param int version: The PVRTC version.
|
||||
:param int bpp: The bits per pixel of the PVRTC blocks.
|
||||
)");
|
||||
void SetPVRTC(uint32_t version, uint32_t bpp)
|
||||
{
|
||||
if(type != ResourceFormatType::PVRTC)
|
||||
return;
|
||||
|
||||
flags &= ~ResourceFormat_PVRTC_Mask;
|
||||
flags |= (version == 1) ? ResourceFormat_PVRTC_v1 : ResourceFormat_PVRTC_v2;
|
||||
flags |= (bpp == 2) ? ResourceFormat_PVRTC_8x4_2bpp : ResourceFormat_PVRTC_4x4_4bpp;
|
||||
}
|
||||
|
||||
DOCUMENT(R"(For PVRTC formats, return the version of PVRTC used either 1 or 2.
|
||||
|
||||
Will return 0 if the format is not PVRTC.
|
||||
|
||||
:return: The version of the current PVRTC format
|
||||
:rtype: int
|
||||
)");
|
||||
uint32_t PVRTCVersion() const
|
||||
{
|
||||
if(type != ResourceFormatType::PVRTC)
|
||||
return 0;
|
||||
|
||||
return (flags & ResourceFormat_PVRTC_v1) ? 1 : 2;
|
||||
}
|
||||
|
||||
DOCUMENT(R"(For PVRTC formats, return the bits per pixel rate either 2 or 4. This can also be
|
||||
thought of as the block shape since each block is 64-bit. 2bpp is 8x4 and 4bpp is 4x4.
|
||||
|
||||
Will return 0 if the format is not PVRTC.
|
||||
|
||||
:return: The bpp of the current PVRTC format
|
||||
:rtype: int
|
||||
)");
|
||||
uint32_t PVRTCBpp() const
|
||||
{
|
||||
if(type != ResourceFormatType::PVRTC)
|
||||
return 0;
|
||||
|
||||
return (flags & ResourceFormat_PVRTC_8x4_2bpp) ? 2 : 4;
|
||||
}
|
||||
|
||||
DOCUMENT(R"(Set 2D ASTC block properties. See :meth:`ASTCDimension` and :meth:`ASTC2DBlock`.
|
||||
|
||||
Invalid values will result in undefined format properties. Has no effect if the format is
|
||||
not already set to be ASTC.
|
||||
|
||||
:param Tuple[int, int] block2D: The 2D block shape.
|
||||
)");
|
||||
void SetASTC2D(const rdcpair<uint32_t, uint32_t> &block2D)
|
||||
{
|
||||
if(type != ResourceFormatType::ASTC)
|
||||
return;
|
||||
|
||||
flags &= ~ResourceFormat_ASTC_Mask;
|
||||
|
||||
flags |= uint16_t(block2D.first << ResourceFormat_ASTC_2DWidth_Shift);
|
||||
flags |= uint16_t(block2D.second << ResourceFormat_ASTC_2DHeight_Shift);
|
||||
}
|
||||
|
||||
DOCUMENT(R"(Set 3D ASTC block properties. See :meth:`ASTCDimension` and :meth:`ASTC3DBlock`.
|
||||
|
||||
Invalid values will result in undefined format properties. Has no effect if the format is
|
||||
not already set to be ASTC.
|
||||
|
||||
:param Tuple[int, int, int] block3D: The 3D block shape.
|
||||
)");
|
||||
void SetASTC3D(const rdcfixedarray<uint32_t, 3> &block3D)
|
||||
{
|
||||
if(type != ResourceFormatType::ASTC)
|
||||
return;
|
||||
|
||||
flags &= ~ResourceFormat_ASTC_Mask;
|
||||
flags |= ResourceFormat_ASTC_3D;
|
||||
|
||||
uint32_t w = block3D[0] - ResourceFormat_ASTC_3D_Base;
|
||||
uint32_t h = block3D[1] - ResourceFormat_ASTC_3D_Base;
|
||||
uint32_t d = block3D[2] - ResourceFormat_ASTC_3D_Base;
|
||||
|
||||
w <<= ResourceFormat_ASTC_3DWidth_Shift;
|
||||
h <<= ResourceFormat_ASTC_3DHeight_Shift;
|
||||
d <<= ResourceFormat_ASTC_3DDepth_Shift;
|
||||
|
||||
w &= ResourceFormat_ASTC_3DWidth_Mask;
|
||||
h &= ResourceFormat_ASTC_3DHeight_Mask;
|
||||
d &= ResourceFormat_ASTC_3DDepth_Mask;
|
||||
|
||||
flags |= uint16_t(w);
|
||||
flags |= uint16_t(h);
|
||||
flags |= uint16_t(d);
|
||||
}
|
||||
|
||||
DOCUMENT(R"(For ASTC formats, return the dimension of the block either 2 or 3.
|
||||
|
||||
Will return 0 if the format is not ASTC.
|
||||
|
||||
:return: The dimension of the blocks in the current ASTC format
|
||||
:rtype: int
|
||||
)");
|
||||
uint32_t ASTCDimension() const
|
||||
{
|
||||
if(type != ResourceFormatType::ASTC)
|
||||
return 0;
|
||||
|
||||
return (flags & ResourceFormat_ASTC_3D) ? 3 : 2;
|
||||
}
|
||||
|
||||
DOCUMENT(R"(For 2D ASTC formats, return the block shape.
|
||||
|
||||
Will return all 0s if the format is not ASTC or is not 2D. See :meth:`ASTCDimension`.
|
||||
|
||||
:return: The block shape if the format is 2D ASTC
|
||||
:rtype: Tuple[int, int]
|
||||
)");
|
||||
rdcpair<uint32_t, uint32_t> ASTC2DBlock() const
|
||||
{
|
||||
if(type != ResourceFormatType::ASTC)
|
||||
return {0, 0};
|
||||
|
||||
return {
|
||||
uint32_t((flags & ResourceFormat_ASTC_2DWidth_Mask) >> ResourceFormat_ASTC_2DWidth_Shift),
|
||||
uint32_t((flags & ResourceFormat_ASTC_2DHeight_Mask) >> ResourceFormat_ASTC_2DHeight_Shift),
|
||||
};
|
||||
}
|
||||
|
||||
DOCUMENT(R"(For 3D ASTC formats, return the block shape.
|
||||
|
||||
Will return all 0s if the format is not ASTC or is not 3D. See :meth:`ASTCDimension`.
|
||||
|
||||
:return: The block shape if the format is 3D ASTC
|
||||
:rtype: Tuple[int, int, int]
|
||||
)");
|
||||
rdcfixedarray<uint32_t, 3> ASTC3DBlock() const
|
||||
{
|
||||
if(type != ResourceFormatType::ASTC)
|
||||
return {0, 0};
|
||||
|
||||
uint32_t w = (flags & ResourceFormat_ASTC_3DWidth_Mask) >> ResourceFormat_ASTC_3DWidth_Shift;
|
||||
uint32_t h = (flags & ResourceFormat_ASTC_3DHeight_Mask) >> ResourceFormat_ASTC_3DHeight_Shift;
|
||||
uint32_t d = (flags & ResourceFormat_ASTC_3DDepth_Mask) >> ResourceFormat_ASTC_3DDepth_Shift;
|
||||
|
||||
return {
|
||||
ResourceFormat_ASTC_3D_Base + w,
|
||||
ResourceFormat_ASTC_3D_Base + h,
|
||||
ResourceFormat_ASTC_3D_Base + d,
|
||||
};
|
||||
}
|
||||
|
||||
DOCUMENT(R"(Return the size of a single element in this format, usually a pixel. For regular sized
|
||||
formats this is just :data:`compByteWidth` times :data:`compCount`, for special packed formats it's
|
||||
the tightly packed size of a single element, with no padding.
|
||||
@@ -454,7 +610,7 @@ texel.
|
||||
case ResourceFormatType::YUV12:
|
||||
case ResourceFormatType::YUV16: return compCount * 2;
|
||||
case ResourceFormatType::PVRTC:
|
||||
return 8; // our representation can't differentiate 2bpp from 4bpp, so guess
|
||||
return 8; // PVRTC is always 64 bits per block, either 4x4 on 4bpp or 8x4 on 2bpp
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -487,6 +643,7 @@ private:
|
||||
enum
|
||||
{
|
||||
ResourceFormat_BGRA = 0x001,
|
||||
ResourceFormat_ASTC_3D = 0x0002,
|
||||
|
||||
ResourceFormat_444 = 0x004,
|
||||
ResourceFormat_422 = 0x008,
|
||||
@@ -496,6 +653,27 @@ private:
|
||||
ResourceFormat_2Planes = 0x020,
|
||||
ResourceFormat_3Planes = 0x040,
|
||||
ResourceFormat_Planes_Mask = 0x060,
|
||||
|
||||
ResourceFormat_PVRTC_v1 = 0x0100,
|
||||
ResourceFormat_PVRTC_v2 = 0x0200,
|
||||
ResourceFormat_PVRTC_4x4_4bpp = 0x0400,
|
||||
ResourceFormat_PVRTC_8x4_2bpp = 0x0800,
|
||||
ResourceFormat_PVRTC_Mask = 0x0f00,
|
||||
|
||||
ResourceFormat_ASTC_2DWidth_Shift = 8,
|
||||
ResourceFormat_ASTC_2DWidth_Mask = (0xf << ResourceFormat_ASTC_2DWidth_Shift),
|
||||
ResourceFormat_ASTC_2DHeight_Shift = 12,
|
||||
ResourceFormat_ASTC_2DHeight_Mask = (0xf << ResourceFormat_ASTC_2DHeight_Shift),
|
||||
|
||||
ResourceFormat_ASTC_3D_Base = 3,
|
||||
ResourceFormat_ASTC_3DWidth_Shift = 10,
|
||||
ResourceFormat_ASTC_3DWidth_Mask = (0x3 << ResourceFormat_ASTC_3DWidth_Shift),
|
||||
ResourceFormat_ASTC_3DHeight_Shift = 12,
|
||||
ResourceFormat_ASTC_3DHeight_Mask = (0x3 << ResourceFormat_ASTC_3DHeight_Shift),
|
||||
ResourceFormat_ASTC_3DDepth_Shift = 14,
|
||||
ResourceFormat_ASTC_3DDepth_Mask = (0x3 << ResourceFormat_ASTC_3DDepth_Shift),
|
||||
|
||||
ResourceFormat_ASTC_Mask = 0xff00,
|
||||
};
|
||||
uint16_t flags;
|
||||
|
||||
|
||||
@@ -2093,7 +2093,31 @@ ResourceFormat MakeResourceFormat(GLenum target, GLenum fmt)
|
||||
case eGL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_ARB:
|
||||
case eGL_COMPRESSED_SRGB8_ETC2:
|
||||
case eGL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC: ret.compType = CompType::UNormSRGB; break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES:
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES: ret.compType = CompType::UNormSRGB; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -2201,12 +2225,78 @@ ResourceFormat MakeResourceFormat(GLenum target, GLenum fmt)
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES: ret.type = ResourceFormatType::ASTC; break;
|
||||
// PVRTC
|
||||
case eGL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT:
|
||||
ret.type = ResourceFormatType::PVRTC;
|
||||
ret.SetPVRTC(1, 2);
|
||||
break;
|
||||
case eGL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT:
|
||||
ret.type = ResourceFormatType::PVRTC;
|
||||
ret.SetPVRTC(1, 4);
|
||||
break;
|
||||
case eGL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT:
|
||||
case eGL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT: ret.type = ResourceFormatType::PVRTC; break;
|
||||
ret.type = ResourceFormatType::PVRTC;
|
||||
ret.SetPVRTC(1, 2);
|
||||
break;
|
||||
case eGL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT:
|
||||
ret.type = ResourceFormatType::PVRTC;
|
||||
ret.SetPVRTC(1, 4);
|
||||
break;
|
||||
default: RDCERR("Unexpected compressed format %#x", fmt); break;
|
||||
}
|
||||
|
||||
// set ASTC shape
|
||||
switch(fmt)
|
||||
{
|
||||
case eGL_COMPRESSED_RGBA_ASTC_4x4_KHR: ret.SetASTC2D({4, 4}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_5x4_KHR: ret.SetASTC2D({5, 4}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_5x5_KHR: ret.SetASTC2D({5, 5}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_6x5_KHR: ret.SetASTC2D({6, 5}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_6x6_KHR: ret.SetASTC2D({6, 6}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_8x5_KHR: ret.SetASTC2D({8, 5}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_8x6_KHR: ret.SetASTC2D({8, 6}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_8x8_KHR: ret.SetASTC2D({8, 8}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_10x5_KHR: ret.SetASTC2D({10, 5}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_10x6_KHR: ret.SetASTC2D({10, 6}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_10x8_KHR: ret.SetASTC2D({10, 8}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_10x10_KHR: ret.SetASTC2D({10, 10}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_12x10_KHR: ret.SetASTC2D({12, 10}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_12x12_KHR: ret.SetASTC2D({12, 12}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_3x3x3_OES: ret.SetASTC3D({3, 3, 3}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_4x3x3_OES: ret.SetASTC3D({4, 3, 3}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_4x4x3_OES: ret.SetASTC3D({4, 4, 3}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_4x4x4_OES: ret.SetASTC3D({4, 4, 4}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_5x4x4_OES: ret.SetASTC3D({5, 4, 4}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_5x5x4_OES: ret.SetASTC3D({5, 5, 4}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_5x5x5_OES: ret.SetASTC3D({5, 5, 5}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_6x5x5_OES: ret.SetASTC3D({6, 5, 5}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_6x6x5_OES: ret.SetASTC3D({6, 6, 5}); break;
|
||||
case eGL_COMPRESSED_RGBA_ASTC_6x6x6_OES: ret.SetASTC3D({6, 6, 6}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR: ret.SetASTC2D({4, 4}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR: ret.SetASTC2D({5, 4}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR: ret.SetASTC2D({5, 5}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR: ret.SetASTC2D({6, 5}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR: ret.SetASTC2D({6, 6}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR: ret.SetASTC2D({8, 5}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR: ret.SetASTC2D({8, 6}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR: ret.SetASTC2D({8, 8}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR: ret.SetASTC2D({10, 5}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR: ret.SetASTC2D({10, 6}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR: ret.SetASTC2D({10, 8}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR: ret.SetASTC2D({10, 10}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR: ret.SetASTC2D({12, 10}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR: ret.SetASTC2D({12, 12}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES: ret.SetASTC3D({3, 3, 3}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES: ret.SetASTC3D({4, 3, 3}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES: ret.SetASTC3D({4, 4, 3}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES: ret.SetASTC3D({4, 4, 4}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES: ret.SetASTC3D({5, 4, 4}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES: ret.SetASTC3D({5, 5, 4}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES: ret.SetASTC3D({5, 5, 5}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES: ret.SetASTC3D({6, 5, 5}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES: ret.SetASTC3D({6, 6, 5}); break;
|
||||
case eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES: ret.SetASTC3D({6, 6, 6}); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -2484,11 +2574,136 @@ GLenum MakeGLFormat(ResourceFormat fmt)
|
||||
case ResourceFormatType::D32S8: ret = eGL_DEPTH32F_STENCIL8; break;
|
||||
case ResourceFormatType::D16S8: return eGL_NONE;
|
||||
case ResourceFormatType::ASTC:
|
||||
RDCWARN("ASTC can't be decoded unambiguously");
|
||||
if(fmt.ASTCDimension() == 2)
|
||||
{
|
||||
rdcpair<uint32_t, uint32_t> shape = fmt.ASTC2DBlock();
|
||||
if(fmt.compType == CompType::UNorm)
|
||||
{
|
||||
if(shape.first == 4 && shape.second == 4)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_4x4_KHR;
|
||||
if(shape.first == 5 && shape.second == 4)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_5x4_KHR;
|
||||
if(shape.first == 5 && shape.second == 5)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_5x5_KHR;
|
||||
if(shape.first == 6 && shape.second == 5)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_6x5_KHR;
|
||||
if(shape.first == 6 && shape.second == 6)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_6x6_KHR;
|
||||
if(shape.first == 8 && shape.second == 5)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_8x5_KHR;
|
||||
if(shape.first == 8 && shape.second == 6)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_8x6_KHR;
|
||||
if(shape.first == 8 && shape.second == 8)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_8x8_KHR;
|
||||
if(shape.first == 10 && shape.second == 5)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_10x5_KHR;
|
||||
if(shape.first == 10 && shape.second == 6)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_10x6_KHR;
|
||||
if(shape.first == 10 && shape.second == 8)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_10x8_KHR;
|
||||
if(shape.first == 10 && shape.second == 10)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_10x10_KHR;
|
||||
if(shape.first == 12 && shape.second == 10)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_12x10_KHR;
|
||||
if(shape.first == 12 && shape.second == 12)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_12x12_KHR;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(shape.first == 4 && shape.second == 4)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;
|
||||
if(shape.first == 5 && shape.second == 4)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR;
|
||||
if(shape.first == 5 && shape.second == 5)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR;
|
||||
if(shape.first == 6 && shape.second == 5)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR;
|
||||
if(shape.first == 6 && shape.second == 6)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR;
|
||||
if(shape.first == 8 && shape.second == 5)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR;
|
||||
if(shape.first == 8 && shape.second == 6)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR;
|
||||
if(shape.first == 8 && shape.second == 8)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR;
|
||||
if(shape.first == 10 && shape.second == 5)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR;
|
||||
if(shape.first == 10 && shape.second == 6)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR;
|
||||
if(shape.first == 10 && shape.second == 8)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR;
|
||||
if(shape.first == 10 && shape.second == 10)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR;
|
||||
if(shape.first == 12 && shape.second == 10)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR;
|
||||
if(shape.first == 12 && shape.second == 12)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rdcfixedarray<uint32_t, 3> shape = fmt.ASTC3DBlock();
|
||||
if(fmt.compType == CompType::UNorm)
|
||||
{
|
||||
if(shape[0] == 3 && shape[1] == 3 && shape[2] == 3)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_3x3x3_OES;
|
||||
if(shape[0] == 4 && shape[1] == 3 && shape[2] == 3)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_4x3x3_OES;
|
||||
if(shape[0] == 4 && shape[1] == 4 && shape[2] == 3)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_4x4x3_OES;
|
||||
if(shape[0] == 4 && shape[1] == 4 && shape[2] == 4)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_4x4x4_OES;
|
||||
if(shape[0] == 5 && shape[1] == 4 && shape[2] == 4)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_5x4x4_OES;
|
||||
if(shape[0] == 5 && shape[1] == 5 && shape[2] == 4)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_5x5x4_OES;
|
||||
if(shape[0] == 5 && shape[1] == 5 && shape[2] == 5)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_5x5x5_OES;
|
||||
if(shape[0] == 6 && shape[1] == 5 && shape[2] == 5)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_6x5x5_OES;
|
||||
if(shape[0] == 6 && shape[1] == 6 && shape[2] == 5)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_6x6x5_OES;
|
||||
if(shape[0] == 6 && shape[1] == 6 && shape[2] == 6)
|
||||
return eGL_COMPRESSED_RGBA_ASTC_6x6x6_OES;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(shape[0] == 3 && shape[1] == 3 && shape[2] == 3)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_3x3x3_OES;
|
||||
if(shape[0] == 4 && shape[1] == 3 && shape[2] == 3)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x3x3_OES;
|
||||
if(shape[0] == 4 && shape[1] == 4 && shape[2] == 3)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x3_OES;
|
||||
if(shape[0] == 4 && shape[1] == 4 && shape[2] == 4)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4x4_OES;
|
||||
if(shape[0] == 5 && shape[1] == 4 && shape[2] == 4)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4x4_OES;
|
||||
if(shape[0] == 5 && shape[1] == 5 && shape[2] == 4)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x4_OES;
|
||||
if(shape[0] == 5 && shape[1] == 5 && shape[2] == 5)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5x5_OES;
|
||||
if(shape[0] == 6 && shape[1] == 5 && shape[2] == 5)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5x5_OES;
|
||||
if(shape[0] == 6 && shape[1] == 6 && shape[2] == 5)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x5_OES;
|
||||
if(shape[0] == 6 && shape[1] == 6 && shape[2] == 6)
|
||||
return eGL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6x6_OES;
|
||||
}
|
||||
}
|
||||
return eGL_NONE;
|
||||
case ResourceFormatType::PVRTC:
|
||||
RDCWARN("PVRTC can't be decoded unambiguously");
|
||||
return eGL_NONE;
|
||||
if(fmt.PVRTCBpp() == 2)
|
||||
{
|
||||
if(fmt.compCount == 3)
|
||||
return eGL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT;
|
||||
return eGL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fmt.compCount == 3)
|
||||
return eGL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT;
|
||||
return eGL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT;
|
||||
}
|
||||
case ResourceFormatType::S8: ret = eGL_STENCIL_INDEX8; break;
|
||||
case ResourceFormatType::A8: ret = eGL_ALPHA8_EXT; break;
|
||||
case ResourceFormatType::Undefined: return eGL_NONE;
|
||||
@@ -2981,10 +3196,6 @@ TEST_CASE("GL formats", "[format][gl]")
|
||||
|
||||
ResourceFormat fmt = MakeResourceFormat(eGL_TEXTURE_2D, f);
|
||||
|
||||
// we don't support ASTC/PVRTC formats currently
|
||||
if(fmt.type == ResourceFormatType::ASTC || fmt.type == ResourceFormatType::PVRTC)
|
||||
continue;
|
||||
|
||||
GLenum glf = MakeGLFormat(fmt);
|
||||
|
||||
// it's OK to 'lose' the non-float flag on this format
|
||||
|
||||
@@ -1717,54 +1717,34 @@ BlockShape GetBlockShape(VkFormat Format, uint32_t plane)
|
||||
|
||||
case VK_FORMAT_ASTC_3x3x3_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_3x3x3_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_3x3x3_SFLOAT_BLOCK_EXT:
|
||||
RDCERR("3D block formats not properly supported");
|
||||
return {3, 3, 16};
|
||||
case VK_FORMAT_ASTC_3x3x3_SFLOAT_BLOCK_EXT: return {3, 3, 16, 3};
|
||||
case VK_FORMAT_ASTC_4x3x3_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_4x3x3_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_4x3x3_SFLOAT_BLOCK_EXT:
|
||||
RDCERR("3D block formats not properly supported");
|
||||
return {4, 3, 16};
|
||||
case VK_FORMAT_ASTC_4x3x3_SFLOAT_BLOCK_EXT: return {4, 3, 16, 3};
|
||||
case VK_FORMAT_ASTC_4x4x3_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_4x4x3_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_4x4x3_SFLOAT_BLOCK_EXT:
|
||||
RDCERR("3D block formats not properly supported");
|
||||
return {4, 4, 16};
|
||||
case VK_FORMAT_ASTC_4x4x3_SFLOAT_BLOCK_EXT: return {4, 4, 16, 3};
|
||||
case VK_FORMAT_ASTC_4x4x4_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_4x4x4_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_4x4x4_SFLOAT_BLOCK_EXT:
|
||||
RDCERR("3D block formats not properly supported");
|
||||
return {4, 4, 16};
|
||||
case VK_FORMAT_ASTC_4x4x4_SFLOAT_BLOCK_EXT: return {4, 4, 16, 4};
|
||||
case VK_FORMAT_ASTC_5x4x4_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_5x4x4_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_5x4x4_SFLOAT_BLOCK_EXT:
|
||||
RDCERR("3D block formats not properly supported");
|
||||
return {5, 4, 16};
|
||||
case VK_FORMAT_ASTC_5x4x4_SFLOAT_BLOCK_EXT: return {5, 4, 16, 4};
|
||||
case VK_FORMAT_ASTC_5x5x4_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_5x5x4_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_5x5x4_SFLOAT_BLOCK_EXT:
|
||||
RDCERR("3D block formats not properly supported");
|
||||
return {5, 5, 16};
|
||||
case VK_FORMAT_ASTC_5x5x4_SFLOAT_BLOCK_EXT: return {5, 5, 16, 4};
|
||||
case VK_FORMAT_ASTC_5x5x5_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_5x5x5_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_5x5x5_SFLOAT_BLOCK_EXT:
|
||||
RDCERR("3D block formats not properly supported");
|
||||
return {5, 5, 16};
|
||||
case VK_FORMAT_ASTC_5x5x5_SFLOAT_BLOCK_EXT: return {5, 5, 16, 5};
|
||||
case VK_FORMAT_ASTC_6x5x5_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_6x5x5_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_6x5x5_SFLOAT_BLOCK_EXT:
|
||||
RDCERR("3D block formats not properly supported");
|
||||
return {6, 5, 16};
|
||||
case VK_FORMAT_ASTC_6x5x5_SFLOAT_BLOCK_EXT: return {6, 5, 16, 5};
|
||||
case VK_FORMAT_ASTC_6x6x5_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_6x6x5_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_6x6x5_SFLOAT_BLOCK_EXT:
|
||||
RDCERR("3D block formats not properly supported");
|
||||
return {6, 6, 16};
|
||||
case VK_FORMAT_ASTC_6x6x5_SFLOAT_BLOCK_EXT: return {6, 6, 16, 5};
|
||||
case VK_FORMAT_ASTC_6x6x6_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_6x6x6_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_6x6x6_SFLOAT_BLOCK_EXT:
|
||||
RDCERR("3D block formats not properly supported");
|
||||
return {6, 6, 16};
|
||||
case VK_FORMAT_ASTC_6x6x6_SFLOAT_BLOCK_EXT: return {6, 6, 16, 6};
|
||||
|
||||
/*
|
||||
* YUV planar/packed subsampled textures.
|
||||
@@ -1974,8 +1954,10 @@ uint64_t GetPlaneByteSize(uint32_t Width, uint32_t Height, uint32_t Depth, VkFor
|
||||
|
||||
uint64_t widthInBlocks = (planeShape.width + blockShape.width - 1) / blockShape.width;
|
||||
uint64_t heightInBlocks = (planeShape.height + blockShape.height - 1) / blockShape.height;
|
||||
uint64_t depthInBlocks =
|
||||
blockShape.depth > 0 ? (mipDepth + blockShape.depth - 1) / blockShape.depth : mipDepth;
|
||||
|
||||
return uint64_t(blockShape.bytes) * widthInBlocks * heightInBlocks * uint64_t(mipDepth);
|
||||
return uint64_t(blockShape.bytes) * widthInBlocks * heightInBlocks * depthInBlocks;
|
||||
}
|
||||
|
||||
uint64_t GetByteSize(uint32_t Width, uint32_t Height, uint32_t Depth, VkFormat Format, uint32_t mip)
|
||||
@@ -3128,6 +3110,125 @@ ResourceFormat MakeResourceFormat(VkFormat fmt)
|
||||
case VK_FORMAT_MAX_ENUM: ret.compByteWidth = 1; break;
|
||||
}
|
||||
|
||||
// set PVRTC properties
|
||||
uint32_t pvrtc_ver = 0, pvrtc_bpp = 0;
|
||||
switch(fmt)
|
||||
{
|
||||
case VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG:
|
||||
case VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG:
|
||||
case VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG:
|
||||
case VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG: pvrtc_ver = 1; break;
|
||||
case VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG:
|
||||
case VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG:
|
||||
case VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG:
|
||||
case VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG: pvrtc_ver = 2; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch(fmt)
|
||||
{
|
||||
case VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG:
|
||||
case VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG:
|
||||
case VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG:
|
||||
case VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG: pvrtc_bpp = 2; break;
|
||||
case VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG:
|
||||
case VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG:
|
||||
case VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG:
|
||||
case VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG: pvrtc_bpp = 4; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
if(pvrtc_ver)
|
||||
ret.SetPVRTC(pvrtc_ver, pvrtc_bpp);
|
||||
|
||||
// set ASTC properties
|
||||
switch(fmt)
|
||||
{
|
||||
case VK_FORMAT_ASTC_4x4_UNORM_BLOCK:
|
||||
case VK_FORMAT_ASTC_4x4_SRGB_BLOCK:
|
||||
case VK_FORMAT_ASTC_5x4_UNORM_BLOCK:
|
||||
case VK_FORMAT_ASTC_5x4_SRGB_BLOCK:
|
||||
case VK_FORMAT_ASTC_5x5_UNORM_BLOCK:
|
||||
case VK_FORMAT_ASTC_5x5_SRGB_BLOCK:
|
||||
case VK_FORMAT_ASTC_6x5_UNORM_BLOCK:
|
||||
case VK_FORMAT_ASTC_6x5_SRGB_BLOCK:
|
||||
case VK_FORMAT_ASTC_6x6_UNORM_BLOCK:
|
||||
case VK_FORMAT_ASTC_6x6_SRGB_BLOCK:
|
||||
case VK_FORMAT_ASTC_8x5_UNORM_BLOCK:
|
||||
case VK_FORMAT_ASTC_8x5_SRGB_BLOCK:
|
||||
case VK_FORMAT_ASTC_8x6_UNORM_BLOCK:
|
||||
case VK_FORMAT_ASTC_8x6_SRGB_BLOCK:
|
||||
case VK_FORMAT_ASTC_8x8_UNORM_BLOCK:
|
||||
case VK_FORMAT_ASTC_8x8_SRGB_BLOCK:
|
||||
case VK_FORMAT_ASTC_10x5_UNORM_BLOCK:
|
||||
case VK_FORMAT_ASTC_10x5_SRGB_BLOCK:
|
||||
case VK_FORMAT_ASTC_10x6_UNORM_BLOCK:
|
||||
case VK_FORMAT_ASTC_10x6_SRGB_BLOCK:
|
||||
case VK_FORMAT_ASTC_10x8_UNORM_BLOCK:
|
||||
case VK_FORMAT_ASTC_10x8_SRGB_BLOCK:
|
||||
case VK_FORMAT_ASTC_10x10_UNORM_BLOCK:
|
||||
case VK_FORMAT_ASTC_10x10_SRGB_BLOCK:
|
||||
case VK_FORMAT_ASTC_12x10_UNORM_BLOCK:
|
||||
case VK_FORMAT_ASTC_12x10_SRGB_BLOCK:
|
||||
case VK_FORMAT_ASTC_12x12_UNORM_BLOCK:
|
||||
case VK_FORMAT_ASTC_12x12_SRGB_BLOCK:
|
||||
case VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK:
|
||||
case VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK:
|
||||
case VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK:
|
||||
case VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK:
|
||||
case VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK:
|
||||
case VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK:
|
||||
case VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK:
|
||||
case VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK:
|
||||
case VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK:
|
||||
case VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK:
|
||||
case VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK:
|
||||
case VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK:
|
||||
case VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK:
|
||||
case VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK:
|
||||
{
|
||||
BlockShape blockShape = GetBlockShape(fmt, 0);
|
||||
ret.SetASTC2D({blockShape.width, blockShape.height});
|
||||
break;
|
||||
}
|
||||
case VK_FORMAT_ASTC_3x3x3_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_3x3x3_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_3x3x3_SFLOAT_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_4x3x3_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_4x3x3_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_4x3x3_SFLOAT_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_4x4x3_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_4x4x3_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_4x4x3_SFLOAT_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_4x4x4_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_4x4x4_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_4x4x4_SFLOAT_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_5x4x4_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_5x4x4_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_5x4x4_SFLOAT_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_5x5x4_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_5x5x4_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_5x5x4_SFLOAT_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_5x5x5_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_5x5x5_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_5x5x5_SFLOAT_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_6x5x5_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_6x5x5_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_6x5x5_SFLOAT_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_6x6x5_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_6x6x5_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_6x6x5_SFLOAT_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_6x6x6_UNORM_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_6x6x6_SRGB_BLOCK_EXT:
|
||||
case VK_FORMAT_ASTC_6x6x6_SFLOAT_BLOCK_EXT:
|
||||
{
|
||||
BlockShape blockShape = GetBlockShape(fmt, 0);
|
||||
ret.SetASTC3D({blockShape.width, blockShape.height, blockShape.depth});
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
if(IsYUVFormat(fmt))
|
||||
{
|
||||
ret.SetYUVPlaneCount(GetYUVPlaneCount(fmt));
|
||||
@@ -3238,6 +3339,166 @@ VkFormat MakeVkFormat(ResourceFormat fmt)
|
||||
: VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK;
|
||||
break;
|
||||
}
|
||||
case ResourceFormatType::PVRTC:
|
||||
{
|
||||
if(fmt.PVRTCVersion() == 1)
|
||||
{
|
||||
if(fmt.PVRTCBpp() == 2)
|
||||
{
|
||||
ret = fmt.SRGBCorrected() ? VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG
|
||||
: VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = fmt.SRGBCorrected() ? VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG
|
||||
: VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fmt.PVRTCBpp() == 2)
|
||||
{
|
||||
ret = fmt.SRGBCorrected() ? VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG
|
||||
: VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = fmt.SRGBCorrected() ? VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG
|
||||
: VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ResourceFormatType::ASTC:
|
||||
{
|
||||
if(fmt.ASTCDimension() == 2)
|
||||
{
|
||||
rdcpair<uint32_t, uint32_t> dim = fmt.ASTC2DBlock();
|
||||
|
||||
switch(dim.first)
|
||||
{
|
||||
case 4:
|
||||
ret = fmt.compType == CompType::Float ? VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK
|
||||
: fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_4x4_UNORM_BLOCK
|
||||
: VK_FORMAT_ASTC_4x4_SRGB_BLOCK;
|
||||
break;
|
||||
case 5:
|
||||
if(dim.second == 4)
|
||||
ret = fmt.compType == CompType::Float ? VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK
|
||||
: fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_5x4_UNORM_BLOCK
|
||||
: VK_FORMAT_ASTC_5x4_SRGB_BLOCK;
|
||||
else if(dim.second == 5)
|
||||
ret = fmt.compType == CompType::Float ? VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK
|
||||
: fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_5x5_UNORM_BLOCK
|
||||
: VK_FORMAT_ASTC_5x5_SRGB_BLOCK;
|
||||
break;
|
||||
case 6:
|
||||
if(dim.second == 5)
|
||||
ret = fmt.compType == CompType::Float ? VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK
|
||||
: fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_6x5_UNORM_BLOCK
|
||||
: VK_FORMAT_ASTC_6x5_SRGB_BLOCK;
|
||||
else if(dim.second == 6)
|
||||
ret = fmt.compType == CompType::Float ? VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK
|
||||
: fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_6x6_UNORM_BLOCK
|
||||
: VK_FORMAT_ASTC_6x6_SRGB_BLOCK;
|
||||
break;
|
||||
case 8:
|
||||
if(dim.second == 5)
|
||||
ret = fmt.compType == CompType::Float ? VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK
|
||||
: fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_8x5_UNORM_BLOCK
|
||||
: VK_FORMAT_ASTC_8x5_SRGB_BLOCK;
|
||||
else if(dim.second == 6)
|
||||
ret = fmt.compType == CompType::Float ? VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK
|
||||
: fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_8x6_UNORM_BLOCK
|
||||
: VK_FORMAT_ASTC_8x6_SRGB_BLOCK;
|
||||
else if(dim.second == 8)
|
||||
ret = fmt.compType == CompType::Float ? VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK
|
||||
: fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_8x8_UNORM_BLOCK
|
||||
: VK_FORMAT_ASTC_8x8_SRGB_BLOCK;
|
||||
break;
|
||||
case 10:
|
||||
if(dim.second == 5)
|
||||
ret = fmt.compType == CompType::Float ? VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK
|
||||
: fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_10x5_UNORM_BLOCK
|
||||
: VK_FORMAT_ASTC_10x5_SRGB_BLOCK;
|
||||
else if(dim.second == 6)
|
||||
ret = fmt.compType == CompType::Float ? VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK
|
||||
: fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_10x6_UNORM_BLOCK
|
||||
: VK_FORMAT_ASTC_10x6_SRGB_BLOCK;
|
||||
else if(dim.second == 8)
|
||||
ret = fmt.compType == CompType::Float ? VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK
|
||||
: fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_10x8_UNORM_BLOCK
|
||||
: VK_FORMAT_ASTC_10x8_SRGB_BLOCK;
|
||||
else if(dim.second == 10)
|
||||
ret = fmt.compType == CompType::Float ? VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK
|
||||
: fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_10x10_UNORM_BLOCK
|
||||
: VK_FORMAT_ASTC_10x10_SRGB_BLOCK;
|
||||
break;
|
||||
case 12:
|
||||
if(dim.second == 10)
|
||||
ret = fmt.compType == CompType::Float ? VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK
|
||||
: fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_12x10_UNORM_BLOCK
|
||||
: VK_FORMAT_ASTC_12x10_SRGB_BLOCK;
|
||||
else if(dim.second == 12)
|
||||
ret = fmt.compType == CompType::Float ? VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK
|
||||
: fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_12x12_UNORM_BLOCK
|
||||
: VK_FORMAT_ASTC_12x12_SRGB_BLOCK;
|
||||
break;
|
||||
}
|
||||
|
||||
if(ret == VK_FORMAT_UNDEFINED)
|
||||
RDCERR("Invalid ASTC block shape %ux%u", dim.first, dim.second);
|
||||
}
|
||||
else
|
||||
{
|
||||
rdcfixedarray<uint32_t, 3> dim = fmt.ASTC3DBlock();
|
||||
|
||||
if(dim[0] == 3 && dim[1] == 3 && dim[2] == 3)
|
||||
ret = fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_3x3x3_UNORM_BLOCK_EXT
|
||||
: fmt.compType == CompType::UNormSRGB ? VK_FORMAT_ASTC_3x3x3_SRGB_BLOCK_EXT
|
||||
: VK_FORMAT_ASTC_3x3x3_SFLOAT_BLOCK_EXT;
|
||||
else if(dim[0] == 4 && dim[1] == 3 && dim[2] == 3)
|
||||
ret = fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_4x3x3_UNORM_BLOCK_EXT
|
||||
: fmt.compType == CompType::UNormSRGB ? VK_FORMAT_ASTC_4x3x3_SRGB_BLOCK_EXT
|
||||
: VK_FORMAT_ASTC_4x3x3_SFLOAT_BLOCK_EXT;
|
||||
else if(dim[0] == 4 && dim[1] == 4 && dim[2] == 3)
|
||||
ret = fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_4x4x3_UNORM_BLOCK_EXT
|
||||
: fmt.compType == CompType::UNormSRGB ? VK_FORMAT_ASTC_4x4x3_SRGB_BLOCK_EXT
|
||||
: VK_FORMAT_ASTC_4x4x3_SFLOAT_BLOCK_EXT;
|
||||
else if(dim[0] == 4 && dim[1] == 4 && dim[2] == 4)
|
||||
ret = fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_4x4x4_UNORM_BLOCK_EXT
|
||||
: fmt.compType == CompType::UNormSRGB ? VK_FORMAT_ASTC_4x4x4_SRGB_BLOCK_EXT
|
||||
: VK_FORMAT_ASTC_4x4x4_SFLOAT_BLOCK_EXT;
|
||||
else if(dim[0] == 5 && dim[1] == 4 && dim[2] == 4)
|
||||
ret = fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_5x4x4_UNORM_BLOCK_EXT
|
||||
: fmt.compType == CompType::UNormSRGB ? VK_FORMAT_ASTC_5x4x4_SRGB_BLOCK_EXT
|
||||
: VK_FORMAT_ASTC_5x4x4_SFLOAT_BLOCK_EXT;
|
||||
else if(dim[0] == 5 && dim[1] == 5 && dim[2] == 4)
|
||||
ret = fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_5x5x4_UNORM_BLOCK_EXT
|
||||
: fmt.compType == CompType::UNormSRGB ? VK_FORMAT_ASTC_5x5x4_SRGB_BLOCK_EXT
|
||||
: VK_FORMAT_ASTC_5x5x4_SFLOAT_BLOCK_EXT;
|
||||
else if(dim[0] == 5 && dim[1] == 5 && dim[2] == 5)
|
||||
ret = fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_5x5x5_UNORM_BLOCK_EXT
|
||||
: fmt.compType == CompType::UNormSRGB ? VK_FORMAT_ASTC_5x5x5_SRGB_BLOCK_EXT
|
||||
: VK_FORMAT_ASTC_5x5x5_SFLOAT_BLOCK_EXT;
|
||||
else if(dim[0] == 6 && dim[1] == 5 && dim[2] == 5)
|
||||
ret = fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_6x5x5_UNORM_BLOCK_EXT
|
||||
: fmt.compType == CompType::UNormSRGB ? VK_FORMAT_ASTC_6x5x5_SRGB_BLOCK_EXT
|
||||
: VK_FORMAT_ASTC_6x5x5_SFLOAT_BLOCK_EXT;
|
||||
else if(dim[0] == 6 && dim[1] == 6 && dim[2] == 5)
|
||||
ret = fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_6x6x5_UNORM_BLOCK_EXT
|
||||
: fmt.compType == CompType::UNormSRGB ? VK_FORMAT_ASTC_6x6x5_SRGB_BLOCK_EXT
|
||||
: VK_FORMAT_ASTC_6x6x5_SFLOAT_BLOCK_EXT;
|
||||
else if(dim[0] == 6 && dim[1] == 6 && dim[2] == 6)
|
||||
ret = fmt.compType == CompType::UNorm ? VK_FORMAT_ASTC_6x6x6_UNORM_BLOCK_EXT
|
||||
: fmt.compType == CompType::UNormSRGB ? VK_FORMAT_ASTC_6x6x6_SRGB_BLOCK_EXT
|
||||
: VK_FORMAT_ASTC_6x6x6_SFLOAT_BLOCK_EXT;
|
||||
|
||||
if(ret == VK_FORMAT_UNDEFINED)
|
||||
RDCERR("Invalid ASTC block shape %ux%ux%u", dim[0], dim[1], dim[2]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ResourceFormatType::R10G10B10A2:
|
||||
if(fmt.compType == CompType::UNorm)
|
||||
ret = fmt.BGRAOrder() ? VK_FORMAT_A2R10G10B10_UNORM_PACK32
|
||||
@@ -4711,6 +4972,8 @@ TEST_CASE("Vulkan formats", "[format][vulkan]")
|
||||
VK_FORMAT_R4G4_UNORM_PACK8,
|
||||
VK_FORMAT_R4G4B4A4_UNORM_PACK16,
|
||||
VK_FORMAT_B4G4R4A4_UNORM_PACK16,
|
||||
VK_FORMAT_A4R4G4B4_UNORM_PACK16,
|
||||
VK_FORMAT_A4B4G4R4_UNORM_PACK16,
|
||||
VK_FORMAT_R5G6B5_UNORM_PACK16,
|
||||
VK_FORMAT_B5G6R5_UNORM_PACK16,
|
||||
VK_FORMAT_R5G5B5A1_UNORM_PACK16,
|
||||
@@ -4894,6 +5157,50 @@ TEST_CASE("Vulkan formats", "[format][vulkan]")
|
||||
VK_FORMAT_ASTC_12x10_SRGB_BLOCK,
|
||||
VK_FORMAT_ASTC_12x12_UNORM_BLOCK,
|
||||
VK_FORMAT_ASTC_12x12_SRGB_BLOCK,
|
||||
VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_3x3x3_UNORM_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_3x3x3_SRGB_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_3x3x3_SFLOAT_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_4x3x3_UNORM_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_4x3x3_SRGB_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_4x3x3_SFLOAT_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_4x4x3_UNORM_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_4x4x3_SRGB_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_4x4x3_SFLOAT_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_4x4x4_UNORM_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_4x4x4_SRGB_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_4x4x4_SFLOAT_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_5x4x4_UNORM_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_5x4x4_SRGB_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_5x4x4_SFLOAT_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_5x5x4_UNORM_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_5x5x4_SRGB_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_5x5x4_SFLOAT_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_5x5x5_UNORM_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_5x5x5_SRGB_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_5x5x5_SFLOAT_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_6x5x5_UNORM_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_6x5x5_SRGB_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_6x5x5_SFLOAT_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_6x6x5_UNORM_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_6x6x5_SRGB_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_6x6x5_SFLOAT_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_6x6x6_UNORM_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_6x6x6_SRGB_BLOCK_EXT,
|
||||
VK_FORMAT_ASTC_6x6x6_SFLOAT_BLOCK_EXT,
|
||||
VK_FORMAT_G8B8G8R8_422_UNORM,
|
||||
VK_FORMAT_B8G8R8G8_422_UNORM,
|
||||
VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM,
|
||||
@@ -4940,20 +5247,6 @@ TEST_CASE("Vulkan formats", "[format][vulkan]")
|
||||
VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG,
|
||||
VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG,
|
||||
VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG,
|
||||
VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK,
|
||||
VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK,
|
||||
};
|
||||
|
||||
SECTION("Only VK_FORMAT_UNDEFINED is ResourceFormatType::Undefined")
|
||||
@@ -4976,19 +5269,6 @@ TEST_CASE("Vulkan formats", "[format][vulkan]")
|
||||
VkFormat original = f;
|
||||
ResourceFormat fmt = MakeResourceFormat(f);
|
||||
|
||||
// astc and pvrtc are not properly supported, collapse to a single type
|
||||
if((f >= VK_FORMAT_ASTC_4x4_UNORM_BLOCK && f <= VK_FORMAT_ASTC_12x12_SRGB_BLOCK) ||
|
||||
(f >= VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK && f <= VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK))
|
||||
{
|
||||
CHECK(fmt.type == ResourceFormatType::ASTC);
|
||||
continue;
|
||||
}
|
||||
if(f >= VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG && f <= VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG)
|
||||
{
|
||||
CHECK(fmt.type == ResourceFormatType::PVRTC);
|
||||
continue;
|
||||
}
|
||||
|
||||
VkFormat reconstructed = MakeVkFormat(fmt);
|
||||
|
||||
// we are OK with remapping these variants to another similar one, where our format doesn't
|
||||
@@ -5030,6 +5310,14 @@ TEST_CASE("Vulkan formats", "[format][vulkan]")
|
||||
{
|
||||
CHECK(reconstructed == VK_FORMAT_R8G8B8A8_SRGB);
|
||||
}
|
||||
else if(f == VK_FORMAT_A4R4G4B4_UNORM_PACK16)
|
||||
{
|
||||
CHECK(reconstructed == VK_FORMAT_R4G4B4A4_UNORM_PACK16);
|
||||
}
|
||||
else if(f == VK_FORMAT_A4B4G4R4_UNORM_PACK16)
|
||||
{
|
||||
CHECK(reconstructed == VK_FORMAT_B4G4R4A4_UNORM_PACK16);
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECK(reconstructed == original);
|
||||
@@ -5106,50 +5394,33 @@ TEST_CASE("Vulkan formats", "[format][vulkan]")
|
||||
{
|
||||
const uint32_t width = 24, height = 24;
|
||||
|
||||
// reference: 24x24 = 576, 576/2 = 288
|
||||
const uint32_t oneBytePerPixel = width * height;
|
||||
const uint32_t halfBytePerPixel = oneBytePerPixel / 2;
|
||||
|
||||
const uint32_t bcnsizes[] = {
|
||||
288, // VK_FORMAT_BC1_RGB_UNORM_BLOCK
|
||||
288, // VK_FORMAT_BC1_RGB_SRGB_BLOCK
|
||||
288, // VK_FORMAT_BC1_RGBA_UNORM_BLOCK
|
||||
288, // VK_FORMAT_BC1_RGBA_SRGB_BLOCK = 0.5 byte/px
|
||||
576, // VK_FORMAT_BC2_UNORM_BLOCK
|
||||
576, // VK_FORMAT_BC2_SRGB_BLOCK = 1 byte/px
|
||||
576, // VK_FORMAT_BC3_UNORM_BLOCK
|
||||
576, // VK_FORMAT_BC3_SRGB_BLOCK = 1 byte/px
|
||||
288, // VK_FORMAT_BC4_UNORM_BLOCK
|
||||
288, // VK_FORMAT_BC4_SNORM_BLOCK = 0.5 byte/px
|
||||
576, // VK_FORMAT_BC5_UNORM_BLOCK
|
||||
576, // VK_FORMAT_BC5_SNORM_BLOCK = 1 byte/px
|
||||
576, // VK_FORMAT_BC6H_UFLOAT_BLOCK
|
||||
576, // VK_FORMAT_BC6H_SFLOAT_BLOCK = 1 byte/px
|
||||
576, // VK_FORMAT_BC7_UNORM_BLOCK
|
||||
576, // VK_FORMAT_BC7_SRGB_BLOCK = 1 byte/px
|
||||
const rdcpair<VkFormat, uint32_t> bcn[] = {
|
||||
{VK_FORMAT_BC1_RGB_UNORM_BLOCK, halfBytePerPixel}, //
|
||||
{VK_FORMAT_BC1_RGB_SRGB_BLOCK, halfBytePerPixel}, //
|
||||
{VK_FORMAT_BC1_RGBA_UNORM_BLOCK, halfBytePerPixel}, //
|
||||
{VK_FORMAT_BC1_RGBA_SRGB_BLOCK, halfBytePerPixel}, // = 0.5 byte/px
|
||||
{VK_FORMAT_BC2_UNORM_BLOCK, oneBytePerPixel}, //
|
||||
{VK_FORMAT_BC2_SRGB_BLOCK, oneBytePerPixel}, //
|
||||
{VK_FORMAT_BC3_UNORM_BLOCK, oneBytePerPixel}, //
|
||||
{VK_FORMAT_BC3_SRGB_BLOCK, oneBytePerPixel}, // = 1 byte/px
|
||||
{VK_FORMAT_BC4_UNORM_BLOCK, halfBytePerPixel}, //
|
||||
{VK_FORMAT_BC4_SNORM_BLOCK, halfBytePerPixel}, // = 0.5 byte/px
|
||||
{VK_FORMAT_BC5_UNORM_BLOCK, oneBytePerPixel}, //
|
||||
{VK_FORMAT_BC5_SNORM_BLOCK, oneBytePerPixel}, //
|
||||
{VK_FORMAT_BC6H_UFLOAT_BLOCK, oneBytePerPixel}, //
|
||||
{VK_FORMAT_BC6H_SFLOAT_BLOCK, oneBytePerPixel}, //
|
||||
{VK_FORMAT_BC7_UNORM_BLOCK, oneBytePerPixel}, //
|
||||
{VK_FORMAT_BC7_SRGB_BLOCK, oneBytePerPixel}, // = 1 byte/px
|
||||
};
|
||||
|
||||
int i = 0;
|
||||
for(VkFormat f : {
|
||||
VK_FORMAT_BC1_RGB_UNORM_BLOCK,
|
||||
VK_FORMAT_BC1_RGB_SRGB_BLOCK,
|
||||
VK_FORMAT_BC1_RGBA_UNORM_BLOCK,
|
||||
VK_FORMAT_BC1_RGBA_SRGB_BLOCK,
|
||||
VK_FORMAT_BC2_UNORM_BLOCK,
|
||||
VK_FORMAT_BC2_SRGB_BLOCK,
|
||||
VK_FORMAT_BC3_UNORM_BLOCK,
|
||||
VK_FORMAT_BC3_SRGB_BLOCK,
|
||||
VK_FORMAT_BC4_UNORM_BLOCK,
|
||||
VK_FORMAT_BC4_SNORM_BLOCK,
|
||||
VK_FORMAT_BC5_UNORM_BLOCK,
|
||||
VK_FORMAT_BC5_SNORM_BLOCK,
|
||||
VK_FORMAT_BC6H_UFLOAT_BLOCK,
|
||||
VK_FORMAT_BC6H_SFLOAT_BLOCK,
|
||||
VK_FORMAT_BC7_UNORM_BLOCK,
|
||||
VK_FORMAT_BC7_SRGB_BLOCK,
|
||||
})
|
||||
for(const rdcpair<VkFormat, uint32_t> &f : bcn)
|
||||
{
|
||||
INFO("Format is " << ToStr(f));
|
||||
INFO("Format is " << ToStr(f.first));
|
||||
|
||||
CHECK(bcnsizes[i++] == GetByteSize(width, height, 1, f, 0));
|
||||
CHECK(f.second == GetByteSize(width, height, 1, f.first, 0));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5157,92 +5428,52 @@ TEST_CASE("Vulkan formats", "[format][vulkan]")
|
||||
{
|
||||
const uint32_t width = 24, height = 24;
|
||||
|
||||
const uint32_t yuvsizes[] = {
|
||||
1152, // VK_FORMAT_G8B8G8R8_422_UNORM (4:2:2 8-bit packed)
|
||||
1152, // VK_FORMAT_B8G8R8G8_422_UNORM (4:2:2 8-bit packed)
|
||||
864, // VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM (4:2:0 8-bit 3-plane)
|
||||
864, // VK_FORMAT_G8_B8R8_2PLANE_420_UNORM (4:2:0 8-bit 2-plane)
|
||||
1152, // VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM (4:2:2 8-bit 3-plane)
|
||||
1152, // VK_FORMAT_G8_B8R8_2PLANE_422_UNORM (4:2:2 8-bit 2-plane)
|
||||
1728, // VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM (4:4:4 8-bit 3-plane)
|
||||
1728, // VK_FORMAT_G8_B8R8_2PLANE_444_UNORM (4:4:4 8-bit 2-plane)
|
||||
1152, // VK_FORMAT_R10X6_UNORM_PACK16 (4:4:4 10-bit packed)
|
||||
2304, // VK_FORMAT_R10X6G10X6_UNORM_2PACK16 (4:4:4 10-bit packed)
|
||||
4608, // VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16 (4:4:4 10-bit packed)
|
||||
2304, // VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 (4:2:2 10-bit packed)
|
||||
2304, // VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 (4:2:2 10-bit packed)
|
||||
1728, // VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16 (4:2:0 10-bit 3-plane)
|
||||
1728, // VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16 (4:2:0 10-bit 2-plane)
|
||||
2304, // VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16 (4:2:2 10-bit 3-plane)
|
||||
2304, // VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16 (4:2:2 10-bit 2-plane)
|
||||
3456, // VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16 (4:4:4 10-bit 3-plane)
|
||||
3456, // VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16 (4:4:4 10-bit 2-plane)
|
||||
1152, // VK_FORMAT_R12X4_UNORM_PACK16 (4:4:4 12-bit packed)
|
||||
2304, // VK_FORMAT_R12X4G12X4_UNORM_2PACK16 (4:4:4 12-bit packed)
|
||||
4608, // VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16 (4:4:4 12-bit packed)
|
||||
2304, // VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 (4:2:2 12-bit packed)
|
||||
2304, // VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 (4:2:2 12-bit packed)
|
||||
1728, // VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16 (4:2:0 12-bit 3-plane)
|
||||
1728, // VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16 (4:2:0 12-bit 2-plane)
|
||||
2304, // VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16 (4:2:2 12-bit 3-plane)
|
||||
2304, // VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16 (4:2:2 12-bit 2-plane)
|
||||
3456, // VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16 (4:4:4 12-bit 3-plane)
|
||||
3456, // VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16 (4:4:4 12-bit 2-plane)
|
||||
2304, // VK_FORMAT_G16B16G16R16_422_UNORM (4:2:2 16-bit packed)
|
||||
2304, // VK_FORMAT_B16G16R16G16_422_UNORM (4:2:2 16-bit packed)
|
||||
1728, // VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM (4:2:0 16-bit 3-plane)
|
||||
1728, // VK_FORMAT_G16_B16R16_2PLANE_420_UNORM (4:2:0 16-bit 2-plane)
|
||||
2304, // VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM (4:2:2 16-bit 3-plane)
|
||||
2304, // VK_FORMAT_G16_B16R16_2PLANE_422_UNORM (4:2:2 16-bit 2-plane)
|
||||
3456, // VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM (4:4:4 16-bit 3-plane)
|
||||
3456, // VK_FORMAT_G16_B16R16_2PLANE_444_UNORM (4:4:4 16-bit 2-plane)
|
||||
const rdcpair<VkFormat, uint32_t> yuv[] = {
|
||||
{VK_FORMAT_G8B8G8R8_422_UNORM, 1152}, // (4:2:2 8-bit packed)
|
||||
{VK_FORMAT_B8G8R8G8_422_UNORM, 1152}, // (4:2:2 8-bit packed)
|
||||
{VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM, 864}, // (4:2:0 8-bit 3-plane)
|
||||
{VK_FORMAT_G8_B8R8_2PLANE_420_UNORM, 864}, // (4:2:0 8-bit 2-plane)
|
||||
{VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM, 1152}, // (4:2:2 8-bit 3-plane)
|
||||
{VK_FORMAT_G8_B8R8_2PLANE_422_UNORM, 1152}, // (4:2:2 8-bit 2-plane)
|
||||
{VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM, 1728}, // (4:4:4 8-bit 3-plane)
|
||||
{VK_FORMAT_G8_B8R8_2PLANE_444_UNORM, 1728}, // (4:4:4 8-bit 2-plane)
|
||||
{VK_FORMAT_R10X6_UNORM_PACK16, 1152}, // (4:4:4 10-bit packed)
|
||||
{VK_FORMAT_R10X6G10X6_UNORM_2PACK16, 2304}, // (4:4:4 10-bit packed)
|
||||
{VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16, 4608}, // (4:4:4 10-bit packed)
|
||||
{VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16, 2304}, // (4:2:2 10-bit packed)
|
||||
{VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16, 2304}, // (4:2:2 10-bit packed)
|
||||
{VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16, 1728}, // (4:2:0 10-bit 3-plane)
|
||||
{VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16, 1728}, // (4:2:0 10-bit 2-plane)
|
||||
{VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16, 2304}, // (4:2:2 10-bit 3-plane)
|
||||
{VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16, 2304}, // (4:2:2 10-bit 2-plane)
|
||||
{VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16, 3456}, // (4:4:4 10-bit 3-plane)
|
||||
{VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16, 3456}, // (4:4:4 10-bit 2-plane)
|
||||
{VK_FORMAT_R12X4_UNORM_PACK16, 1152}, // (4:4:4 12-bit packed)
|
||||
{VK_FORMAT_R12X4G12X4_UNORM_2PACK16, 2304}, // (4:4:4 12-bit packed)
|
||||
{VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16, 4608}, // (4:4:4 12-bit packed)
|
||||
{VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16, 2304}, // (4:2:2 12-bit packed)
|
||||
{VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16, 2304}, // (4:2:2 12-bit packed)
|
||||
{VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16, 1728}, // (4:2:0 12-bit 3-plane)
|
||||
{VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16, 1728}, // (4:2:0 12-bit 2-plane)
|
||||
{VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16, 2304}, // (4:2:2 12-bit 3-plane)
|
||||
{VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16, 2304}, // (4:2:2 12-bit 2-plane)
|
||||
{VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16, 3456}, // (4:4:4 12-bit 3-plane)
|
||||
{VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16, 3456}, // (4:4:4 12-bit 2-plane)
|
||||
{VK_FORMAT_G16B16G16R16_422_UNORM, 2304}, // (4:2:2 16-bit packed)
|
||||
{VK_FORMAT_B16G16R16G16_422_UNORM, 2304}, // (4:2:2 16-bit packed)
|
||||
{VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM, 1728}, // (4:2:0 16-bit 3-plane)
|
||||
{VK_FORMAT_G16_B16R16_2PLANE_420_UNORM, 1728}, // (4:2:0 16-bit 2-plane)
|
||||
{VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM, 2304}, // (4:2:2 16-bit 3-plane)
|
||||
{VK_FORMAT_G16_B16R16_2PLANE_422_UNORM, 2304}, // (4:2:2 16-bit 2-plane)
|
||||
{VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM, 3456}, // (4:4:4 16-bit 3-plane)
|
||||
{VK_FORMAT_G16_B16R16_2PLANE_444_UNORM, 3456}, // (4:4:4 16-bit 2-plane)
|
||||
};
|
||||
|
||||
int i = 0;
|
||||
for(VkFormat f : {
|
||||
VK_FORMAT_G8B8G8R8_422_UNORM,
|
||||
VK_FORMAT_B8G8R8G8_422_UNORM,
|
||||
VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM,
|
||||
VK_FORMAT_G8_B8R8_2PLANE_420_UNORM,
|
||||
VK_FORMAT_G8_B8_R8_3PLANE_422_UNORM,
|
||||
VK_FORMAT_G8_B8R8_2PLANE_422_UNORM,
|
||||
VK_FORMAT_G8_B8_R8_3PLANE_444_UNORM,
|
||||
VK_FORMAT_G8_B8R8_2PLANE_444_UNORM,
|
||||
VK_FORMAT_R10X6_UNORM_PACK16,
|
||||
VK_FORMAT_R10X6G10X6_UNORM_2PACK16,
|
||||
VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16,
|
||||
VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16,
|
||||
VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16,
|
||||
VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16,
|
||||
VK_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16,
|
||||
VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16,
|
||||
VK_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16,
|
||||
VK_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16,
|
||||
VK_FORMAT_G10X6_B10X6R10X6_2PLANE_444_UNORM_3PACK16,
|
||||
VK_FORMAT_R12X4_UNORM_PACK16,
|
||||
VK_FORMAT_R12X4G12X4_UNORM_2PACK16,
|
||||
VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16,
|
||||
VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16,
|
||||
VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16,
|
||||
VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16,
|
||||
VK_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16,
|
||||
VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16,
|
||||
VK_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16,
|
||||
VK_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16,
|
||||
VK_FORMAT_G12X4_B12X4R12X4_2PLANE_444_UNORM_3PACK16,
|
||||
VK_FORMAT_G16B16G16R16_422_UNORM,
|
||||
VK_FORMAT_B16G16R16G16_422_UNORM,
|
||||
VK_FORMAT_G16_B16_R16_3PLANE_420_UNORM,
|
||||
VK_FORMAT_G16_B16R16_2PLANE_420_UNORM,
|
||||
VK_FORMAT_G16_B16_R16_3PLANE_422_UNORM,
|
||||
VK_FORMAT_G16_B16R16_2PLANE_422_UNORM,
|
||||
VK_FORMAT_G16_B16_R16_3PLANE_444_UNORM,
|
||||
VK_FORMAT_G16_B16R16_2PLANE_444_UNORM,
|
||||
})
|
||||
for(const rdcpair<VkFormat, uint32_t> &f : yuv)
|
||||
{
|
||||
INFO("Format is " << ToStr(f));
|
||||
INFO("Format is " << ToStr(f.first));
|
||||
|
||||
CHECK(yuvsizes[i++] == GetByteSize(width, height, 1, f, 0));
|
||||
CHECK(f.second == GetByteSize(width, height, 1, f.first, 0));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2627,6 +2627,9 @@ struct BlockShape
|
||||
|
||||
// the number of bytes used to encode the block
|
||||
uint32_t bytes;
|
||||
|
||||
// the depth, for 3D ASTC only
|
||||
uint32_t depth;
|
||||
};
|
||||
|
||||
BlockShape GetBlockShape(VkFormat Format, uint32_t plane);
|
||||
|
||||
Reference in New Issue
Block a user