94 if (host_format != device_format) {
111 switch (device_format) {
208 switch (device_format) {
287 switch (device_format) {
369 switch (device_format) {
444 switch (device_format) {
521 switch (device_format) {
617 switch (host_format) {
641#define CASE_SINGLE(a, b) \
642 case ConversionType::a##_TO_##b: \
643 return ConversionType::b##_TO_##a;
645#define CASE_PAIR(a, b) \
697 float_to_bits.fl = value;
698 return float_to_bits.u;
707 float_to_bits.u = value;
708 return float_to_bits.fl;
736 return value & 0xffff;
741 value = (
value & 0xffffffffffff0000) | (new_value & 0xffff);
745 return (
value >> 16) & 0xffff;
750 value = (
value & 0xffffffff0000ffff) | ((new_value & 0xffff) << 16);
754 return (
value >> 32) & 0xffff;
759 value = (
value & 0xffff0000ffffffff) | ((new_value & 0xffff) << 32);
764 value = (
value & 0xffffffffffff) | ((new_value & 0xffff) << 48);
770 operator uint32_t()
const
793 static_assert(std::is_same<InnerType, uint8_t>() || std::is_same<InnerType, uint16_t>());
798 return (1 << (
sizeof(InnerType) * 8 - 1));
803 return (1 << (
sizeof(InnerType) * 8 - 1)) - 1;
808 return ((1 << (
sizeof(InnerType) * 8)) - 1);
813 static_assert(std::is_same<InnerType, uint8_t>() || std::is_same<InnerType, uint16_t>() ||
814 std::is_same<InnerType, uint32_t>() ||
815 std::is_same<InnerType, DepthComponent24>());
820 if constexpr (std::is_same<InnerType, DepthComponent24>()) {
821 return InnerType::used_byte_size();
824 return sizeof(InnerType);
830 if constexpr (std::is_same<InnerType, DepthComponent24>()) {
834 return std::numeric_limits<InnerType>::max();
838 static constexpr uint32_t
max()
840 if constexpr (std::is_same<InnerType, DepthComponent24>()) {
844 return std::numeric_limits<InnerType>::max();
867 static constexpr uint32_t
max = scalar;
877 dst.
value = float(uint32_t(src.
value & scalar)) / float(scalar);
880template<
typename StorageType>
893template<
typename DestinationType,
typename SourceType>
894void convert(DestinationType &dst,
const SourceType &src)
896 static_assert(std::is_same<DestinationType, UI8>() || std::is_same<DestinationType, UI16>() ||
897 std::is_same<DestinationType, UI32>() || std::is_same<DestinationType, I8>() ||
898 std::is_same<DestinationType, I16>() || std::is_same<DestinationType, I32>());
899 static_assert(std::is_same<SourceType, UI8>() || std::is_same<SourceType, UI16>() ||
900 std::is_same<SourceType, UI32>() || std::is_same<SourceType, I8>() ||
901 std::is_same<SourceType, I16>() || std::is_same<SourceType, I32>());
902 static_assert(!std::is_same<DestinationType, SourceType>());
903 dst.value = src.value;
993 uint32_t stencil = (src.
value & 0xFF000000) >> 24;
994 uint32_t depth = (src.
value & 0xFFFFFF);
995 dst.
value = (depth << 8) + stencil;
1001 uint32_t stencil = (src.
value & 0xFF);
1002 uint32_t depth = (src.
value >> 8) & 0xFFFFFF;
1003 dst.
value = depth + (stencil << 24);
1008 uint32_t depth = uint32_t(src.
value * 0xFFFFFF);
1009 dst.
value = (depth << 8);
1014 uint32_t depth = (src.
value >> 8) & 0xFFFFFF;
1015 dst.
value = float(depth) * 0xFFFFFF;
1018template<
typename DestinationType,
typename SourceType>
1023 convert(dst[index], src[index]);
1027template<
typename DestinationType,
typename SourceType>
1029 const void *src_memory,
1037 static_cast<DestinationType *
>(dst_memory), total_components);
1041template<
typename DestinationType,
typename SourceType>
1047 static_cast<DestinationType *
>(dst_memory), buffer_size);
1052 const void *src_memory,
1063 memcpy(dst_memory, src_memory, buffer_size *
to_bytesize(device_format));
1104 dst_memory, src_memory, buffer_size, device_format);
1108 dst_memory, src_memory, buffer_size, device_format);
1113 dst_memory, src_memory, buffer_size, device_format);
1117 dst_memory, src_memory, buffer_size, device_format);
1122 dst_memory, src_memory, buffer_size, device_format);
1126 dst_memory, src_memory, buffer_size, device_format);
1131 dst_memory, src_memory, buffer_size, device_format);
1135 dst_memory, src_memory, buffer_size, device_format);
1140 dst_memory, src_memory, buffer_size, device_format);
1144 dst_memory, src_memory, buffer_size, device_format);
1156 static_cast<uint16_t *
>(dst_memory),
1161 static_cast<float *
>(dst_memory),
1174 dst_memory, src_memory, buffer_size, device_format);
1178 dst_memory, src_memory, buffer_size, device_format);
1182 dst_memory, src_memory, buffer_size, device_format);
1226 const void *src_buffer,
1234 convert_buffer(dst_buffer, src_buffer, buffer_size, device_format, conversion_type);
1238 const void *src_buffer,
1245 host_to_device(host_format, host_texture_format, device_format));
1247 "Data conversion between host_format and device_format isn't supported (yet).");
1248 convert_buffer(dst_buffer, src_buffer, buffer_size, device_format, conversion_type);
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
MINLINE float max_ff(float a, float b)
MINLINE int clamp_i(int value, int min, int max)
@ GPU_DATA_2_10_10_10_REV
unsigned long long int uint64_t
ColorSceneLinearByteEncoded4b< Alpha > encode() const
ColorSceneLinear4f< Alpha > decode() const
constexpr int64_t size() const
constexpr int64_t size() const
DepthComponent24 & operator=(uint32_t new_value)
static constexpr size_t used_byte_size()
void set_g(uint64_t new_value)
void set_r(uint64_t new_value)
void set_a(uint64_t new_value)
void set_b(uint64_t new_value)
ComponentValue< int16_t > I16
ComponentValue< uint16_t > F16
ComponentValue< uint8_t > UI8
constexpr uint32_t MASK_10_BITS
PixelValue< ColorSceneLinearByteEncoded4b< eAlpha::Premultiplied > > SRGBA8
static ConversionType type_of_conversion_float(const eGPUTextureFormat host_format, const eGPUTextureFormat device_format)
ComponentValue< uint32_t > UI32
constexpr uint8_t SHIFT_B
static ConversionType type_of_conversion_ubyte(eGPUTextureFormat device_format)
static ConversionType reversed(ConversionType type)
static ConversionType type_of_conversion_half(eGPUTextureFormat device_format)
@ UINT_TO_DEPTH24_STENCIL8
@ B10F_G11F_R11F_TO_FLOAT
@ FLOAT_TO_B10F_G11F_R11F
@ UINT_TO_DEPTH_COMPONENT24
@ UINT_TO_DEPTH32F_STENCIL8
@ DEPTH32F_STENCIL8_TO_UINT
@ DEPTH_COMPONENT24_TO_UINT
@ DEPTH_COMPONENT24_TO_FLOAT
@ DEPTH24_STENCIL8_TO_UINT
@ FLOAT_TO_DEPTH_COMPONENT24
void convert_host_to_device(void *dst_buffer, const void *src_buffer, size_t buffer_size, eGPUDataFormat host_format, eGPUTextureFormat host_texture_format, eGPUTextureFormat device_format)
void convert_per_component(void *dst_memory, const void *src_memory, size_t buffer_size, eGPUTextureFormat device_format)
static ConversionType host_to_device(const eGPUDataFormat host_format, const eGPUTextureFormat host_texture_format, const eGPUTextureFormat device_format)
static uint32_t float_to_uint32_t(float value)
void convert(SignedNormalized< StorageType > &dst, const F32 &src)
ComponentValue< uint16_t > UI16
constexpr uint8_t SHIFT_R
constexpr uint8_t SHIFT_G
void convert_device_to_host(void *dst_buffer, const void *src_buffer, size_t buffer_size, eGPUDataFormat host_format, eGPUTextureFormat host_texture_format, eGPUTextureFormat device_format)
PixelValue< float3 > FLOAT3
static ConversionType type_of_conversion_uint(eGPUTextureFormat device_format)
static ConversionType type_of_conversion_uint248(const eGPUTextureFormat device_format)
int to_bytesize(const DataFormat format)
ComponentValue< float > F32
ComponentValue< int32_t > I32
PixelValue< ColorSceneLinear4f< eAlpha::Premultiplied > > FLOAT4
static ConversionType type_of_conversion_r10g10b10a2(eGPUTextureFormat device_format)
ComponentValue< int8_t > I8
static void convert_buffer(void *dst_memory, const void *src_memory, size_t buffer_size, eGPUTextureFormat device_format, ConversionType type)
int to_component_len(eGPUTextureFormat format)
uint32_t convert_float_formats(uint32_t value)
static float uint32_t_to_float(uint32_t value)
void convert_per_pixel(void *dst_memory, const void *src_memory, size_t buffer_size)
static ConversionType type_of_conversion_r11g11b10(eGPUTextureFormat device_format)
static ConversionType type_of_conversion_int(eGPUTextureFormat device_format)
constexpr uint32_t MASK_11_BITS
void float_to_half_array(const float *src, uint16_t *dst, size_t length)
uint16_t float_to_half(float v)
void half_to_float_array(const uint16_t *src, float *dst, size_t length)
float half_to_float(uint16_t v)
#define CASE_PAIR(value_src, value_dst)
ColorSceneLinearByteEncoded4b< eAlpha::Premultiplied > value
static constexpr int32_t scalar()
static constexpr int32_t delta()
static constexpr int32_t max()
static constexpr uint32_t max()
static constexpr size_t used_byte_size()
static constexpr uint32_t scalar()