Skip to content

Commit

Permalink
[gpu.resource] resource_write now can have an offset
Browse files Browse the repository at this point in the history
  • Loading branch information
harrand committed Oct 30, 2024
1 parent aebbc6f commit 7f0809d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/tz/gpu/resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ namespace tz::gpu
* - If the image was created with @ref image_type::rgba, then each pixel should be 4 bytes - one for each component (0-255).
* - 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);
void resource_write(resource_handle res, std::span<const std::byte> new_data, std::size_t offset = 0);
/**
* @ingroup tz_gpu_resource
* @brief Retrieves the current data within a resource.
Expand Down
6 changes: 3 additions & 3 deletions src/tz/gpu/rhi_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,12 +898,12 @@ namespace tz::gpu
return tz::error_code::success;
}

void resource_write(resource_handle resh, std::span<const std::byte> new_data)
void resource_write(resource_handle resh, std::span<const std::byte> new_data, std::size_t offset)
{
auto& res = resources[resh.peek()];
// update the resource data cpu-side.
tz_assert(new_data.size_bytes() == res.data.size(), "resource write data span is of wrong size.");
std::copy(new_data.begin(), new_data.end(), res.data.begin());
tz_assert(offset + new_data.size_bytes() <= res.data.size(), "resource write data span is of wrong size.");
std::copy(new_data.begin(), new_data.end(), res.data.begin() + offset);
// make sure the change is resident GPU-side.
// definitely could cause gpu sync issues if commands are currently in-flight that are reading from it.
impl_write_single_resource(resh);
Expand Down

0 comments on commit 7f0809d

Please sign in to comment.