Skip to content

Commit

Permalink
[text_renderer] fixed a nasty gpu crash (device lost) which was cause…
Browse files Browse the repository at this point in the history
…d whenever the internal string buffer got resized coz it needs more space. the new string_locators in the expanded buffer did not have their memory zero'd, causing them to have indeterminate values and causing the compute shader to iterate over them and read garbage memory (and then go on to read out of bounds which causes a device-lost)
  • Loading branch information
harrand committed Feb 27, 2024
1 parent 3dba699 commit d8c5d66
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/tz/ren/text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,13 +317,22 @@ namespace tz::ren
{
return;
}
std::vector<string_locator> new_empties;
new_empties.resize(string_count - old_cap);
std::span<const string_locator> new_empties_span = new_empties;
tz::gl::get_device().get_renderer(rh).edit(
tz::gl::RendererEditBuilder{}
.buffer_resize
({
.buffer_handle = this->string_buffer,
.size = string_count * sizeof(string_locator)
})
.write
({
.resource = this->string_buffer,
.data = std::as_bytes(new_empties_span),
.offset = old_cap * sizeof(string_locator),
})
.build()
);
tz::gl::get_device().get_renderer(ch).edit(
Expand Down

0 comments on commit d8c5d66

Please sign in to comment.