Move VR render state mapping to renderer gl
This commit is contained in:
@@ -199,6 +199,9 @@ Known local toolchain state:
|
|||||||
The Windows entrypoint also consumes backend-owned generic OpenGL error-code
|
The Windows entrypoint also consumes backend-owned generic OpenGL error-code
|
||||||
and info-string tokens; WGL context/pixel-format constants remain in the
|
and info-string tokens; WGL context/pixel-format constants remain in the
|
||||||
platform shell for a later platform-boundary slice.
|
platform shell for a later platform-boundary slice.
|
||||||
|
Desktop VR drawing also consumes backend-owned scissor/depth/blend state,
|
||||||
|
depth clear masks, active texture units, and fallback 2D texture unbind
|
||||||
|
targets while retaining the existing VR SDK/platform bridge shape.
|
||||||
- `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.
|
||||||
|
|||||||
@@ -742,6 +742,10 @@ Results:
|
|||||||
and runtime `data/` copy.
|
and runtime `data/` copy.
|
||||||
- Android arm64 configured with NDK 29.0.14206865 through the platform-build
|
- Android arm64 configured with NDK 29.0.14206865 through the platform-build
|
||||||
wrapper and compiled headless foundation/tool/test targets.
|
wrapper and compiled headless foundation/tool/test targets.
|
||||||
|
- Desktop VR drawing now routes generic OpenGL scissor/depth/blend state,
|
||||||
|
depth clears, active texture units, and fallback 2D texture unbinds through
|
||||||
|
the renderer GL backend mapping; platform VR SDK bridges remain isolated for
|
||||||
|
later platform-shell extraction.
|
||||||
- Known remaining warnings: legacy project/vendor diagnostics, Visual Studio
|
- Known remaining warnings: legacy project/vendor diagnostics, Visual Studio
|
||||||
vcpkg-manifest warning, `LNK4099` missing libyuv PDBs, and `LNK4098` runtime
|
vcpkg-manifest warning, `LNK4099` missing libyuv PDBs, and `LNK4098` runtime
|
||||||
library conflict from retained vendor binaries.
|
library conflict from retained vendor binaries.
|
||||||
|
|||||||
@@ -1,13 +1,31 @@
|
|||||||
#include "pch.h"
|
#include "pch.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
#include "app.h"
|
#include "app.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "shape.h"
|
#include "shape.h"
|
||||||
|
#include "renderer_gl/opengl_capabilities.h"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
bool win32_vr_start();
|
bool win32_vr_start();
|
||||||
void win32_vr_stop();
|
void win32_vr_stop();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
void set_active_texture_unit(std::uint32_t unit_index)
|
||||||
|
{
|
||||||
|
glActiveTexture(pp::renderer::gl::active_texture_unit(unit_index));
|
||||||
|
}
|
||||||
|
|
||||||
|
void unbind_texture_2d()
|
||||||
|
{
|
||||||
|
glBindTexture(pp::renderer::gl::texture_2d_target(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool trigger_down = false;
|
bool trigger_down = false;
|
||||||
cbuffer<glm::vec3> controller_points(10);
|
cbuffer<glm::vec3> controller_points(10);
|
||||||
glm::vec3 controller_last_point;
|
glm::vec3 controller_last_point;
|
||||||
@@ -38,12 +56,12 @@ void App::vr_draw_ui()
|
|||||||
uirtt.bindFramebuffer();
|
uirtt.bindFramebuffer();
|
||||||
uirtt.clear();
|
uirtt.clear();
|
||||||
glViewport(0, 0, uirtt.getWidth(), uirtt.getHeight());
|
glViewport(0, 0, uirtt.getWidth(), uirtt.getHeight());
|
||||||
glEnable(GL_SCISSOR_TEST);
|
glEnable(pp::renderer::gl::scissor_test_state());
|
||||||
auto observer = std::bind(&App::update_ui_observer, this, std::placeholders::_1);
|
auto observer = std::bind(&App::update_ui_observer, this, std::placeholders::_1);
|
||||||
for (int i = 1; i < layout[main_id]->m_children.size(); i++)
|
for (int i = 1; i < layout[main_id]->m_children.size(); i++)
|
||||||
layout[main_id]->m_children[i]->watch(observer);
|
layout[main_id]->m_children[i]->watch(observer);
|
||||||
//msgbox->watch(observer);
|
//msgbox->watch(observer);
|
||||||
glDisable(GL_SCISSOR_TEST);
|
glDisable(pp::renderer::gl::scissor_test_state());
|
||||||
uirtt.unbindFramebuffer();
|
uirtt.unbindFramebuffer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,12 +203,12 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat
|
|||||||
glm::vec3 origin = glm::vec3(0, 0, -1) * glm::transpose(glm::mat3(pose));
|
glm::vec3 origin = glm::vec3(0, 0, -1) * glm::transpose(glm::mat3(pose));
|
||||||
vr_rot = glm::lookAt({ 0, 0, 0 }, origin, { 0, 1, 0 });
|
vr_rot = glm::lookAt({ 0, 0, 0 }, origin, { 0, 1, 0 });
|
||||||
|
|
||||||
auto blend = glIsEnabled(GL_BLEND);
|
auto blend = glIsEnabled(pp::renderer::gl::blend_state());
|
||||||
auto depth = glIsEnabled(GL_DEPTH_TEST);
|
auto depth = glIsEnabled(pp::renderer::gl::depth_test_state());
|
||||||
|
|
||||||
glDisable(GL_BLEND);
|
glDisable(pp::renderer::gl::blend_state());
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(pp::renderer::gl::depth_test_state());
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(pp::renderer::gl::framebuffer_depth_buffer_mask());
|
||||||
|
|
||||||
for (int plane_index = 0; plane_index < 6; plane_index++)
|
for (int plane_index = 0; plane_index < 6; plane_index++)
|
||||||
{
|
{
|
||||||
@@ -205,9 +223,9 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat
|
|||||||
m_face_plane.draw_fill();
|
m_face_plane.draw_fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
glEnable(GL_BLEND);
|
glEnable(pp::renderer::gl::blend_state());
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(pp::renderer::gl::depth_test_state());
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(pp::renderer::gl::framebuffer_depth_buffer_mask());
|
||||||
|
|
||||||
for (size_t i = 0; i < canvas->m_canvas->m_layers.size(); i++)
|
for (size_t i = 0; i < canvas->m_canvas->m_layers.size(); i++)
|
||||||
{
|
{
|
||||||
@@ -241,17 +259,17 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat
|
|||||||
//ShaderManager::u_int(kShaderUniform::Lock, m_canvas->m_layers[layer_index]->m_alpha_locked);
|
//ShaderManager::u_int(kShaderUniform::Lock, m_canvas->m_layers[layer_index]->m_alpha_locked);
|
||||||
ShaderManager::u_int(kShaderUniform::Mask, canvas->m_canvas->m_smask_active);
|
ShaderManager::u_int(kShaderUniform::Mask, canvas->m_canvas->m_smask_active);
|
||||||
ShaderManager::u_mat4(kShaderUniform::MVP, plane_mvp_z);
|
ShaderManager::u_mat4(kShaderUniform::MVP, plane_mvp_z);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
set_active_texture_unit(0);
|
||||||
canvas->m_canvas->m_layers[layer_index]->rtt(plane_index).bindTexture();
|
canvas->m_canvas->m_layers[layer_index]->rtt(plane_index).bindTexture();
|
||||||
glActiveTexture(GL_TEXTURE1);
|
set_active_texture_unit(1);
|
||||||
canvas->m_canvas->m_tmp[plane_index].bindTexture();
|
canvas->m_canvas->m_tmp[plane_index].bindTexture();
|
||||||
glActiveTexture(GL_TEXTURE2);
|
set_active_texture_unit(2);
|
||||||
canvas->m_canvas->m_smask.rtt(plane_index).bindTexture();
|
canvas->m_canvas->m_smask.rtt(plane_index).bindTexture();
|
||||||
m_face_plane.draw_fill();
|
m_face_plane.draw_fill();
|
||||||
canvas->m_canvas->m_smask.rtt(plane_index).unbindTexture();
|
canvas->m_canvas->m_smask.rtt(plane_index).unbindTexture();
|
||||||
glActiveTexture(GL_TEXTURE1);
|
set_active_texture_unit(1);
|
||||||
canvas->m_canvas->m_tmp[plane_index].unbindTexture();
|
canvas->m_canvas->m_tmp[plane_index].unbindTexture();
|
||||||
glActiveTexture(GL_TEXTURE0);
|
set_active_texture_unit(0);
|
||||||
canvas->m_canvas->m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
canvas->m_canvas->m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
||||||
}
|
}
|
||||||
else if (canvas->m_canvas->m_show_tmp && canvas->m_canvas->m_current_layer_idx == layer_index)
|
else if (canvas->m_canvas->m_show_tmp && canvas->m_canvas->m_current_layer_idx == layer_index)
|
||||||
@@ -292,28 +310,28 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat
|
|||||||
ShaderManager::u_int(kShaderUniform::PatternBlendMode, b->m_pattern_blend_mode);
|
ShaderManager::u_int(kShaderUniform::PatternBlendMode, b->m_pattern_blend_mode);
|
||||||
ShaderManager::u_vec2(kShaderUniform::PatternOffset, Canvas::I->m_pattern_offset);
|
ShaderManager::u_vec2(kShaderUniform::PatternOffset, Canvas::I->m_pattern_offset);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
set_active_texture_unit(0);
|
||||||
canvas->m_canvas->m_layers[layer_index]->rtt(plane_index).bindTexture();
|
canvas->m_canvas->m_layers[layer_index]->rtt(plane_index).bindTexture();
|
||||||
glActiveTexture(GL_TEXTURE1);
|
set_active_texture_unit(1);
|
||||||
canvas->m_canvas->m_tmp[plane_index].bindTexture();
|
canvas->m_canvas->m_tmp[plane_index].bindTexture();
|
||||||
glActiveTexture(GL_TEXTURE2);
|
set_active_texture_unit(2);
|
||||||
canvas->m_canvas->m_smask.rtt(plane_index).bindTexture();
|
canvas->m_canvas->m_smask.rtt(plane_index).bindTexture();
|
||||||
glActiveTexture(GL_TEXTURE3);
|
set_active_texture_unit(3);
|
||||||
if (b->m_dual_enabled)
|
if (b->m_dual_enabled)
|
||||||
canvas->m_canvas->m_tmp_dual[plane_index].bindTexture();
|
canvas->m_canvas->m_tmp_dual[plane_index].bindTexture();
|
||||||
glActiveTexture(GL_TEXTURE4);
|
set_active_texture_unit(4);
|
||||||
b->m_pattern_texture ?
|
b->m_pattern_texture ?
|
||||||
b->m_pattern_texture->bind() :
|
b->m_pattern_texture->bind() :
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
unbind_texture_2d();
|
||||||
m_face_plane.draw_fill();
|
m_face_plane.draw_fill();
|
||||||
glActiveTexture(GL_TEXTURE3);
|
set_active_texture_unit(3);
|
||||||
if (b->m_dual_enabled)
|
if (b->m_dual_enabled)
|
||||||
canvas->m_canvas->m_tmp_dual[plane_index].unbindTexture();
|
canvas->m_canvas->m_tmp_dual[plane_index].unbindTexture();
|
||||||
glActiveTexture(GL_TEXTURE2);
|
set_active_texture_unit(2);
|
||||||
canvas->m_canvas->m_smask.rtt(plane_index).unbindTexture();
|
canvas->m_canvas->m_smask.rtt(plane_index).unbindTexture();
|
||||||
glActiveTexture(GL_TEXTURE1);
|
set_active_texture_unit(1);
|
||||||
canvas->m_canvas->m_tmp[plane_index].unbindTexture();
|
canvas->m_canvas->m_tmp[plane_index].unbindTexture();
|
||||||
glActiveTexture(GL_TEXTURE0);
|
set_active_texture_unit(0);
|
||||||
canvas->m_canvas->m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
canvas->m_canvas->m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -325,7 +343,7 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat
|
|||||||
ShaderManager::u_int(kShaderUniform::Highlight, canvas->m_canvas->m_layers[layer_index]->m_hightlight);
|
ShaderManager::u_int(kShaderUniform::Highlight, canvas->m_canvas->m_layers[layer_index]->m_hightlight);
|
||||||
ShaderManager::u_mat4(kShaderUniform::MVP, plane_mvp_z);
|
ShaderManager::u_mat4(kShaderUniform::MVP, plane_mvp_z);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
set_active_texture_unit(0);
|
||||||
canvas->m_canvas->m_layers[layer_index]->rtt(plane_index).bindTexture();
|
canvas->m_canvas->m_layers[layer_index]->rtt(plane_index).bindTexture();
|
||||||
m_face_plane.draw_fill();
|
m_face_plane.draw_fill();
|
||||||
canvas->m_canvas->m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
canvas->m_canvas->m_layers[layer_index]->rtt(plane_index).unbindTexture();
|
||||||
@@ -352,7 +370,7 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat
|
|||||||
m_face_plane.draw_stroke();
|
m_face_plane.draw_stroke();
|
||||||
}
|
}
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(pp::renderer::gl::depth_test_state());
|
||||||
// draw the brush
|
// draw the brush
|
||||||
/*
|
/*
|
||||||
auto mode = dynamic_cast<CanvasModePen*>(canvas->m_canvas->modes[(int)canvas->m_canvas->m_current_mode][0]);
|
auto mode = dynamic_cast<CanvasModePen*>(canvas->m_canvas->modes[(int)canvas->m_canvas->m_current_mode][0]);
|
||||||
@@ -377,8 +395,8 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat
|
|||||||
glm::scale(glm::vec3(canvas->m_canvas->m_current_brush->m_tip_size / height)) *
|
glm::scale(glm::vec3(canvas->m_canvas->m_current_brush->m_tip_size / height)) *
|
||||||
glm::eulerAngleZ(canvas->m_canvas->m_current_brush->m_tip_angle * (float)(M_PI * 2.0))
|
glm::eulerAngleZ(canvas->m_canvas->m_current_brush->m_tip_angle * (float)(M_PI * 2.0))
|
||||||
);
|
);
|
||||||
glEnable(GL_BLEND);
|
glEnable(pp::renderer::gl::blend_state());
|
||||||
glActiveTexture(GL_TEXTURE0);
|
set_active_texture_unit(0);
|
||||||
auto& tex = *canvas->m_canvas->m_current_brush->m_tip_texture;
|
auto& tex = *canvas->m_canvas->m_current_brush->m_tip_texture;
|
||||||
tex.bind();
|
tex.bind();
|
||||||
sampler_linear.bind(0);
|
sampler_linear.bind(0);
|
||||||
@@ -399,7 +417,7 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat
|
|||||||
ShaderManager::use(kShader::Texture);
|
ShaderManager::use(kShader::Texture);
|
||||||
ShaderManager::u_int(kShaderUniform::Tex, 0);
|
ShaderManager::u_int(kShaderUniform::Tex, 0);
|
||||||
ShaderManager::u_mat4(kShaderUniform::MVP, mvp);
|
ShaderManager::u_mat4(kShaderUniform::MVP, mvp);
|
||||||
glActiveTexture(GL_TEXTURE0);
|
set_active_texture_unit(0);
|
||||||
uirtt.bindTexture();
|
uirtt.bindTexture();
|
||||||
m_face_plane.draw_fill();
|
m_face_plane.draw_fill();
|
||||||
uirtt.unbindTexture();
|
uirtt.unbindTexture();
|
||||||
@@ -451,8 +469,8 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat
|
|||||||
glm::scale(glm::vec3(canvas->m_canvas->m_current_brush->m_tip_size * 100.f / height)) *
|
glm::scale(glm::vec3(canvas->m_canvas->m_current_brush->m_tip_size * 100.f / height)) *
|
||||||
glm::eulerAngleZ(canvas->m_canvas->m_current_brush->m_tip_angle * (float)(M_PI * 2.0))
|
glm::eulerAngleZ(canvas->m_canvas->m_current_brush->m_tip_angle * (float)(M_PI * 2.0))
|
||||||
);
|
);
|
||||||
glEnable(GL_BLEND);
|
glEnable(pp::renderer::gl::blend_state());
|
||||||
glActiveTexture(GL_TEXTURE0);
|
set_active_texture_unit(0);
|
||||||
auto& tex = *canvas->m_canvas->m_current_brush->m_tip_texture;
|
auto& tex = *canvas->m_canvas->m_current_brush->m_tip_texture;
|
||||||
tex.bind();
|
tex.bind();
|
||||||
sampler_linear.bind(0);
|
sampler_linear.bind(0);
|
||||||
@@ -466,7 +484,7 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat
|
|||||||
for (auto& mode : *canvas->m_canvas->m_mode)
|
for (auto& mode : *canvas->m_canvas->m_mode)
|
||||||
mode->on_Draw(ortho_proj, proj, camera);
|
mode->on_Draw(ortho_proj, proj, camera);
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(pp::renderer::gl::depth_test_state());
|
||||||
if (canvas->m_canvas->m_smask_active)
|
if (canvas->m_canvas->m_smask_active)
|
||||||
{
|
{
|
||||||
canvas->m_canvas->modes[(int)kCanvasMode::MaskFree][0]->on_Draw(ortho_proj, proj, camera);
|
canvas->m_canvas->modes[(int)kCanvasMode::MaskFree][0]->on_Draw(ortho_proj, proj, camera);
|
||||||
@@ -479,8 +497,8 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat
|
|||||||
mode->on_Draw(ortho_proj, proj, camera);
|
mode->on_Draw(ortho_proj, proj, camera);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
blend ? glEnable(GL_BLEND) : glDisable(GL_BLEND);
|
blend ? glEnable(pp::renderer::gl::blend_state()) : glDisable(pp::renderer::gl::blend_state());
|
||||||
depth ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST);
|
depth ? glEnable(pp::renderer::gl::depth_test_state()) : glDisable(pp::renderer::gl::depth_test_state());
|
||||||
sampler.unbind();
|
sampler.unbind();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user