84 if (host_format != device_format) {
98 switch (device_format) {
193 switch (device_format) {
272 switch (device_format) {
353 switch (device_format) {
428 switch (device_format) {
523 switch (host_format) {
548#define CASE_SINGLE(a, b) \
549 case ConversionType::a##_TO_##b: \
550 return ConversionType::b##_TO_##a;
552#define CASE_PAIR(a, b) \
599 float_to_bits.fl = value;
600 return float_to_bits.u;
609 float_to_bits.u = value;
610 return float_to_bits.fl;
637 return value & 0xffff;
642 value = (
value & 0xffffffffffff0000) | (new_value & 0xffff);
646 return (
value >> 16) & 0xffff;
651 value = (
value & 0xffffffff0000ffff) | ((new_value & 0xffff) << 16);
655 return (
value >> 32) & 0xffff;
660 value = (
value & 0xffff0000ffffffff) | ((new_value & 0xffff) << 32);
665 value = (
value & 0xffffffffffff) | ((new_value & 0xffff) << 48);
690 static_assert(std::is_same<InnerType, uint8_t>() || std::is_same<InnerType, uint16_t>());
695 return (1 << (
sizeof(InnerType) * 8 - 1));
700 return (1 << (
sizeof(InnerType) * 8 - 1)) - 1;
705 return ((1 << (
sizeof(InnerType) * 8)) - 1);
710 static_assert(std::is_same<InnerType, uint8_t>() || std::is_same<InnerType, uint16_t>() ||
711 std::is_same<InnerType, uint32_t>() ||
712 std::is_same<InnerType, DepthComponent24>());
717 if constexpr (std::is_same<InnerType, DepthComponent24>()) {
718 return InnerType::used_byte_size();
721 return sizeof(InnerType);
727 if constexpr (std::is_same<InnerType, DepthComponent24>()) {
731 return std::numeric_limits<InnerType>::max();
737 if constexpr (std::is_same<InnerType, DepthComponent24>()) {
741 return std::numeric_limits<InnerType>::max();
777template<
typename StorageType>
790template<
typename DestinationType,
typename SourceType>
791void convert(DestinationType &dst,
const SourceType &src)
793 static_assert(std::is_same<DestinationType, UI8>() || std::is_same<DestinationType, UI16>() ||
794 std::is_same<DestinationType, UI32>() || std::is_same<DestinationType, I8>() ||
795 std::is_same<DestinationType, I16>() || std::is_same<DestinationType, I32>());
796 static_assert(std::is_same<SourceType, UI8>() || std::is_same<SourceType, UI16>() ||
797 std::is_same<SourceType, UI32>() || std::is_same<SourceType, I8>() ||
798 std::is_same<SourceType, I16>() || std::is_same<SourceType, I32>());
799 static_assert(!std::is_same<DestinationType, SourceType>());
800 dst.value = src.value;
869template<
typename DestinationType,
typename SourceType>
874 convert(dst[index], src[index]);
878template<
typename DestinationType,
typename SourceType>
880 const void *src_memory,
888 static_cast<DestinationType *
>(dst_memory), total_components);
892template<
typename DestinationType,
typename SourceType>
898 static_cast<DestinationType *
>(dst_memory), buffer_size);
903 const void *src_memory,
914 memcpy(dst_memory, src_memory, buffer_size *
to_bytesize(device_format));
951 dst_memory, src_memory, buffer_size, device_format);
955 dst_memory, src_memory, buffer_size, device_format);
960 dst_memory, src_memory, buffer_size, device_format);
964 dst_memory, src_memory, buffer_size, device_format);
969 dst_memory, src_memory, buffer_size, device_format);
973 dst_memory, src_memory, buffer_size, device_format);
978 dst_memory, src_memory, buffer_size, device_format);
982 dst_memory, src_memory, buffer_size, device_format);
987 dst_memory, src_memory, buffer_size, device_format);
991 dst_memory, src_memory, buffer_size, device_format);
996 static_cast<uint16_t *
>(dst_memory),
1001 static_cast<float *
>(dst_memory),
1014 dst_memory, src_memory, buffer_size, device_format);
1018 dst_memory, src_memory, buffer_size, device_format);
1022 dst_memory, src_memory, buffer_size, device_format);
1053 const void *src_buffer,
1061 convert_buffer(dst_buffer, src_buffer, buffer_size, device_format, conversion_type);
1065 const void *src_buffer,
1072 host_to_device(host_format, host_texture_format, device_format));
1074 "Data conversion between host_format and device_format isn't supported (yet).");
1075 convert_buffer(dst_buffer, src_buffer, buffer_size, device_format, conversion_type);
1098 source_format_ =
nullptr;
1099 device_format_ =
nullptr;
1102 needs_conversion_ =
false;
1107 return device_format_ !=
nullptr;
1113 source_format_ = vertex_format;
1114 device_format_ = vertex_format;
1116 update_conversion_flags(*source_format_, workarounds);
1117 if (needs_conversion_) {
1118 init_device_format(workarounds);
1125 return *device_format_;
1131 return needs_conversion_;
1134void VertexFormatConverter::update_conversion_flags(
const GPUVertFormat &vertex_format,
1137 needs_conversion_ =
false;
1141 update_conversion_flags(vert_attr, workarounds);
1145void VertexFormatConverter::update_conversion_flags(
const GPUVertAttr &vertex_attribute,
1146 const VKWorkarounds &workarounds)
1152 needs_conversion_ =
true;
1157 needs_conversion_ =
true;
1161void VertexFormatConverter::init_device_format(
const VKWorkarounds &workarounds)
1165 bool needs_repack =
false;
1167 for (
int attr_index : IndexRange(converted_format_.attr_len)) {
1168 GPUVertAttr &vert_attr = converted_format_.attrs[attr_index];
1169 make_device_compatible(vert_attr, workarounds, needs_repack);
1175 device_format_ = &converted_format_;
1178void VertexFormatConverter::make_device_compatible(GPUVertAttr &vertex_attribute,
1180 bool &r_needs_repack)
const
1191 vertex_attribute.
size = 4;
1192 r_needs_repack =
true;
1198 const uint vertex_len)
const
1202 memcpy(device_data,
source_data, device_format_->stride * vertex_len);
1206 void *device_row_data =
static_cast<uint8_t *
>(device_data);
1207 for (
int vertex_index :
IndexRange(vertex_len)) {
1209 convert_row(device_row_data, source_row_data);
1210 source_row_data =
static_cast<const uint8_t *
>(source_row_data) + source_format_->stride;
1211 device_row_data =
static_cast<uint8_t *
>(device_row_data) + device_format_->stride;
1215void VertexFormatConverter::convert_row(
void *device_row_data,
const void *source_row_data)
const
1220 convert_attribute(device_row_data, source_row_data, device_attribute, source_attribute);
1224void VertexFormatConverter::convert_attribute(
void *device_row_data,
1225 const void *source_row_data,
1229 const void *source_attr_data =
static_cast<const uint8_t *
>(source_row_data) +
1231 void *device_attr_data =
static_cast<uint8_t *
>(device_row_data) + device_attribute.offset;
1232 if (source_attribute.comp_len == device_attribute.comp_len &&
1233 source_attribute.comp_type == device_attribute.comp_type &&
1234 source_attribute.fetch_mode == device_attribute.fetch_mode)
1241 for (
int component : IndexRange(source_attribute.comp_len)) {
1242 const int32_t *component_in =
static_cast<const int32_t *
>(source_attr_data) + component;
1243 float *component_out =
static_cast<float *
>(device_attr_data) + component;
1244 *component_out =
float(*component_in);
1250 for (
int component : IndexRange(source_attribute.comp_len)) {
1251 const uint32_t *component_in =
static_cast<const uint32_t *
>(source_attr_data) + component;
1252 float *component_out =
static_cast<float *
>(device_attr_data) + component;
1253 *component_out =
float(*component_in);
1259 const uchar3 *attr_in =
static_cast<const uchar3 *
>(source_attr_data);
1260 uchar4 *attr_out =
static_cast<uchar4 *
>(device_attr_data);
1261 *attr_out =
uchar4(attr_in->
x, attr_in->
y, attr_in->
z, 255);
#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
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its and value channels Color Retrieve a color attribute
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)
local_group_size(16, 16) .push_constant(Type b
additional_info("compositor_sum_float_shared") .push_constant(Type additional_info("compositor_sum_float_shared") .push_constant(Type GPU_RGBA32F
GPU_SHADER_INTERFACE_INFO(depth_2d_update_iface, "").smooth(Type fragColor push_constant(Type::VEC2, "extent") .push_constant(Type source_data
DOF_TILES_FLATTEN_GROUP_SIZE coc_tx GPU_R11F_G11F_B10F
draw_view in_light_buf[] float
out_radiance out_gbuf_normal out_gbuf_closure2 GPU_RG16
SHADOW_TILEMAP_RES tiles_buf[] statistics_buf render_view_buf[SHADOW_VIEW_MAX] GPU_R32UI
RAYTRACE_GROUP_SIZE additional_info("eevee_shared", "eevee_gbuffer_data", "eevee_global_ubo", "eevee_sampling_data", "eevee_utility_texture", "eevee_hiz_data", "draw_view") .specialization_constant(Type RAYTRACE_GROUP_SIZE in_sh_0_tx in_sh_2_tx screen_normal_tx GPU_RGBA8
ComponentValue< int16_t > I16
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)
@ B10F_G11F_R11F_TO_FLOAT
@ FLOAT_TO_B10F_G11F_R11F
@ UINT_TO_DEPTH_COMPONENT24
@ DEPTH_COMPONENT24_TO_UINT
@ DEPTH_COMPONENT24_TO_FLOAT
@ 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
constexpr bool validate_data_format(eGPUTextureFormat tex_format, eGPUDataFormat data_format)
static ConversionType type_of_conversion_uint(eGPUTextureFormat device_format)
size_t to_bytesize(GPUIndexBufType type)
static bool attribute_check(const GPUVertAttr attribute, GPUVertCompType comp_type, GPUVertFetchMode fetch_mode)
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)
blender::VecBase< uint8_t, 3 > uchar3
blender::VecBase< uint8_t, 4 > uchar4
unsigned __int64 uint64_t
#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()