35 halp_meta(name,
"Array to texture")
36 halp_meta(category,
"Visuals/Utilities")
37 halp_meta(c_name,
"array_to_texture")
38 halp_meta(manual_url,
"https://ossia.io/score-docs/processes/array-to-texture.html")
39 halp_meta(uuid,
"bb5dc513-3430-4671-8c74-2bba78e53709")
43 struct : halp::val_port<
"Input", std::vector<float>>
47 struct : halp::xy_spinboxes_i32<
"Size">
51 struct : halp::enum_t<halp::custom_texture::texture_format,
"Format">
59 halp::texture_output<
"Output", halp::custom_texture> main;
64 const auto format = inputs.format;
65 const auto sz = inputs.size.value;
66 outputs.main.texture.request_format = format;
67 outputs.main.create(sz.x, sz.y);
68 std::size_t to_copy = sz.x * sz.y * outputs.main.texture.components(format);
69 const auto& value = inputs.in.value;
70 to_copy = std::min(to_copy, value.size());
72 auto* out = outputs.main.texture.bytes;
73 using enum halp::custom_texture::texture_format;
82 std::copy_n(value.data(), to_copy, (uint8_t*)out);
87 std::copy_n(value.data(), to_copy, (uint16_t*)out);
93 std::copy_n(value.data(), to_copy, (uint32_t*)out);
98 std::copy_n(value.data(), to_copy, (
float*)out);
104#if (SCORE_LIBC_HAS_FLOAT16 && SCORE_COMPILER_HAS_FLOAT16)
105 std::copy_n(value.data(), to_copy, (_Float16*)out);
110 auto* dst = (uint16_t*)out;
111 for(std::size_t i = 0; i < to_copy; i++)
113 const float f = value.data()[i];
115 std::memcpy(&x, &f, 4);
116 const uint32_t sign = (x >> 16) & 0x8000;
119 dst[i] = sign | 0x7C00 | (x > 0x7F800000 ? 0x200 : 0);
120 else if(x < 0x38800000)
122 const uint32_t shift = 126 - (x >> 23);
126 const uint32_t mant = (x & 0x7FFFFF) | 0x800000;
127 half = mant >> shift;
128 half += ((mant >> (shift - 1)) & 1)
129 && ((mant & ((1u << (shift - 1)) - 1)) || (half & 1));
131 dst[i] = sign | half;
135 uint32_t half = ((x - 0x38000000) >> 13);
136 half += ((x >> 12) & 1) && ((x & 0xFFF) || (half & 1));
137 dst[i] = sign | half;
147 outputs.main.upload();
Definition ArrayToTexture.hpp:33
Definition ArrayToTexture.hpp:42