CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Common/GPU/DataFormat.h
Views: 1401
#pragma once12#include <cstdint>3#include <cstdlib>45namespace Draw {67enum class DataFormat : uint8_t {8UNDEFINED,910R8_UNORM,11R8G8_UNORM,12R8G8B8_UNORM,1314R8G8B8A8_UNORM,15R8G8B8A8_UNORM_SRGB,16B8G8R8A8_UNORM, // D3D style17B8G8R8A8_UNORM_SRGB, // D3D style1819R8G8B8A8_SNORM,20R8G8B8A8_UINT,21R8G8B8A8_SINT,2223R4G4_UNORM_PACK8,24A4R4G4B4_UNORM_PACK16, // A4 in the UPPER bit25B4G4R4A4_UNORM_PACK16,26R4G4B4A4_UNORM_PACK16,27R5G6B5_UNORM_PACK16,28B5G6R5_UNORM_PACK16,29R5G5B5A1_UNORM_PACK16, // A1 in the LOWER bit30B5G5R5A1_UNORM_PACK16, // A1 in the LOWER bit31A1R5G5B5_UNORM_PACK16, // A1 in the UPPER bit.32A1B5G5R5_UNORM_PACK16, // A1 in the UPPER bit. OpenGL-only.3334R16_UNORM,3536R16_FLOAT,37R16G16_FLOAT,38R16G16B16A16_FLOAT,3940R32_FLOAT,41R32G32_FLOAT,42R32G32B32_FLOAT,43R32G32B32A32_FLOAT,4445// Block compression formats.46// These are modern names for DXT and friends, now patent free.47// https://msdn.microsoft.com/en-us/library/bb694531.aspx48BC1_RGBA_UNORM_BLOCK, // 64 bits per 4x4 block. Used by Basis, along with ETC2_R8G8B8_UNORM_BLOCK.49BC2_UNORM_BLOCK, // 4-bit straight alpha + DXT1 color. 128 bits per block. Usually not worth using50BC3_UNORM_BLOCK, // 3-bit alpha with 2 ref values (+ magic) + DXT1 color. 128 bits per block.51BC4_UNORM_BLOCK, // 1-channel, same storage as BC3 alpha. 64 bits per block.52BC5_UNORM_BLOCK, // 2-channel RG, each has same storage as BC3 alpha. 128 bits per block.53BC7_UNORM_BLOCK, // Highly advanced RGBA, very expensive to compress, very good quality. 128 bits per block.5455// Ericsson texture compression.56ETC2_R8G8B8_UNORM_BLOCK, // Color-only, 64 bits per 4x4 block.57ETC2_R8G8B8A1_UNORM_BLOCK, // Color + alpha, 128 bits per 4x4 block.58ETC2_R8G8B8A8_UNORM_BLOCK, // Color + alpha, 128 bits per 4x4 block.5960// This is the one ASTC format used by UASTC / basis Universal.61ASTC_4x4_UNORM_BLOCK,6263S8,64D16,65D16_S8,66D24_S8,67D32F,68D32F_S8,69};7071size_t DataFormatSizeInBytes(DataFormat fmt);72bool DataFormatIsDepthStencil(DataFormat fmt);73inline bool DataFormatIsColor(DataFormat fmt) {74return !DataFormatIsDepthStencil(fmt);75}76bool DataFormatIsBlockCompressed(DataFormat fmt, int *blockSize);7778// Limited format support for now.79const char *DataFormatToString(DataFormat fmt);8081void ConvertFromRGBA8888(uint8_t *dst, const uint8_t *src, uint32_t dstStride, uint32_t srcStride, uint32_t width, uint32_t height, DataFormat format);82void ConvertFromBGRA8888(uint8_t *dst, const uint8_t *src, uint32_t dstStride, uint32_t srcStride, uint32_t width, uint32_t height, DataFormat format);83void ConvertToD32F(uint8_t *dst, const uint8_t *src, uint32_t dstStride, uint32_t srcStride, uint32_t width, uint32_t height, DataFormat format);84void ConvertToD16(uint8_t *dst, const uint8_t *src, uint32_t dstStride, uint32_t srcStride, uint32_t width, uint32_t height, DataFormat format);8586} // namespace878889