MCPcopy Create free account
hub / github.com/FEX-Emu/FEX / RepackStructArray

Function RepackStructArray

ThunkLibs/libvulkan/Host.cpp:269–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

267// Allocates storage on the heap that must be de-allocated using delete[] or DeleteRepackedStructArray
268template<bool NeedsRepack = true, typename T>
269std::span<std::remove_cv_t<T>> RepackStructArray(uint32_t Count, const guest_layout<T*> GuestData) {
270 if (!GuestData.get_pointer() || Count == 0) {
271 return {};
272 }
273
274 auto HostData = new std::remove_cv_t<T>[Count];
275 for (size_t i = 0; i < Count; ++i) {
276 auto& GuestElement = (const guest_layout<std::remove_cv_t<T>>&)GuestData.get_pointer()[i];
277 auto Element = host_layout<std::remove_cv_t<T>> {GuestElement};
278 if constexpr (NeedsRepack) {
279 fex_apply_custom_repacking_entry(Element, GuestElement);
280 }
281 HostData[i] = Element.data;
282 }
283 return {HostData, Count};
284}
285
286template<typename T>
287void DeleteRepackedStructArray(uint32_t Count, T* HostData, guest_layout<T*>& GuestData) {

Calls 1

get_pointerMethod · 0.45

Tested by

no test coverage detected