Route RTT region readbacks through backend

This commit is contained in:
2026-06-04 21:01:13 +02:00
parent b9dbcd10d7
commit 15c58bfb21
8 changed files with 86 additions and 58 deletions

View File

@@ -503,6 +503,38 @@ glm::ivec4 RTT::calc_bounds() const noexcept
return { bbmin, bbmax };
}
bool RTT::readPixelsRgba8(int x, int y, int width, int height, void* buffer) const noexcept
{
if (!valid() || buffer == nullptr)
return false;
bool ret = true;
App::I->render_task([&]
{
const auto readback = pp::renderer::gl::rgba8_readback_format();
const auto status = pp::renderer::gl::readback_opengl_framebuffer(
pp::renderer::gl::OpenGlFramebufferReadback {
.framebuffer = static_cast<std::uint32_t>(fboID),
.x = x,
.y = y,
.width = width,
.height = height,
.format = readback,
.pixels = buffer,
},
pp::renderer::gl::OpenGlFramebufferReadbackDispatch {
.get_integer = query_opengl_integer,
.bind_framebuffer = bind_opengl_framebuffer,
.read_pixels = read_opengl_pixels,
});
if (!status.ok()) {
LOG("RTT::readPixelsRgba8() failed because: %s", status.message);
ret = false;
}
});
return ret;
}
uint8_t* RTT::readTextureData(uint8_t* buffer) const noexcept
{
if (!valid())