Move OpenGL runtime classification into renderer backend
This commit is contained in:
@@ -180,6 +180,17 @@ if(PP_ENABLE_OPENGL)
|
||||
pp_project_options
|
||||
PRIVATE
|
||||
pp_project_warnings)
|
||||
if(EMSCRIPTEN)
|
||||
target_compile_definitions(pp_renderer_gl PRIVATE
|
||||
PP_RENDERER_GL_RUNTIME_GLES=1
|
||||
PP_RENDERER_GL_RUNTIME_WEB=1)
|
||||
elseif(ANDROID OR CMAKE_SYSTEM_NAME STREQUAL "iOS")
|
||||
target_compile_definitions(pp_renderer_gl PRIVATE
|
||||
PP_RENDERER_GL_RUNTIME_GLES=1)
|
||||
else()
|
||||
target_compile_definitions(pp_renderer_gl PRIVATE
|
||||
PP_RENDERER_GL_RUNTIME_DESKTOP=1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_library(pp_paint_renderer STATIC
|
||||
|
||||
@@ -788,6 +788,10 @@ Known warnings after the current CMake app build:
|
||||
the retained OpenGL runtime classes still include legacy app/engine headers
|
||||
and are still consumed directly by canvas and UI classes. It should become a
|
||||
normal backend library once those call sites depend on `pp_renderer_api`.
|
||||
`pp_renderer_gl` now owns OpenGL runtime build-target classification through
|
||||
CMake target compile definitions and `opengl_runtime_for_current_build()`,
|
||||
so app shader startup asks the backend for desktop GL/GLES/WebGL policy
|
||||
instead of carrying local platform branches.
|
||||
- `pp_legacy_ui_core` is an object-library containment boundary because the
|
||||
retained base `Node` controls still depend on legacy renderer and app
|
||||
headers. It should shrink as layout parsing, colors, generic controls, and
|
||||
|
||||
@@ -672,6 +672,10 @@ Default canvas allocation size now dispatches through `PlatformServices`, so
|
||||
1536 and WebGL 512 defaults without carrying the old `CANVAS_RES` platform
|
||||
macro in `canvas.h`; DEBT-0057 tracks moving the retained WebGL policy branch
|
||||
out of the legacy fallback when the Web shell owns injected services.
|
||||
OpenGL runtime build-target classification now lives in `pp_renderer_gl`
|
||||
through CMake-owned compile definitions and
|
||||
`opengl_runtime_for_current_build()`, so `app_shaders.cpp` no longer decides
|
||||
desktop GL/GLES/WebGL capability policy with local platform branches.
|
||||
Prepared-file save/download handoff is now also part of the service contract,
|
||||
so iOS/Web export completion routes through `PlatformServices` after the app
|
||||
writes the temporary/exported payload.
|
||||
|
||||
@@ -50,16 +50,7 @@ void App::initShaders()
|
||||
LOG("EXT: %s", extension_storage.back().c_str());
|
||||
}
|
||||
|
||||
pp::renderer::gl::OpenGlRuntime runtime;
|
||||
#if __GL__
|
||||
runtime.desktop_gl = true;
|
||||
#endif
|
||||
#if __GLES__
|
||||
runtime.gles = true;
|
||||
#endif
|
||||
#if __WEB__
|
||||
runtime.web = true;
|
||||
#endif
|
||||
const auto runtime = pp::renderer::gl::opengl_runtime_for_current_build();
|
||||
const auto capabilities = pp::renderer::gl::detect_opengl_capabilities(extension_views, runtime);
|
||||
ShaderManager::ext_framebuffer_fetch = capabilities.framebuffer_fetch;
|
||||
ShaderManager::ext_map_aligned = capabilities.map_buffer_alignment;
|
||||
@@ -69,12 +60,12 @@ void App::initShaders()
|
||||
ShaderManager::set_render_device_features(pp::renderer::gl::render_device_features(capabilities));
|
||||
});
|
||||
|
||||
#if __GL__
|
||||
// In OpenGL 3.3 these should be already available
|
||||
ShaderManager::ext_float32_linear = true;
|
||||
ShaderManager::ext_float32 = true;
|
||||
ShaderManager::ext_float16 = true;
|
||||
#endif
|
||||
if (pp::renderer::gl::opengl_runtime_for_current_build().desktop_gl) {
|
||||
// In OpenGL 3.3 these should be already available.
|
||||
ShaderManager::ext_float32_linear = true;
|
||||
ShaderManager::ext_float32 = true;
|
||||
ShaderManager::ext_float16 = true;
|
||||
}
|
||||
ShaderManager::set_render_device_features(
|
||||
pp::renderer::gl::render_device_features(shader_manager_capabilities()));
|
||||
|
||||
|
||||
@@ -201,6 +201,21 @@ OpenGlCapabilities detect_opengl_capabilities(
|
||||
return capabilities;
|
||||
}
|
||||
|
||||
OpenGlRuntime opengl_runtime_for_current_build() noexcept
|
||||
{
|
||||
OpenGlRuntime runtime;
|
||||
#if defined(PP_RENDERER_GL_RUNTIME_DESKTOP)
|
||||
runtime.desktop_gl = true;
|
||||
#endif
|
||||
#if defined(PP_RENDERER_GL_RUNTIME_GLES)
|
||||
runtime.gles = true;
|
||||
#endif
|
||||
#if defined(PP_RENDERER_GL_RUNTIME_WEB)
|
||||
runtime.web = true;
|
||||
#endif
|
||||
return runtime;
|
||||
}
|
||||
|
||||
pp::renderer::RenderDeviceFeatures render_device_features(OpenGlCapabilities capabilities) noexcept
|
||||
{
|
||||
return pp::renderer::RenderDeviceFeatures {
|
||||
|
||||
@@ -678,6 +678,7 @@ struct OpenGlMeshDeleteDispatch {
|
||||
[[nodiscard]] OpenGlCapabilities detect_opengl_capabilities(
|
||||
std::span<const std::string_view> extensions,
|
||||
OpenGlRuntime runtime) noexcept;
|
||||
[[nodiscard]] OpenGlRuntime opengl_runtime_for_current_build() noexcept;
|
||||
[[nodiscard]] pp::renderer::RenderDeviceFeatures render_device_features(
|
||||
OpenGlCapabilities capabilities) noexcept;
|
||||
[[nodiscard]] OpenGlInitialState panopainter_initial_state() noexcept;
|
||||
|
||||
@@ -1035,6 +1035,16 @@ void ignores_gles_texture_extensions_for_webgl_runtime(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, !capabilities.float16_textures);
|
||||
}
|
||||
|
||||
void classifies_current_build_opengl_runtime(pp::tests::Harness& h)
|
||||
{
|
||||
const auto runtime = pp::renderer::gl::opengl_runtime_for_current_build();
|
||||
|
||||
PP_EXPECT(h, runtime.desktop_gl || runtime.gles);
|
||||
PP_EXPECT(h, !(runtime.desktop_gl && runtime.gles));
|
||||
if (runtime.web)
|
||||
PP_EXPECT(h, runtime.gles);
|
||||
}
|
||||
|
||||
void selects_texture_upload_type_from_internal_format(pp::tests::Harness& h)
|
||||
{
|
||||
constexpr std::uint32_t gl_unsigned_byte = 0x1401U;
|
||||
@@ -4092,6 +4102,7 @@ int main()
|
||||
harness.run("treats_desktop_gl_float_rendering_as_core", treats_desktop_gl_float_rendering_as_core);
|
||||
harness.run("detects_gles_texture_float_extensions", detects_gles_texture_float_extensions);
|
||||
harness.run("ignores_gles_texture_extensions_for_webgl_runtime", ignores_gles_texture_extensions_for_webgl_runtime);
|
||||
harness.run("classifies_current_build_opengl_runtime", classifies_current_build_opengl_runtime);
|
||||
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("maps_renderer_texture_formats_to_opengl_tokens", maps_renderer_texture_formats_to_opengl_tokens);
|
||||
|
||||
Reference in New Issue
Block a user