Move render target clear mapping to renderer gl
This commit is contained in:
@@ -127,8 +127,9 @@ Known local toolchain state:
|
||||
by the legacy app initialization path; `pp_renderer_gl_capabilities_tests`
|
||||
validates framebuffer fetch, map-buffer alignment, desktop GL float support,
|
||||
GLES float/half-float extensions, WebGL exclusion behavior, and the
|
||||
upload-type mapping used by legacy `Texture2D` and `RTT` creation. It also
|
||||
validates image channel-count to OpenGL texture format mapping, including
|
||||
upload-type mapping used by legacy `Texture2D` and `RTT` creation, plus the
|
||||
RGBA pixel-format mapping used by `RTT` texture allocation. It also validates
|
||||
image channel-count to OpenGL texture format mapping, including
|
||||
invalid channel counts rejected by `Texture2D::create(Image)`, RGBA8/RGBA32F
|
||||
readback formats, byte-count math, and PBO pixel-buffer target/usage/access
|
||||
mapping used by `RTT` and `PBO` readbacks, and framebuffer status naming
|
||||
@@ -137,7 +138,9 @@ Known local toolchain state:
|
||||
`RTT::resize` and `RTT::copy`, plus the default linear clamp-to-edge
|
||||
render-target texture parameters, texture/renderbuffer targets, depth format,
|
||||
framebuffer targets, binding queries, attachment points, and completion
|
||||
status used by `RTT::create` and framebuffer bind/restore paths. It also
|
||||
status used by `RTT::create` and framebuffer bind/restore paths, plus RTT
|
||||
clear color/depth masks and color-write-mask query tokens. `RTT` no longer
|
||||
spells GL enum names directly. 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`.
|
||||
|
||||
@@ -388,7 +388,8 @@ catalog now consumed by the legacy OpenGL app initialization path.
|
||||
`pp_renderer_gl` now exists as the first OpenGL backend library and owns pure
|
||||
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
|
||||
by legacy `Texture2D` and `RTT` creation, RGBA pixel-format mapping used by
|
||||
`RTT` texture allocation, plus image channel-count to texture
|
||||
format mapping for `Texture2D` image uploads and framebuffer status naming for
|
||||
`RTT` diagnostics. RGBA8/RGBA32F readback formats, byte-count math, and PBO
|
||||
pixel-buffer target/usage/access tokens used by `RTT` and `PBO` readbacks now
|
||||
@@ -397,14 +398,15 @@ filter tokens used by `RTT::resize` and `RTT::copy`, plus the default
|
||||
render-target texture parameters, texture/renderbuffer targets, depth format,
|
||||
framebuffer targets, binding queries, attachment points, and completion status
|
||||
used by `RTT::create` and framebuffer bind/restore paths, also live in
|
||||
`pp_renderer_gl`.
|
||||
`pp_renderer_gl`. RTT clear color/depth masks and color-write-mask query tokens
|
||||
also live in `pp_renderer_gl`. `RTT` no longer spells GL enum names directly.
|
||||
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, framebuffer blit, render-target setup, mesh draw-mode,
|
||||
and cube-face texture-target interpretation to that backend library. Sampler
|
||||
wrap, min/mag filter, and desktop border-color parameter
|
||||
framebuffer diagnostic, framebuffer blit, render-target setup, clear-state,
|
||||
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
|
||||
|
||||
@@ -43,6 +43,8 @@ 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_depth_buffer_bit = 0x00000100U;
|
||||
constexpr std::uint32_t gl_color_writemask = 0x0C23U;
|
||||
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;
|
||||
@@ -121,6 +123,11 @@ std::uint32_t texture_upload_type_for_internal_format(std::uint32_t internal_for
|
||||
}
|
||||
}
|
||||
|
||||
std::uint32_t rgba_pixel_format() noexcept
|
||||
{
|
||||
return gl_rgba;
|
||||
}
|
||||
|
||||
OpenGlPixelFormat texture_format_for_channel_count(std::uint32_t channel_count) noexcept
|
||||
{
|
||||
switch (channel_count) {
|
||||
@@ -267,6 +274,16 @@ std::uint32_t framebuffer_color_buffer_mask() noexcept
|
||||
return gl_color_buffer_bit;
|
||||
}
|
||||
|
||||
std::uint32_t framebuffer_depth_buffer_mask() noexcept
|
||||
{
|
||||
return gl_depth_buffer_bit;
|
||||
}
|
||||
|
||||
std::uint32_t color_write_mask_query() noexcept
|
||||
{
|
||||
return gl_color_writemask;
|
||||
}
|
||||
|
||||
std::uint32_t framebuffer_blit_filter(bool linear) noexcept
|
||||
{
|
||||
return linear ? gl_linear : gl_nearest;
|
||||
|
||||
@@ -43,6 +43,7 @@ struct OpenGlReadbackFormat {
|
||||
OpenGlRuntime runtime) noexcept;
|
||||
|
||||
[[nodiscard]] std::uint32_t texture_upload_type_for_internal_format(std::uint32_t internal_format) noexcept;
|
||||
[[nodiscard]] std::uint32_t rgba_pixel_format() noexcept;
|
||||
[[nodiscard]] OpenGlPixelFormat texture_format_for_channel_count(std::uint32_t channel_count) noexcept;
|
||||
[[nodiscard]] OpenGlReadbackFormat rgba8_readback_format() noexcept;
|
||||
[[nodiscard]] OpenGlReadbackFormat rgba32f_readback_format() noexcept;
|
||||
@@ -67,6 +68,8 @@ struct OpenGlReadbackFormat {
|
||||
[[nodiscard]] std::uint32_t framebuffer_complete_status() 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_depth_buffer_mask() noexcept;
|
||||
[[nodiscard]] std::uint32_t color_write_mask_query() 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;
|
||||
|
||||
19
src/rtt.cpp
19
src/rtt.cpp
@@ -263,7 +263,16 @@ bool RTT::create(int width, int height, int tex/* = -1*/, GLint internal_format,
|
||||
|
||||
glBindTexture(texture_2d_target(), texID);
|
||||
if (tex == -1)
|
||||
glTexImage2D(texture_2d_target(), 0, internal_format, width, height, 0, GL_RGBA, ifmt, 0);
|
||||
glTexImage2D(
|
||||
texture_2d_target(),
|
||||
0,
|
||||
internal_format,
|
||||
width,
|
||||
height,
|
||||
0,
|
||||
static_cast<GLenum>(pp::renderer::gl::rgba_pixel_format()),
|
||||
ifmt,
|
||||
0);
|
||||
for (const auto parameter : pp::renderer::gl::default_render_target_texture_parameters())
|
||||
{
|
||||
glTexParameterf(
|
||||
@@ -361,7 +370,9 @@ void RTT::clear(glm::vec4 color)
|
||||
{
|
||||
assert(App::I->is_render_thread());
|
||||
glClearColor(color.r, color.g, color.b, color.a);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glClear(static_cast<GLbitfield>(
|
||||
pp::renderer::gl::framebuffer_color_buffer_mask()
|
||||
| pp::renderer::gl::framebuffer_depth_buffer_mask()));
|
||||
}
|
||||
|
||||
void RTT::clear_mask(glm::bool4 mask, glm::vec4 color)
|
||||
@@ -369,12 +380,12 @@ void RTT::clear_mask(glm::bool4 mask, glm::vec4 color)
|
||||
assert(App::I->is_render_thread());
|
||||
// save old state
|
||||
std::array<GLboolean, 4> old_mask;
|
||||
glGetBooleanv(GL_COLOR_WRITEMASK, old_mask.data());
|
||||
glGetBooleanv(static_cast<GLenum>(pp::renderer::gl::color_write_mask_query()), old_mask.data());
|
||||
|
||||
// clear with mask
|
||||
glColorMask(mask.r, mask.g, mask.b, mask.a);
|
||||
glClearColor(color.r, color.g, color.b, color.a);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glClear(static_cast<GLbitfield>(pp::renderer::gl::framebuffer_color_buffer_mask()));
|
||||
|
||||
// restore old state
|
||||
glColorMask(old_mask[0], old_mask[1], old_mask[2], old_mask[3]);
|
||||
|
||||
@@ -84,6 +84,7 @@ void selects_texture_upload_type_from_internal_format(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, pp::renderer::gl::texture_upload_type_for_internal_format(gl_rgba32f) == gl_float);
|
||||
PP_EXPECT(h, pp::renderer::gl::texture_upload_type_for_internal_format(gl_rgba16f) == gl_half_float);
|
||||
PP_EXPECT(h, pp::renderer::gl::texture_upload_type_for_internal_format(0U) == gl_unsigned_byte);
|
||||
PP_EXPECT(h, pp::renderer::gl::rgba_pixel_format() == 0x1908U);
|
||||
}
|
||||
|
||||
void maps_image_channel_count_to_texture_format(pp::tests::Harness& h)
|
||||
@@ -177,6 +178,8 @@ void maps_framebuffer_render_target_parameters(pp::tests::Harness& h)
|
||||
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_depth_buffer_mask() == 0x00000100U);
|
||||
PP_EXPECT(h, pp::renderer::gl::color_write_mask_query() == 0x0C23U);
|
||||
PP_EXPECT(h, pp::renderer::gl::framebuffer_blit_filter(true) == 0x2601U);
|
||||
PP_EXPECT(h, pp::renderer::gl::framebuffer_blit_filter(false) == 0x2600U);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user