Overview
I am considering having an abstracting for handling GPU data such as handling multi-faced textures. Example being a skybox.
There has been some thought of how I plan to approach this, not sure which way may fit the needs to smoothly send information to the GPU or have access in the same address space. There are things that still need to be considered here.
Though, I have some idea in how the API may take form.
Example API Usage
Here are some of my thoughts for the API's would be:
vk::cube_image skybox_image(logical_device, ....);
// faces = 6
// also accounted for the array_layers
// bytes_per_pixel = size * pixel_bytes
// do stuff with storing all of the image faces into this array and load them altogether
// all_six_faces: std::span<const uint8_t>
skybox_image.multi_write(all_six_faces, faces, bytes_per_pixel);
Some Pseudocode Example
template<uint64_t array_layers=6, uint64_t bytes_per_pixel=4>
void multi_write(std::span<const uint8_t> p_data, uint32_t p_offset) {
void* mapped_data = nullptr;
vk_check(vkMapMemory(
m_device, m_device_memory, p_offset, p_data.size_bytes(), 0, &mapped_data),
"vkMapMemory");
// Number of faces we have. If it was a skybox, then it would be 6
uint64_t face_size = array_layers;
// size refer to each face rows and columns.
auto gpu_view = std::mdspan<std::byte, std::extents<size_t, array_layers, std::dynamic_extent, std::dynamic_extent>> (
static_cast<std::byte*>(mapped_data), face_size, p_data.size(), p_data.size_bytes()
);
for(size_t i = 0; i < array_layers; i++) {
auto* face_ptr = &gpu_view[i, 0, 0];
// potentially memcpy
}
vkUnmapMemory(m_device, m_device_memory);
}
Overview
I am considering having an abstracting for handling GPU data such as handling multi-faced textures. Example being a skybox.
There has been some thought of how I plan to approach this, not sure which way may fit the needs to smoothly send information to the GPU or have access in the same address space. There are things that still need to be considered here.
Though, I have some idea in how the API may take form.
Example API Usage
Here are some of my thoughts for the API's would be:
Some Pseudocode Example