Route RTT blit readback through renderer GL
This commit is contained in:
@@ -608,6 +608,82 @@ pp::foundation::Result<OpenGlTexture2DReadbackResult> readback_opengl_texture_2d
|
||||
return pp::foundation::Result<OpenGlTexture2DReadbackResult>::success(result);
|
||||
}
|
||||
|
||||
pp::foundation::Status blit_opengl_framebuffer(
|
||||
OpenGlFramebufferBlit blit,
|
||||
OpenGlFramebufferBlitDispatch dispatch) noexcept
|
||||
{
|
||||
if (dispatch.get_integer == nullptr
|
||||
|| dispatch.bind_framebuffer == nullptr
|
||||
|| dispatch.blit_framebuffer == nullptr) {
|
||||
return pp::foundation::Status::invalid_argument("OpenGL framebuffer blit dispatch callbacks must not be null");
|
||||
}
|
||||
|
||||
if (blit.source_rect.x1 <= blit.source_rect.x0
|
||||
|| blit.source_rect.y1 <= blit.source_rect.y0
|
||||
|| blit.destination_rect.x1 <= blit.destination_rect.x0
|
||||
|| blit.destination_rect.y1 <= blit.destination_rect.y0
|
||||
|| blit.mask == 0U
|
||||
|| blit.filter == 0U) {
|
||||
return pp::foundation::Status::invalid_argument("OpenGL framebuffer blit parameters are invalid");
|
||||
}
|
||||
|
||||
std::int32_t previous_draw_framebuffer = 0;
|
||||
std::int32_t previous_read_framebuffer = 0;
|
||||
dispatch.get_integer(draw_framebuffer_binding_query(), &previous_draw_framebuffer);
|
||||
dispatch.get_integer(read_framebuffer_binding_query(), &previous_read_framebuffer);
|
||||
dispatch.bind_framebuffer(draw_framebuffer_target(), blit.destination_framebuffer);
|
||||
dispatch.bind_framebuffer(read_framebuffer_target(), blit.source_framebuffer);
|
||||
dispatch.blit_framebuffer(
|
||||
blit.source_rect.x0,
|
||||
blit.source_rect.y0,
|
||||
blit.source_rect.x1,
|
||||
blit.source_rect.y1,
|
||||
blit.destination_rect.x0,
|
||||
blit.destination_rect.y0,
|
||||
blit.destination_rect.x1,
|
||||
blit.destination_rect.y1,
|
||||
blit.mask,
|
||||
blit.filter);
|
||||
dispatch.bind_framebuffer(draw_framebuffer_target(), static_cast<std::uint32_t>(previous_draw_framebuffer));
|
||||
dispatch.bind_framebuffer(read_framebuffer_target(), static_cast<std::uint32_t>(previous_read_framebuffer));
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Status readback_opengl_framebuffer(
|
||||
OpenGlFramebufferReadback readback,
|
||||
OpenGlFramebufferReadbackDispatch dispatch) noexcept
|
||||
{
|
||||
if (dispatch.get_integer == nullptr
|
||||
|| dispatch.bind_framebuffer == nullptr
|
||||
|| dispatch.read_pixels == nullptr) {
|
||||
return pp::foundation::Status::invalid_argument(
|
||||
"OpenGL framebuffer readback dispatch callbacks must not be null");
|
||||
}
|
||||
|
||||
if (readback.width <= 0
|
||||
|| readback.height <= 0
|
||||
|| readback.format.pixel_format == 0U
|
||||
|| readback.format.component_type == 0U
|
||||
|| readback.format.bytes_per_pixel == 0U
|
||||
|| readback.pixels == nullptr) {
|
||||
return pp::foundation::Status::invalid_argument("OpenGL framebuffer readback parameters are invalid");
|
||||
}
|
||||
|
||||
std::int32_t previous_read_framebuffer = 0;
|
||||
dispatch.get_integer(read_framebuffer_binding_query(), &previous_read_framebuffer);
|
||||
dispatch.bind_framebuffer(read_framebuffer_target(), readback.framebuffer);
|
||||
dispatch.read_pixels(
|
||||
readback.x,
|
||||
readback.y,
|
||||
readback.width,
|
||||
readback.height,
|
||||
readback.format.pixel_format,
|
||||
readback.format.component_type,
|
||||
readback.pixels);
|
||||
dispatch.bind_framebuffer(read_framebuffer_target(), static_cast<std::uint32_t>(previous_read_framebuffer));
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
std::uint32_t extension_count_query() noexcept
|
||||
{
|
||||
return gl_num_extensions;
|
||||
|
||||
Reference in New Issue
Block a user