Share retained sampler and pixel-buffer dispatch bridges
This commit is contained in:
90
src/rtt.cpp
90
src/rtt.cpp
@@ -4,6 +4,7 @@
|
||||
#include "util.h"
|
||||
#include "app.h"
|
||||
#include "legacy_gl_framebuffer_dispatch.h"
|
||||
#include "legacy_gl_pixel_buffer_dispatch.h"
|
||||
#include "legacy_gl_renderbuffer_dispatch.h"
|
||||
#include "legacy_gl_texture_dispatch.h"
|
||||
#include "renderer_gl/opengl_capabilities.h"
|
||||
@@ -32,52 +33,6 @@ void set_opengl_color_mask(std::uint8_t r, std::uint8_t g, std::uint8_t b, std::
|
||||
glColorMask(r, g, b, a);
|
||||
}
|
||||
|
||||
void gen_opengl_buffers(std::uint32_t count, std::uint32_t* ids) noexcept
|
||||
{
|
||||
glGenBuffers(static_cast<GLsizei>(count), reinterpret_cast<GLuint*>(ids));
|
||||
}
|
||||
|
||||
void delete_opengl_buffers(std::uint32_t count, const std::uint32_t* ids) noexcept
|
||||
{
|
||||
glDeleteBuffers(static_cast<GLsizei>(count), reinterpret_cast<const GLuint*>(ids));
|
||||
}
|
||||
|
||||
void bind_opengl_buffer(std::uint32_t target, std::uint32_t buffer) noexcept
|
||||
{
|
||||
glBindBuffer(static_cast<GLenum>(target), static_cast<GLuint>(buffer));
|
||||
}
|
||||
|
||||
void set_opengl_buffer_data(
|
||||
std::uint32_t target,
|
||||
std::intptr_t byte_count,
|
||||
const void* data,
|
||||
std::uint32_t usage) noexcept
|
||||
{
|
||||
glBufferData(
|
||||
static_cast<GLenum>(target),
|
||||
static_cast<GLsizeiptr>(byte_count),
|
||||
data,
|
||||
static_cast<GLenum>(usage));
|
||||
}
|
||||
|
||||
void* map_opengl_buffer_range(
|
||||
std::uint32_t target,
|
||||
std::intptr_t offset,
|
||||
std::intptr_t byte_count,
|
||||
std::uint32_t access) noexcept
|
||||
{
|
||||
return glMapBufferRange(
|
||||
static_cast<GLenum>(target),
|
||||
static_cast<GLintptr>(offset),
|
||||
static_cast<GLsizeiptr>(byte_count),
|
||||
static_cast<GLbitfield>(access));
|
||||
}
|
||||
|
||||
void unmap_opengl_buffer(std::uint32_t target) noexcept
|
||||
{
|
||||
glUnmapBuffer(static_cast<GLenum>(target));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RTT& RTT::operator=(RTT&& other)
|
||||
@@ -686,9 +641,7 @@ bool PBO::create() noexcept
|
||||
{
|
||||
App::I->render_task([this] {
|
||||
const auto result = pp::renderer::gl::allocate_opengl_pixel_buffer(
|
||||
pp::renderer::gl::OpenGlPixelBufferAllocationDispatch {
|
||||
.gen_buffers = gen_opengl_buffers,
|
||||
});
|
||||
pp::legacy::gl_pixel_buffer::pixel_buffer_allocation_dispatch());
|
||||
if (!result.ok()) {
|
||||
LOG("%s", result.status().message);
|
||||
buffer_id = 0U;
|
||||
@@ -709,12 +662,7 @@ bool PBO::create(RTT& rtt) noexcept
|
||||
width,
|
||||
height,
|
||||
pp::renderer::gl::rgba8_readback_format(),
|
||||
pp::renderer::gl::OpenGlPixelBufferReadbackDispatch {
|
||||
.gen_buffers = gen_opengl_buffers,
|
||||
.bind_buffer = bind_opengl_buffer,
|
||||
.buffer_data = set_opengl_buffer_data,
|
||||
.read_pixels = pp::legacy::gl_framebuffer::read_opengl_pixels,
|
||||
});
|
||||
pp::legacy::gl_pixel_buffer::pixel_buffer_readback_dispatch());
|
||||
rtt.unbindFramebuffer();
|
||||
if (!result.ok()) {
|
||||
LOG("%s", result.status().message);
|
||||
@@ -733,9 +681,7 @@ void PBO::destroy() noexcept
|
||||
App::I->render_task_async([id=buffer_id] {
|
||||
const auto status = pp::renderer::gl::delete_opengl_pixel_buffer(
|
||||
id,
|
||||
pp::renderer::gl::OpenGlPixelBufferDeleteDispatch {
|
||||
.delete_buffers = delete_opengl_buffers,
|
||||
});
|
||||
pp::legacy::gl_pixel_buffer::pixel_buffer_delete_dispatch());
|
||||
if (!status.ok()) {
|
||||
LOG("%s", status.message);
|
||||
}
|
||||
@@ -748,24 +694,6 @@ void PBO::destroy() noexcept
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void PBO::bind_read() noexcept
|
||||
{
|
||||
App::I->render_task([this] {
|
||||
const auto buffer_target = static_cast<GLenum>(pp::renderer::gl::pixel_unpack_buffer_target());
|
||||
glBindBuffer(buffer_target, buffer_id);
|
||||
bound_slot = buffer_target;
|
||||
});
|
||||
}
|
||||
|
||||
void PBO::unbind() noexcept
|
||||
{
|
||||
App::I->render_task([this] {
|
||||
glBindBuffer(bound_slot, buffer_id);
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
glm::uint8_t* PBO::map() noexcept
|
||||
{
|
||||
App::I->render_task([this] {
|
||||
@@ -774,10 +702,7 @@ glm::uint8_t* PBO::map() noexcept
|
||||
width,
|
||||
height,
|
||||
pp::renderer::gl::rgba8_readback_format(),
|
||||
pp::renderer::gl::OpenGlPixelBufferMapDispatch {
|
||||
.bind_buffer = bind_opengl_buffer,
|
||||
.map_buffer_range = map_opengl_buffer_range,
|
||||
});
|
||||
pp::legacy::gl_pixel_buffer::pixel_buffer_map_dispatch());
|
||||
if (!result.ok()) {
|
||||
LOG("%s", result.status().message);
|
||||
mapped_ptr = nullptr;
|
||||
@@ -793,10 +718,7 @@ void PBO::unmap() noexcept
|
||||
App::I->render_task([this] {
|
||||
const auto status = pp::renderer::gl::unmap_opengl_pixel_buffer(
|
||||
buffer_id,
|
||||
pp::renderer::gl::OpenGlPixelBufferUnmapDispatch {
|
||||
.bind_buffer = bind_opengl_buffer,
|
||||
.unmap_buffer = unmap_opengl_buffer,
|
||||
});
|
||||
pp::legacy::gl_pixel_buffer::pixel_buffer_unmap_dispatch());
|
||||
if (!status.ok()) {
|
||||
LOG("%s", status.message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user