Route framebuffer texture copies through GL backend
This commit is contained in:
@@ -748,6 +748,36 @@ pp::foundation::Status update_opengl_texture_2d(
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Status copy_opengl_framebuffer_to_texture_2d(
|
||||
OpenGlTexture2DFramebufferCopy copy,
|
||||
OpenGlTexture2DFramebufferCopyDispatch dispatch) noexcept
|
||||
{
|
||||
if (dispatch.copy_tex_sub_image_2d == nullptr) {
|
||||
return pp::foundation::Status::invalid_argument(
|
||||
"OpenGL framebuffer-to-texture copy dispatch callback must not be null");
|
||||
}
|
||||
|
||||
if (copy.width < 0 || copy.height < 0) {
|
||||
return pp::foundation::Status::invalid_argument(
|
||||
"OpenGL framebuffer-to-texture copy dimensions are invalid");
|
||||
}
|
||||
|
||||
if (copy.width == 0 || copy.height == 0) {
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
dispatch.copy_tex_sub_image_2d(
|
||||
texture_2d_target(),
|
||||
copy.level,
|
||||
copy.destination_x,
|
||||
copy.destination_y,
|
||||
copy.source_x,
|
||||
copy.source_y,
|
||||
copy.width,
|
||||
copy.height);
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Status generate_opengl_texture_2d_mipmaps(
|
||||
std::uint32_t texture_id,
|
||||
OpenGlTexture2DMipmapDispatch dispatch) noexcept
|
||||
|
||||
@@ -149,6 +149,16 @@ struct OpenGlTexture2DUpdate {
|
||||
const void* data = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlTexture2DFramebufferCopy {
|
||||
std::int32_t level = 0;
|
||||
std::int32_t destination_x = 0;
|
||||
std::int32_t destination_y = 0;
|
||||
std::int32_t source_x = 0;
|
||||
std::int32_t source_y = 0;
|
||||
std::int32_t width = 0;
|
||||
std::int32_t height = 0;
|
||||
};
|
||||
|
||||
struct OpenGlTexture2DReadback {
|
||||
std::uint32_t texture_id = 0;
|
||||
std::int32_t width = 0;
|
||||
@@ -426,6 +436,15 @@ using OpenGlTexSubImage2DFn = void (*)(
|
||||
std::uint32_t pixel_format,
|
||||
std::uint32_t component_type,
|
||||
const void* data) noexcept;
|
||||
using OpenGlCopyTexSubImage2DFn = void (*)(
|
||||
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;
|
||||
using OpenGlGenerateMipmapFn = void (*)(std::uint32_t target) noexcept;
|
||||
using OpenGlFramebufferTexture2DFn = void (*)(
|
||||
std::uint32_t target,
|
||||
@@ -582,6 +601,10 @@ struct OpenGlTexture2DUpdateDispatch {
|
||||
OpenGlTexSubImage2DFn tex_sub_image_2d = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlTexture2DFramebufferCopyDispatch {
|
||||
OpenGlCopyTexSubImage2DFn copy_tex_sub_image_2d = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlTexture2DMipmapDispatch {
|
||||
OpenGlBindTextureFn bind_texture = nullptr;
|
||||
OpenGlGenerateMipmapFn generate_mipmap = nullptr;
|
||||
@@ -820,6 +843,9 @@ struct OpenGlMeshDeleteDispatch {
|
||||
[[nodiscard]] pp::foundation::Status update_opengl_texture_2d(
|
||||
OpenGlTexture2DUpdate update,
|
||||
OpenGlTexture2DUpdateDispatch dispatch) noexcept;
|
||||
[[nodiscard]] pp::foundation::Status copy_opengl_framebuffer_to_texture_2d(
|
||||
OpenGlTexture2DFramebufferCopy copy,
|
||||
OpenGlTexture2DFramebufferCopyDispatch dispatch) noexcept;
|
||||
[[nodiscard]] pp::foundation::Status generate_opengl_texture_2d_mipmaps(
|
||||
std::uint32_t texture_id,
|
||||
OpenGlTexture2DMipmapDispatch dispatch) noexcept;
|
||||
|
||||
Reference in New Issue
Block a user