Move canvas depth renderbuffers into GL backend
This commit is contained in:
@@ -939,6 +939,70 @@ pp::foundation::Status restore_opengl_framebuffer_binding(
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Result<std::uint32_t> allocate_opengl_depth_renderbuffer(
|
||||
std::int32_t width,
|
||||
std::int32_t height,
|
||||
OpenGlDepthRenderbufferAllocationDispatch dispatch) noexcept
|
||||
{
|
||||
if (dispatch.gen_renderbuffers == nullptr
|
||||
|| dispatch.bind_renderbuffer == nullptr
|
||||
|| dispatch.renderbuffer_storage == nullptr) {
|
||||
return pp::foundation::Result<std::uint32_t>::failure(
|
||||
pp::foundation::Status::invalid_argument(
|
||||
"OpenGL depth renderbuffer allocation dispatch callbacks must not be null"));
|
||||
}
|
||||
|
||||
if (width <= 0 || height <= 0) {
|
||||
return pp::foundation::Result<std::uint32_t>::failure(
|
||||
pp::foundation::Status::invalid_argument("OpenGL depth renderbuffer dimensions are invalid"));
|
||||
}
|
||||
|
||||
std::uint32_t renderbuffer_id = 0U;
|
||||
dispatch.gen_renderbuffers(1U, &renderbuffer_id);
|
||||
if (renderbuffer_id == 0U) {
|
||||
return pp::foundation::Result<std::uint32_t>::failure(
|
||||
pp::foundation::Status::out_of_range("OpenGL renderbuffer allocation returned id 0"));
|
||||
}
|
||||
|
||||
dispatch.bind_renderbuffer(renderbuffer_target(), renderbuffer_id);
|
||||
dispatch.renderbuffer_storage(renderbuffer_target(), depth_component24_format(), width, height);
|
||||
dispatch.bind_renderbuffer(renderbuffer_target(), default_framebuffer_id());
|
||||
return pp::foundation::Result<std::uint32_t>::success(renderbuffer_id);
|
||||
}
|
||||
|
||||
pp::foundation::Status delete_opengl_renderbuffer(
|
||||
std::uint32_t renderbuffer_id,
|
||||
OpenGlRenderbufferDeleteDispatch dispatch) noexcept
|
||||
{
|
||||
if (dispatch.delete_renderbuffers == nullptr) {
|
||||
return pp::foundation::Status::invalid_argument("OpenGL renderbuffer delete callback must not be null");
|
||||
}
|
||||
|
||||
if (renderbuffer_id == 0U) {
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
dispatch.delete_renderbuffers(1U, &renderbuffer_id);
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Status attach_opengl_depth_renderbuffer(
|
||||
std::uint32_t renderbuffer_id,
|
||||
OpenGlDepthRenderbufferAttachmentDispatch dispatch) noexcept
|
||||
{
|
||||
if (dispatch.framebuffer_renderbuffer == nullptr) {
|
||||
return pp::foundation::Status::invalid_argument(
|
||||
"OpenGL depth renderbuffer attachment callback must not be null");
|
||||
}
|
||||
|
||||
dispatch.framebuffer_renderbuffer(
|
||||
framebuffer_target(),
|
||||
framebuffer_depth_attachment(),
|
||||
renderbuffer_target(),
|
||||
renderbuffer_id);
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
pp::foundation::Result<std::uint32_t> create_opengl_sampler(
|
||||
std::span<const OpenGlTextureParameter> parameters,
|
||||
OpenGlSamplerCreateDispatch dispatch) noexcept
|
||||
|
||||
@@ -364,8 +364,14 @@ using OpenGlGetActiveUniformFn = void (*)(
|
||||
char* name) noexcept;
|
||||
using OpenGlGetUniformLocationFn = std::int32_t (*)(std::uint32_t program, const char* name) noexcept;
|
||||
using OpenGlBindFramebufferFn = void (*)(std::uint32_t target, std::uint32_t framebuffer) noexcept;
|
||||
using OpenGlBindRenderbufferFn = void (*)(std::uint32_t target, std::uint32_t renderbuffer) noexcept;
|
||||
using OpenGlBindTextureFn = void (*)(std::uint32_t target, std::uint32_t texture) noexcept;
|
||||
using OpenGlBindSamplerFn = void (*)(std::uint32_t unit, std::uint32_t sampler) noexcept;
|
||||
using OpenGlRenderbufferStorageFn = void (*)(
|
||||
std::uint32_t target,
|
||||
std::uint32_t internal_format,
|
||||
std::int32_t width,
|
||||
std::int32_t height) noexcept;
|
||||
using OpenGlSamplerParameteriFn = void (*)(
|
||||
std::uint32_t sampler,
|
||||
std::uint32_t parameter,
|
||||
@@ -427,6 +433,11 @@ using OpenGlFramebufferTexture2DFn = void (*)(
|
||||
std::uint32_t texture_target,
|
||||
std::uint32_t texture,
|
||||
std::int32_t level) noexcept;
|
||||
using OpenGlFramebufferRenderbufferFn = void (*)(
|
||||
std::uint32_t target,
|
||||
std::uint32_t attachment,
|
||||
std::uint32_t renderbuffer_target,
|
||||
std::uint32_t renderbuffer) noexcept;
|
||||
using OpenGlCheckFramebufferStatusFn = std::uint32_t (*)(std::uint32_t target) noexcept;
|
||||
using OpenGlReadPixelsFn = void (*)(
|
||||
std::int32_t x,
|
||||
@@ -608,6 +619,20 @@ struct OpenGlFramebufferRestoreDispatch {
|
||||
OpenGlBindFramebufferFn bind_framebuffer = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlDepthRenderbufferAllocationDispatch {
|
||||
OpenGlGenObjectsFn gen_renderbuffers = nullptr;
|
||||
OpenGlBindRenderbufferFn bind_renderbuffer = nullptr;
|
||||
OpenGlRenderbufferStorageFn renderbuffer_storage = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlRenderbufferDeleteDispatch {
|
||||
OpenGlDeleteObjectsFn delete_renderbuffers = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlDepthRenderbufferAttachmentDispatch {
|
||||
OpenGlFramebufferRenderbufferFn framebuffer_renderbuffer = nullptr;
|
||||
};
|
||||
|
||||
struct OpenGlSamplerCreateDispatch {
|
||||
OpenGlGenObjectsFn gen_samplers = nullptr;
|
||||
OpenGlSamplerParameteriFn sampler_parameter_i = nullptr;
|
||||
@@ -813,6 +838,16 @@ struct OpenGlMeshDeleteDispatch {
|
||||
[[nodiscard]] pp::foundation::Status restore_opengl_framebuffer_binding(
|
||||
OpenGlFramebufferBindingState binding,
|
||||
OpenGlFramebufferRestoreDispatch dispatch) noexcept;
|
||||
[[nodiscard]] pp::foundation::Result<std::uint32_t> allocate_opengl_depth_renderbuffer(
|
||||
std::int32_t width,
|
||||
std::int32_t height,
|
||||
OpenGlDepthRenderbufferAllocationDispatch dispatch) noexcept;
|
||||
[[nodiscard]] pp::foundation::Status delete_opengl_renderbuffer(
|
||||
std::uint32_t renderbuffer_id,
|
||||
OpenGlRenderbufferDeleteDispatch dispatch) noexcept;
|
||||
[[nodiscard]] pp::foundation::Status attach_opengl_depth_renderbuffer(
|
||||
std::uint32_t renderbuffer_id,
|
||||
OpenGlDepthRenderbufferAttachmentDispatch dispatch) noexcept;
|
||||
[[nodiscard]] pp::foundation::Result<std::uint32_t> create_opengl_sampler(
|
||||
std::span<const OpenGlTextureParameter> parameters,
|
||||
OpenGlSamplerCreateDispatch dispatch) noexcept;
|
||||
|
||||
Reference in New Issue
Block a user