Move framebuffer blit mapping to renderer gl
This commit is contained in:
@@ -131,10 +131,12 @@ Known local toolchain state:
|
||||
validates image channel-count to OpenGL texture format mapping, including
|
||||
invalid channel counts rejected by `Texture2D::create(Image)`, and
|
||||
framebuffer status naming used by `RTT` diagnostics. It also owns and
|
||||
validates the default linear clamp-to-edge render-target texture parameters
|
||||
used by `RTT::create`. It also validates Shape index-type and fill/stroke
|
||||
primitive-mode mapping used by the legacy mesh draw path, plus the
|
||||
PanoPainter cube-face to OpenGL texture-target mapping used by `TextureCube`.
|
||||
validates framebuffer blit color mask and linear/nearest filters used by
|
||||
`RTT::resize` and `RTT::copy`, plus the default linear clamp-to-edge
|
||||
render-target texture parameters used by `RTT::create`. It also validates
|
||||
Shape index-type and fill/stroke primitive-mode mapping used by the legacy
|
||||
mesh draw path, plus the PanoPainter cube-face to OpenGL texture-target
|
||||
mapping used by `TextureCube`.
|
||||
It also owns and validates sampler wrap S/T/R, min/mag filter, and desktop
|
||||
border-color parameter mapping used by legacy `Sampler`. The PanoPainter
|
||||
shader attribute binding catalog used by legacy `Shader` creation also lives
|
||||
|
||||
@@ -390,15 +390,17 @@ OpenGL capability detection for framebuffer fetch, map-buffer alignment, and
|
||||
float texture support. It also owns the OpenGL texture upload-type mapping used
|
||||
by legacy `Texture2D` and `RTT` creation, plus image channel-count to texture
|
||||
format mapping for `Texture2D` image uploads and framebuffer status naming for
|
||||
`RTT` diagnostics. The default render-target texture parameters used by
|
||||
`RTT::create` also live in `pp_renderer_gl`. Mesh index-type and primitive-mode
|
||||
`RTT` diagnostics. The framebuffer blit color mask and linear/nearest filter
|
||||
tokens used by `RTT::resize` and `RTT::copy`, plus the default render-target
|
||||
texture parameters used by `RTT::create`, also live in `pp_renderer_gl`.
|
||||
Mesh index-type and primitive-mode
|
||||
decisions used by legacy `Shape` drawing and the PanoPainter cube-face to
|
||||
OpenGL texture-target mapping used by `TextureCube` also live in
|
||||
`pp_renderer_gl`. The legacy app delegates extension, upload-format,
|
||||
framebuffer diagnostic, render-target texture parameter, mesh draw-mode, and
|
||||
cube-face texture-target interpretation to that backend library. Sampler wrap,
|
||||
min/mag filter, and desktop border-color parameter mapping for legacy
|
||||
`Sampler` also lives in `pp_renderer_gl`. The PanoPainter shader attribute
|
||||
framebuffer diagnostic, framebuffer blit, render-target texture parameter,
|
||||
mesh draw-mode, and cube-face texture-target interpretation to that backend
|
||||
library. Sampler wrap, min/mag filter, and desktop border-color parameter
|
||||
mapping for legacy `Sampler` also lives in `pp_renderer_gl`. The PanoPainter shader attribute
|
||||
binding catalog also lives in `pp_renderer_gl` and is consumed by legacy
|
||||
`Shader` creation. Shader uniform hashing, catalog validation, active-uniform
|
||||
mapping, and the legacy uniform uniqueness check now delegate to
|
||||
@@ -644,9 +646,10 @@ Results:
|
||||
alignment, desktop GL core float support, GLES float/half-float extensions,
|
||||
WebGL exclusion behavior, upload types for RGBA8/RGBA16F/RGBA32F internal
|
||||
formats, image channel-count format mapping including invalid counts, and
|
||||
framebuffer status names, plus Shape index-type and fill/stroke primitive
|
||||
mode mapping, PanoPainter cube-face texture-target order, and the linear
|
||||
clamp-to-edge render-target texture parameter set used by `RTT::create`.
|
||||
framebuffer status names, framebuffer blit color mask and linear/nearest
|
||||
filters, plus Shape index-type and fill/stroke primitive mode mapping,
|
||||
PanoPainter cube-face texture-target order, and the linear clamp-to-edge
|
||||
render-target texture parameter set used by `RTT::create`.
|
||||
Sampler parameter validation covers wrap S/T/R plus min/mag filter ordering
|
||||
used by legacy `Sampler::set` and `Sampler::set_filter`, plus the desktop
|
||||
border-color parameter name used by `Sampler::set_border`.
|
||||
|
||||
@@ -32,6 +32,7 @@ constexpr std::uint32_t gl_framebuffer_incomplete_read_buffer = 0x8CDCU;
|
||||
constexpr std::uint32_t gl_framebuffer_unsupported = 0x8CDDU;
|
||||
constexpr std::uint32_t gl_framebuffer_undefined = 0x8219U;
|
||||
constexpr std::uint32_t gl_framebuffer_incomplete_multisample = 0x8D56U;
|
||||
constexpr std::uint32_t gl_color_buffer_bit = 0x00004000U;
|
||||
constexpr std::uint32_t gl_texture_cube_map_positive_x = 0x8515U;
|
||||
constexpr std::uint32_t gl_texture_cube_map_negative_x = 0x8516U;
|
||||
constexpr std::uint32_t gl_texture_cube_map_positive_y = 0x8517U;
|
||||
@@ -39,6 +40,7 @@ constexpr std::uint32_t gl_texture_cube_map_negative_y = 0x8518U;
|
||||
constexpr std::uint32_t gl_texture_cube_map_positive_z = 0x8519U;
|
||||
constexpr std::uint32_t gl_texture_cube_map_negative_z = 0x851AU;
|
||||
constexpr std::uint32_t gl_linear = 0x2601U;
|
||||
constexpr std::uint32_t gl_nearest = 0x2600U;
|
||||
constexpr std::uint32_t gl_texture_mag_filter = 0x2800U;
|
||||
constexpr std::uint32_t gl_texture_min_filter = 0x2801U;
|
||||
constexpr std::uint32_t gl_texture_wrap_s = 0x2802U;
|
||||
@@ -145,6 +147,16 @@ const char* framebuffer_status_name(std::uint32_t status) noexcept
|
||||
}
|
||||
}
|
||||
|
||||
std::uint32_t framebuffer_color_buffer_mask() noexcept
|
||||
{
|
||||
return gl_color_buffer_bit;
|
||||
}
|
||||
|
||||
std::uint32_t framebuffer_blit_filter(bool linear) noexcept
|
||||
{
|
||||
return linear ? gl_linear : gl_nearest;
|
||||
}
|
||||
|
||||
std::uint32_t index_type_for_index_size(std::uint32_t index_size_bytes) noexcept
|
||||
{
|
||||
switch (index_size_bytes) {
|
||||
|
||||
@@ -39,6 +39,8 @@ struct OpenGlTextureParameter {
|
||||
[[nodiscard]] std::uint32_t texture_upload_type_for_internal_format(std::uint32_t internal_format) noexcept;
|
||||
[[nodiscard]] OpenGlPixelFormat texture_format_for_channel_count(std::uint32_t channel_count) noexcept;
|
||||
[[nodiscard]] const char* framebuffer_status_name(std::uint32_t status) noexcept;
|
||||
[[nodiscard]] std::uint32_t framebuffer_color_buffer_mask() noexcept;
|
||||
[[nodiscard]] std::uint32_t framebuffer_blit_filter(bool linear) noexcept;
|
||||
[[nodiscard]] std::uint32_t index_type_for_index_size(std::uint32_t index_size_bytes) noexcept;
|
||||
[[nodiscard]] std::uint32_t primitive_mode_for_fill_count(std::uint32_t vertex_or_index_count) noexcept;
|
||||
[[nodiscard]] std::uint32_t primitive_mode_for_stroke_count(std::uint32_t vertex_or_index_count) noexcept;
|
||||
|
||||
18
src/rtt.cpp
18
src/rtt.cpp
@@ -85,7 +85,17 @@ bool RTT::resize(int width, int height)
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, new_rtt.fboID);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, fboID);
|
||||
glBlitFramebuffer(0, 0, w, h, 0, 0, new_rtt.w, new_rtt.h, GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
glBlitFramebuffer(
|
||||
0,
|
||||
0,
|
||||
w,
|
||||
h,
|
||||
0,
|
||||
0,
|
||||
new_rtt.w,
|
||||
new_rtt.h,
|
||||
static_cast<GLbitfield>(pp::renderer::gl::framebuffer_color_buffer_mask()),
|
||||
static_cast<GLenum>(pp::renderer::gl::framebuffer_blit_filter(true)));
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, oldDFboID);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, oldRFboID);
|
||||
@@ -147,7 +157,8 @@ void RTT::copy(const RTT & source)
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fboID);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, source.fboID);
|
||||
glBlitFramebuffer(0, 0, source.w, source.h, 0, 0, w, h,
|
||||
GL_COLOR_BUFFER_BIT, GL_LINEAR);
|
||||
static_cast<GLbitfield>(pp::renderer::gl::framebuffer_color_buffer_mask()),
|
||||
static_cast<GLenum>(pp::renderer::gl::framebuffer_blit_filter(true)));
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, old_draw);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, old_read);
|
||||
@@ -170,7 +181,8 @@ void RTT::copy(const RTT& source, const glm::vec4& rect)
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, fboID);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, source.fboID);
|
||||
glBlitFramebuffer(r.x, r.y, r.z, r.w, r.x, r.y, r.z, r.w,
|
||||
GL_COLOR_BUFFER_BIT, GL_NEAREST);
|
||||
static_cast<GLbitfield>(pp::renderer::gl::framebuffer_color_buffer_mask()),
|
||||
static_cast<GLenum>(pp::renderer::gl::framebuffer_blit_filter(false)));
|
||||
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, old_draw);
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, old_read);
|
||||
|
||||
@@ -135,6 +135,13 @@ void names_framebuffer_status_codes(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, pp::renderer::gl::framebuffer_status_name(0U) == std::string_view("UNKNOWN"));
|
||||
}
|
||||
|
||||
void maps_framebuffer_blit_parameters(pp::tests::Harness& h)
|
||||
{
|
||||
PP_EXPECT(h, pp::renderer::gl::framebuffer_color_buffer_mask() == 0x00004000U);
|
||||
PP_EXPECT(h, pp::renderer::gl::framebuffer_blit_filter(true) == 0x2601U);
|
||||
PP_EXPECT(h, pp::renderer::gl::framebuffer_blit_filter(false) == 0x2600U);
|
||||
}
|
||||
|
||||
void maps_shape_index_and_primitive_modes(pp::tests::Harness& h)
|
||||
{
|
||||
constexpr std::uint32_t gl_points = 0x0000U;
|
||||
@@ -316,6 +323,7 @@ int main()
|
||||
harness.run("selects_texture_upload_type_from_internal_format", selects_texture_upload_type_from_internal_format);
|
||||
harness.run("maps_image_channel_count_to_texture_format", maps_image_channel_count_to_texture_format);
|
||||
harness.run("names_framebuffer_status_codes", names_framebuffer_status_codes);
|
||||
harness.run("maps_framebuffer_blit_parameters", maps_framebuffer_blit_parameters);
|
||||
harness.run("maps_shape_index_and_primitive_modes", maps_shape_index_and_primitive_modes);
|
||||
harness.run("maps_panopainter_cube_faces_to_texture_targets", maps_panopainter_cube_faces_to_texture_targets);
|
||||
harness.run("exposes_default_render_target_texture_parameters", exposes_default_render_target_texture_parameters);
|
||||
|
||||
Reference in New Issue
Block a user