Move image node state mapping to renderer gl
This commit is contained in:
@@ -171,6 +171,9 @@ Known local toolchain state:
|
||||
clear-color query, color-buffer clear mask, and blend-state tokens.
|
||||
`NodeImageTexture` preview drawing also consumes backend-owned fallback 2D
|
||||
texture bind and blend-state tokens.
|
||||
`NodeImage` drawing and remote-image texture creation also consume
|
||||
backend-owned mipmapped sampler filters, blend-state tokens, and RGBA8/RGBA
|
||||
texture format mapping.
|
||||
- `windows-msvc-vcpkg-headless` validates manifest install/configure/build/test
|
||||
for the current headless component matrix; see DEBT-0007 for remaining app
|
||||
and platform triplet migration.
|
||||
|
||||
@@ -438,6 +438,9 @@ clear-color query, color-buffer clear mask, and blend-state tokens to
|
||||
`pp_renderer_gl`.
|
||||
`NodeImageTexture` preview drawing now delegates its fallback 2D texture bind
|
||||
target and blend-state tokens to `pp_renderer_gl`.
|
||||
`NodeImage` drawing and remote-image texture creation now delegate mipmapped
|
||||
sampler filters, blend-state tokens, and RGBA8/RGBA texture format mapping to
|
||||
`pp_renderer_gl`.
|
||||
The existing renderer classes are not yet fully
|
||||
behind the renderer interfaces.
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "pch.h"
|
||||
#include "log.h"
|
||||
#include "node_image.h"
|
||||
#include "renderer_gl/opengl_capabilities.h"
|
||||
#include "shader.h"
|
||||
#include "app.h"
|
||||
|
||||
@@ -13,7 +14,9 @@ void NodeImage::static_init()
|
||||
m_plane.create<1>(1, 1);
|
||||
m_sampler.create();
|
||||
m_sampler_mips.create();
|
||||
m_sampler_mips.set_filter(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR);
|
||||
m_sampler_mips.set_filter(
|
||||
pp::renderer::gl::linear_mipmap_linear_texture_filter(),
|
||||
pp::renderer::gl::linear_texture_filter());
|
||||
}
|
||||
|
||||
Node* NodeImage::clone_instantiate() const
|
||||
@@ -99,7 +102,7 @@ void NodeImage::draw()
|
||||
auto& sampler = m_use_mipmaps ? m_sampler_mips : m_sampler;
|
||||
sampler.bind(0);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glEnable(pp::renderer::gl::blend_state());
|
||||
if (m_use_atlas)
|
||||
{
|
||||
ShaderManager::use(kShader::Atlas);
|
||||
@@ -114,7 +117,7 @@ void NodeImage::draw()
|
||||
ShaderManager::u_mat4(kShaderUniform::MVP, m_mvp * glm::scale(glm::vec3(m_scale, 1.f)));
|
||||
m_plane.draw_fill();
|
||||
sampler.unbind();
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(pp::renderer::gl::blend_state());
|
||||
}
|
||||
|
||||
bool NodeImage::set_image(const std::string& path)
|
||||
@@ -155,7 +158,12 @@ void NodeImage::load_url(const std::string& url)
|
||||
int w, h, c;
|
||||
uint8_t* rgba = stbi_load_from_memory(m_remote_asset->m_data, m_remote_asset->m_len, &w, &h, &c, 4);
|
||||
m_remote_texture = std::make_shared<Texture2D>();
|
||||
m_remote_texture->create(w, h, GL_RGBA8, GL_RGBA, rgba);
|
||||
m_remote_texture->create(
|
||||
w,
|
||||
h,
|
||||
pp::renderer::gl::rgba8_internal_format(),
|
||||
pp::renderer::gl::rgba_pixel_format(),
|
||||
rgba);
|
||||
if (m_use_mipmaps)
|
||||
m_remote_texture->create_mipmaps();
|
||||
delete rgba;
|
||||
|
||||
@@ -85,6 +85,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_linear_mipmap_linear = 0x2703U;
|
||||
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;
|
||||
@@ -548,6 +549,11 @@ std::uint32_t linear_texture_filter() noexcept
|
||||
return gl_linear;
|
||||
}
|
||||
|
||||
std::uint32_t linear_mipmap_linear_texture_filter() noexcept
|
||||
{
|
||||
return gl_linear_mipmap_linear;
|
||||
}
|
||||
|
||||
std::uint32_t nearest_texture_filter() noexcept
|
||||
{
|
||||
return gl_nearest;
|
||||
|
||||
@@ -112,6 +112,7 @@ struct OpenGlReadbackFormat {
|
||||
[[nodiscard]] std::uint32_t max_blend_equation() noexcept;
|
||||
[[nodiscard]] std::uint32_t rgba8_internal_format() noexcept;
|
||||
[[nodiscard]] std::uint32_t linear_texture_filter() noexcept;
|
||||
[[nodiscard]] std::uint32_t linear_mipmap_linear_texture_filter() noexcept;
|
||||
[[nodiscard]] std::uint32_t nearest_texture_filter() noexcept;
|
||||
[[nodiscard]] std::uint32_t repeat_texture_wrap() noexcept;
|
||||
[[nodiscard]] std::uint32_t active_texture_unit(std::uint32_t unit_index) noexcept;
|
||||
|
||||
@@ -337,6 +337,7 @@ void maps_app_initialization_parameters(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, pp::renderer::gl::max_blend_equation() == 0x8008U);
|
||||
PP_EXPECT(h, pp::renderer::gl::rgba8_internal_format() == 0x8058U);
|
||||
PP_EXPECT(h, pp::renderer::gl::linear_texture_filter() == 0x2601U);
|
||||
PP_EXPECT(h, pp::renderer::gl::linear_mipmap_linear_texture_filter() == 0x2703U);
|
||||
PP_EXPECT(h, pp::renderer::gl::nearest_texture_filter() == 0x2600U);
|
||||
PP_EXPECT(h, pp::renderer::gl::repeat_texture_wrap() == 0x2901U);
|
||||
PP_EXPECT(h, pp::renderer::gl::active_texture_unit(0U) == 0x84C0U);
|
||||
|
||||
Reference in New Issue
Block a user