Share target-aware framebuffer copy bridge

This commit is contained in:
2026-06-05 14:07:46 +02:00
parent 2641db35ac
commit 65bf047d77
6 changed files with 69 additions and 55 deletions

View File

@@ -13,27 +13,6 @@ uint32_t Layer::s_count = 0;
namespace {
void copy_opengl_tex_sub_image_2d(
std::uint32_t target,
std::int32_t level,
std::int32_t destination_x,
std::int32_t destination_y,
std::int32_t source_x,
std::int32_t source_y,
std::int32_t width,
std::int32_t height) noexcept
{
glCopyTexSubImage2D(
static_cast<GLenum>(target),
static_cast<GLint>(level),
static_cast<GLint>(destination_x),
static_cast<GLint>(destination_y),
static_cast<GLint>(source_x),
static_cast<GLint>(source_y),
static_cast<GLsizei>(width),
static_cast<GLsizei>(height));
}
void apply_layer_viewport(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height)
{
pp::legacy::ui_gl::apply_viewport(x, y, width, height, "Layer");
@@ -63,21 +42,14 @@ void copy_layer_framebuffer_to_texture(
std::int32_t width,
std::int32_t height)
{
const auto status = pp::renderer::gl::copy_opengl_framebuffer_to_texture_2d(
pp::renderer::gl::OpenGlTexture2DFramebufferCopy {
.texture_target = texture_target,
.destination_x = destination_x,
.destination_y = destination_y,
.source_x = source_x,
.source_y = source_y,
.width = width,
.height = height,
},
pp::renderer::gl::OpenGlTexture2DFramebufferCopyDispatch {
.copy_tex_sub_image_2d = copy_opengl_tex_sub_image_2d,
});
if (!status.ok())
LOG("Layer framebuffer-to-texture copy dispatch failed because: %s", status.message);
copy_framebuffer_to_texture_target(
texture_target,
destination_x,
destination_y,
source_x,
source_y,
width,
height);
}
void clear_layer_color_buffer(const glm::vec4& color)

View File

@@ -740,7 +740,8 @@ void check_OpenGLError(const char* stmt, const char* fname, int line)
}
}
bool copy_framebuffer_to_texture_2d(
bool copy_framebuffer_to_texture_target(
uint32_t texture_target,
int destination_x,
int destination_y,
int source_x,
@@ -751,6 +752,7 @@ bool copy_framebuffer_to_texture_2d(
{
const auto status = pp::renderer::gl::copy_opengl_framebuffer_to_texture_2d(
pp::renderer::gl::OpenGlTexture2DFramebufferCopy {
.texture_target = texture_target,
.level = level,
.destination_x = destination_x,
.destination_y = destination_y,
@@ -769,6 +771,26 @@ bool copy_framebuffer_to_texture_2d(
return true;
}
bool copy_framebuffer_to_texture_2d(
int destination_x,
int destination_y,
int source_x,
int source_y,
int width,
int height,
int level) noexcept
{
return copy_framebuffer_to_texture_target(
pp::renderer::gl::texture_2d_target(),
destination_x,
destination_y,
source_x,
source_y,
width,
height,
level);
}
size_t curl_data_handler(void *contents, size_t size, size_t nmemb, void *userp)
{
auto buffer = reinterpret_cast<std::string*>(userp);

View File

@@ -201,6 +201,15 @@ std::string str_replace(const std::string& string, const std::string& search, co
size_t curl_data_handler(void *contents, size_t size, size_t nmemb, void *userp);
size_t curl_data_write(void *ptr, size_t size, size_t nmemb, FILE *stream);
void check_OpenGLError(const char* stmt, const char* fname, int line);
bool copy_framebuffer_to_texture_target(
uint32_t texture_target,
int destination_x,
int destination_y,
int source_x,
int source_y,
int width,
int height,
int level = 0) noexcept;
bool copy_framebuffer_to_texture_2d(
int destination_x,
int destination_y,