Skip to content

Commit

Permalink
[gpu.resource] added new api function resource_read. also added undoc…
Browse files Browse the repository at this point in the history
…umented NYI api functions buffer_resize and image_resize, which error out currently if you try to call them
  • Loading branch information
harrand committed Oct 20, 2024
1 parent b2cd0b8 commit afec52b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/tz/gpu/resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,15 @@ namespace tz::gpu
* - If the image was created with @ref image_type::depth or @ref image_type::floats, then each pixel should be 4 bytes - a single signed 32-bit float.
*/
void resource_write(resource_handle res, std::span<const std::byte> new_data);
/**
* @ingroup tz_gpu_resource
* @brief Retrieves the current data within a resource.
*
* You aren't allowed to read from @ref tz::gpu::window_resource.
*/
std::span<const std::byte> resource_read(resource_handle res);
void buffer_resize(resource_handle bufh, std::size_t new_size_bytes);
void image_resize(resource_handle imgh, unsigned int new_width, unsigned int new_height);
/**
* @ingroup tz_gpu_resource
* @brief Write indices into a buffer resource.
Expand Down
20 changes: 20 additions & 0 deletions src/tz/gpu/rhi_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,26 @@ namespace tz::gpu
impl_write_single_resource(resh);
}

std::span<const std::byte> resource_read(resource_handle resh)
{
auto& res = resources[resh.peek()];
return res.data;
}

void buffer_resize(resource_handle bufh, std::size_t new_size_bytes)
{
(void)bufh;
(void)new_size_bytes;
tz_error("buffer resize NYI");
}

void image_resize(resource_handle imgh, unsigned int new_width, unsigned int new_height)
{
(void)imgh;
(void)new_width; (void)new_height;
tz_error("image resize NYI");
}

void index_buffer_write(resource_handle index_buffer, std::span<const index_t> indices)
{
resource_write(index_buffer, std::as_bytes(indices));
Expand Down

0 comments on commit afec52b

Please sign in to comment.