Move canvas layer pixel mapping to renderer gl
This commit is contained in:
@@ -179,6 +179,9 @@ Known local toolchain state:
|
|||||||
and blend-state tokens.
|
and blend-state tokens.
|
||||||
Simple UI text, text-input, border, scroll, and animation timeline draw
|
Simple UI text, text-input, border, scroll, and animation timeline draw
|
||||||
paths also consume backend-owned blend-state tokens.
|
paths also consume backend-owned blend-state tokens.
|
||||||
|
Canvas layer cube/equirect generation, clear, restore, and snapshot paths
|
||||||
|
also consume backend-owned cube/2D texture targets, active texture units,
|
||||||
|
blend/clear state, and RGBA8 read/write pixel mapping.
|
||||||
- `windows-msvc-vcpkg-headless` validates manifest install/configure/build/test
|
- `windows-msvc-vcpkg-headless` validates manifest install/configure/build/test
|
||||||
for the current headless component matrix; see DEBT-0007 for remaining app
|
for the current headless component matrix; see DEBT-0007 for remaining app
|
||||||
and platform triplet migration.
|
and platform triplet migration.
|
||||||
|
|||||||
@@ -446,6 +446,9 @@ array-buffer, static-upload, vertex-attribute, primitive-mode, and blend-state
|
|||||||
tokens to `pp_renderer_gl`.
|
tokens to `pp_renderer_gl`.
|
||||||
Simple UI text, text-input, border, scroll, and animation timeline draw paths
|
Simple UI text, text-input, border, scroll, and animation timeline draw paths
|
||||||
now also delegate blend-state tokens to `pp_renderer_gl`.
|
now also delegate blend-state tokens to `pp_renderer_gl`.
|
||||||
|
Canvas layer cube/equirect generation, clear, restore, and snapshot paths now
|
||||||
|
also delegate cube/2D texture targets, active texture units, blend/clear state,
|
||||||
|
and RGBA8 read/write pixel mapping to `pp_renderer_gl`.
|
||||||
The existing renderer classes are not yet fully
|
The existing renderer classes are not yet fully
|
||||||
behind the renderer interfaces.
|
behind the renderer interfaces.
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
#include "canvas_layer.h"
|
#include "canvas_layer.h"
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
|
#include "renderer_gl/opengl_capabilities.h"
|
||||||
#include "rtt.h"
|
#include "rtt.h"
|
||||||
|
|
||||||
uint32_t Layer::s_count = 0;
|
uint32_t Layer::s_count = 0;
|
||||||
@@ -44,7 +45,7 @@ TextureCube Layer::gen_cube()
|
|||||||
{
|
{
|
||||||
ret.bind();
|
ret.bind();
|
||||||
rtt(i).bindFramebuffer();
|
rtt(i).bindFramebuffer();
|
||||||
glCopyTexSubImage2D(TextureCube::m_faces_map[i], 0, 0, 0, 0, 0, w, w);
|
glCopyTexSubImage2D(pp::renderer::gl::cube_face_texture_target(i), 0, 0, 0, 0, 0, w, w);
|
||||||
rtt(i).unbindFramebuffer();
|
rtt(i).unbindFramebuffer();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -70,7 +71,7 @@ Texture2D Layer::gen_equirect(glm::ivec2 size /*= { 0, 0 }*/)
|
|||||||
latlong.create(size.x * 4, size.y * 2);
|
latlong.create(size.x * 4, size.y * 2);
|
||||||
ret.create(size.x * 4, size.y * 2);
|
ret.create(size.x * 4, size.y * 2);
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(pp::renderer::gl::blend_state());
|
||||||
|
|
||||||
latlong.bindFramebuffer();
|
latlong.bindFramebuffer();
|
||||||
|
|
||||||
@@ -78,8 +79,8 @@ Texture2D Layer::gen_equirect(glm::ivec2 size /*= { 0, 0 }*/)
|
|||||||
|
|
||||||
glViewport(0, 0, latlong.getWidth(), latlong.getHeight());
|
glViewport(0, 0, latlong.getWidth(), latlong.getHeight());
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(pp::renderer::gl::active_texture_unit(0U));
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, cube.m_cubetex_id);
|
glBindTexture(pp::renderer::gl::texture_cube_map_target(), cube.m_cubetex_id);
|
||||||
|
|
||||||
ShaderManager::use(kShader::Equirect);
|
ShaderManager::use(kShader::Equirect);
|
||||||
ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f));
|
ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f));
|
||||||
@@ -88,7 +89,7 @@ Texture2D Layer::gen_equirect(glm::ivec2 size /*= { 0, 0 }*/)
|
|||||||
Canvas::I->m_plane.draw_fill();
|
Canvas::I->m_plane.draw_fill();
|
||||||
|
|
||||||
ret.bind();
|
ret.bind();
|
||||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, latlong.getWidth(), latlong.getHeight());
|
glCopyTexSubImage2D(pp::renderer::gl::texture_2d_target(), 0, 0, 0, 0, 0, latlong.getWidth(), latlong.getHeight());
|
||||||
|
|
||||||
latlong.unbindFramebuffer();
|
latlong.unbindFramebuffer();
|
||||||
|
|
||||||
@@ -115,13 +116,13 @@ PBO Layer::gen_equirect_pbo(glm::ivec2 size /*= { 0, 0 }*/)
|
|||||||
|
|
||||||
App::I->render_task([&]
|
App::I->render_task([&]
|
||||||
{
|
{
|
||||||
glDisable(GL_BLEND);
|
glDisable(pp::renderer::gl::blend_state());
|
||||||
|
|
||||||
latlong.bindFramebuffer();
|
latlong.bindFramebuffer();
|
||||||
|
|
||||||
glViewport(0, 0, latlong.getWidth(), latlong.getHeight());
|
glViewport(0, 0, latlong.getWidth(), latlong.getHeight());
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(pp::renderer::gl::active_texture_unit(0U));
|
||||||
glBindTexture(GL_TEXTURE_CUBE_MAP, cube.m_cubetex_id);
|
glBindTexture(pp::renderer::gl::texture_cube_map_target(), cube.m_cubetex_id);
|
||||||
|
|
||||||
ShaderManager::use(kShader::Equirect);
|
ShaderManager::use(kShader::Equirect);
|
||||||
ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f));
|
ShaderManager::u_mat4(kShaderUniform::MVP, glm::ortho(-.5f, .5f, -.5f, .5f, -1.f, 1.f));
|
||||||
@@ -458,7 +459,7 @@ void LayerFrame::clear(const glm::vec4& c)
|
|||||||
{
|
{
|
||||||
// push clear color state
|
// push clear color state
|
||||||
GLfloat cc[4];
|
GLfloat cc[4];
|
||||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, cc);
|
glGetFloatv(pp::renderer::gl::color_clear_value_query(), cc);
|
||||||
glClearColor(c.r, c.g, c.b, c.a);
|
glClearColor(c.r, c.g, c.b, c.a);
|
||||||
|
|
||||||
bool erase = (c.a == 0.f);
|
bool erase = (c.a == 0.f);
|
||||||
@@ -466,7 +467,7 @@ void LayerFrame::clear(const glm::vec4& c)
|
|||||||
for (int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
m_rtt[i].bindFramebuffer();
|
m_rtt[i].bindFramebuffer();
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(pp::renderer::gl::framebuffer_color_buffer_mask());
|
||||||
m_rtt[i].unbindFramebuffer();
|
m_rtt[i].unbindFramebuffer();
|
||||||
|
|
||||||
if (erase)
|
if (erase)
|
||||||
@@ -530,9 +531,11 @@ void LayerFrame::restore(const Snapshot& snap)
|
|||||||
|
|
||||||
m_rtt[i].bindTexture();
|
m_rtt[i].bindTexture();
|
||||||
glm::vec2 box_sz = zw(m_dirty_box[i]) - xy(m_dirty_box[i]);
|
glm::vec2 box_sz = zw(m_dirty_box[i]) - xy(m_dirty_box[i]);
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0,
|
glTexSubImage2D(pp::renderer::gl::texture_2d_target(), 0,
|
||||||
m_dirty_box[i].x, m_dirty_box[i].y,
|
static_cast<int>(m_dirty_box[i].x), static_cast<int>(m_dirty_box[i].y),
|
||||||
box_sz.x, box_sz.y, GL_RGBA, GL_UNSIGNED_BYTE,
|
static_cast<int>(box_sz.x), static_cast<int>(box_sz.y),
|
||||||
|
pp::renderer::gl::rgba_pixel_format(),
|
||||||
|
pp::renderer::gl::unsigned_byte_component_type(),
|
||||||
snap.image[i].get());
|
snap.image[i].get());
|
||||||
m_rtt[i].unbindTexture();
|
m_rtt[i].unbindTexture();
|
||||||
LOG("restore face %d - %d bytes (%dx%d)", i,
|
LOG("restore face %d - %d bytes (%dx%d)", i,
|
||||||
@@ -560,8 +563,11 @@ LayerFrame::Snapshot LayerFrame::snapshot(std::array<glm::vec4, 6>* dirty_box /*
|
|||||||
|
|
||||||
m_rtt[i].bindFramebuffer();
|
m_rtt[i].bindFramebuffer();
|
||||||
glm::vec2 box_sz = zw(snap.m_dirty_box[i]) - xy(snap.m_dirty_box[i]);
|
glm::vec2 box_sz = zw(snap.m_dirty_box[i]) - xy(snap.m_dirty_box[i]);
|
||||||
glReadPixels(snap.m_dirty_box[i].x, snap.m_dirty_box[i].y,
|
glReadPixels(static_cast<int>(snap.m_dirty_box[i].x), static_cast<int>(snap.m_dirty_box[i].y),
|
||||||
box_sz.x, box_sz.y, GL_RGBA, GL_UNSIGNED_BYTE, snap.image[i].get());
|
static_cast<int>(box_sz.x), static_cast<int>(box_sz.y),
|
||||||
|
pp::renderer::gl::rgba_pixel_format(),
|
||||||
|
pp::renderer::gl::unsigned_byte_component_type(),
|
||||||
|
snap.image[i].get());
|
||||||
m_rtt[i].unbindFramebuffer();
|
m_rtt[i].unbindFramebuffer();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user