From 028dbff64f22d0712a86914ef5d13bb9cdf77f53 Mon Sep 17 00:00:00 2001 From: lachrymaLF Date: Tue, 18 Jun 2024 01:27:39 -0400 Subject: [PATCH] will compile on mac but not sure whats wrong --- Keishiki/Graphics.cpp | 2 +- Keishiki/PlugboardNodes.cpp | 1 + Keishiki/UI.cpp | 15 ++++++++------- Keishiki/VisualTrack.cpp | 18 +++++++++--------- Keishiki/include/Graphics.h | 28 +++++++++++++--------------- Keishiki/include/Resource.h | 1 + 6 files changed, 33 insertions(+), 32 deletions(-) diff --git a/Keishiki/Graphics.cpp b/Keishiki/Graphics.cpp index ef5bed8..3262c7b 100644 --- a/Keishiki/Graphics.cpp +++ b/Keishiki/Graphics.cpp @@ -360,7 +360,7 @@ namespace K::Graphics { pack[3] = pack[2] = pack[1] = pack[0] = static_cast(mode); bgfx::setViewMode(view_id, bgfx::ViewMode::Sequential); - bgfx::setViewClear(view_id, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH | BGFX_CLEAR_STENCIL); + bgfx::setViewClear(view_id, BGFX_CLEAR_COLOR); bgfx::setViewFrameBuffer(view_id, fb); bgfx::setViewTransform(view_id, composite_view, proj); bgfx::setViewRect(view_id, 0, 0, w, h); diff --git a/Keishiki/PlugboardNodes.cpp b/Keishiki/PlugboardNodes.cpp index be6d9f1..3e9842e 100644 --- a/Keishiki/PlugboardNodes.cpp +++ b/Keishiki/PlugboardNodes.cpp @@ -1,4 +1,5 @@ #include +#include namespace K::PlugboardNodes { std::array Nodes = std::to_array({ diff --git a/Keishiki/UI.cpp b/Keishiki/UI.cpp index 24503c2..5870711 100644 --- a/Keishiki/UI.cpp +++ b/Keishiki/UI.cpp @@ -69,9 +69,9 @@ namespace K::UI { }; l.track.AddUniform("u_aspect_ratio", ShaderGraph::expand_type(ShaderGraph::T_XY)); if (s.width > s.height) - l.track.uniforms[0].val = ShaderGraph::T_Map::type(static_cast(s.width)/static_cast(s.height), 1.0f); + l.track.uniforms[0].val = ShaderGraph::T_Map::type{static_cast(s.width)/static_cast(s.height), 1.0f}; else - l.track.uniforms[0].val = ShaderGraph::T_Map::type(1.0f, static_cast(s.height)/static_cast(s.width)); + l.track.uniforms[0].val = ShaderGraph::T_Map::type{1.0f, static_cast(s.height)/static_cast(s.width)}; l.track.AddUniform("u_opacity", ShaderGraph::expand_type(ShaderGraph::T_Float)); l.track.uniforms[1].val = ShaderGraph::T_Map::type(1.0f); @@ -80,10 +80,10 @@ namespace K::UI { l.track.uniforms[2].val = ShaderGraph::T_Map::type(.0f); l.track.AddUniform("u_scale", ShaderGraph::expand_type(ShaderGraph::T_XY)); - l.track.uniforms[3].val = ShaderGraph::T_Map::type(1.0f, 1.0f); + l.track.uniforms[3].val = ShaderGraph::T_Map::type{1.0f, 1.0f}; l.track.AddUniform("u_translate", ShaderGraph::expand_type(ShaderGraph::T_XY)); - l.track.uniforms[4].val = ShaderGraph::T_Map::type(.0f, .0f); + l.track.uniforms[4].val = ShaderGraph::T_Map::type{.0f, .0f}; l.track.shader = "void main() {\n" "\tfloat angle = -u_rot * M_PI / 180.0f;\n" @@ -340,7 +340,7 @@ namespace K::UI { // Perform rendering u32 view_count = 0, layers_done = 0; bgfx::setViewFrameBuffer(Graphics::K_VIEW_COMP_COMPOSITE + view_count, composite_fb[0]); // the other fb will be cleared in composite - bgfx::setViewClear(Graphics::K_VIEW_COMP_COMPOSITE + view_count, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH | BGFX_CLEAR_STENCIL, 0x00000000); + bgfx::setViewClear(Graphics::K_VIEW_COMP_COMPOSITE + view_count, BGFX_CLEAR_COLOR, 0x00000000); bgfx::setViewRect(Graphics::K_VIEW_COMP_COMPOSITE + view_count, 0, 0, s.width, s.height); bgfx::touch(Graphics::K_VIEW_COMP_COMPOSITE + view_count); view_count++; @@ -368,7 +368,7 @@ namespace K::UI { transform); } - ImTextureID idx = ImGui::toId(composite[layers_done % 2], 0, 0); + ImTextureID idx = ImGui::toId(composite[layers_done % 2], 1, 0); if (idx != nullptr) ImGui::Image(idx, ImVec2{ static_cast(s.width), static_cast(s.height) }); @@ -400,7 +400,7 @@ namespace K::UI { } constexpr u64 TimelineScreenViewToFrame(f32 view_left, f32 view_amt, f32 view_width, f32 view, u64 frame_max) { - return std::clamp(static_cast(std::round((view / view_width * view_amt + view_left) * static_cast(frame_max + 1))), 0UL, frame_max); + return std::clamp(static_cast(std::round((view / view_width * view_amt + view_left) * static_cast(frame_max + 1))), static_cast(0), frame_max); } void Composition(CompState& s) { @@ -1431,6 +1431,7 @@ namespace K::UI { io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; ImGui_Implbgfx_Init(K::Graphics::K_VIEW_UI); + bgfx::setViewClear(Graphics::K_VIEW_UI, BGFX_CLEAR_COLOR); switch (bgfx::getRendererType()) { case bgfx::RendererType::Noop: diff --git a/Keishiki/VisualTrack.cpp b/Keishiki/VisualTrack.cpp index 79edb27..cc0172f 100644 --- a/Keishiki/VisualTrack.cpp +++ b/Keishiki/VisualTrack.cpp @@ -10,11 +10,11 @@ namespace K { else if constexpr (std::is_same_v::type>) return PlugboardGraph::T_Map::type(arg); else if constexpr (std::is_same_v::type>) - return PlugboardGraph::T_Map::type(arg.r, arg.g, arg.b, arg.a); + return PlugboardGraph::T_Map::type{arg.r, arg.g, arg.b, arg.a}; else if constexpr (std::is_same_v::type>) - return PlugboardGraph::T_Map::type(arg.x, arg.y); + return PlugboardGraph::T_Map::type{arg.x, arg.y}; else if constexpr (std::is_same_v::type>) - return PlugboardGraph::T_Map::type(arg.x, arg.y, arg.z); + return PlugboardGraph::T_Map::type{arg.x, arg.y, arg.z}; },val); } @@ -26,11 +26,11 @@ namespace K { else if constexpr (std::is_same_v::type>) return ShaderGraph::T_Map::type(arg); else if constexpr (std::is_same_v::type>) - return ShaderGraph::T_Map::type(arg.r, arg.g, arg.b, arg.a); + return ShaderGraph::T_Map::type{arg.r, arg.g, arg.b, arg.a}; else if constexpr (std::is_same_v::type>) - return ShaderGraph::T_Map::type(arg.x, arg.y); + return ShaderGraph::T_Map::type{arg.x, arg.y}; else if constexpr (std::is_same_v::type>) - return ShaderGraph::T_Map::type(arg.x, arg.y, arg.z); + return ShaderGraph::T_Map::type{arg.x, arg.y, arg.z}; else if constexpr (std::is_same_v::type>) return ShaderGraph::T_Map::type{}; },val); @@ -39,7 +39,7 @@ namespace K { void VisualTrack::GetFrame(const CompState& s, u32 view_id, bgfx::FrameBufferHandle fb, u32 w, u32 h, f32 proj[16], f32 view[16], f32 transform[16]) { bgfx::setViewMode(view_id, bgfx::ViewMode::Sequential); - bgfx::setViewClear(view_id, BGFX_CLEAR_COLOR | BGFX_CLEAR_DEPTH | BGFX_CLEAR_STENCIL); + bgfx::setViewClear(view_id, BGFX_CLEAR_COLOR); bgfx::setViewFrameBuffer(view_id, fb); bgfx::setViewTransform(view_id, view, proj); @@ -211,7 +211,7 @@ namespace K { for (auto& ss : samplers) if (ss.name == s) return; - uniforms.emplace_back(Uniform(s, bgfx::createUniform(("__" + s).c_str(), bgfx::UniformType::Vec4), val, {nullptr, 0})); + uniforms.emplace_back(Uniform{s, bgfx::createUniform(("__" + s).c_str(), bgfx::UniformType::Vec4), val, {nullptr, 0}}); } void VisualTrack::AddSampler(const String& s) { @@ -221,6 +221,6 @@ namespace K { for (auto& ss : samplers) if (ss.name == s) return; - samplers.emplace_back(Sampler(s, bgfx::createUniform(s.c_str(), bgfx::UniformType::Sampler), Resource::fallback_still)); + samplers.emplace_back(Sampler{s, bgfx::createUniform(s.c_str(), bgfx::UniformType::Sampler), Resource::fallback_still}); } } diff --git a/Keishiki/include/Graphics.h b/Keishiki/include/Graphics.h index 8284e8a..df15207 100644 --- a/Keishiki/include/Graphics.h +++ b/Keishiki/include/Graphics.h @@ -3,6 +3,7 @@ #include "Common.h" #include #include +#include #include @@ -117,28 +118,25 @@ namespace K::Graphics { void Composite(u32 view_id, bgfx::FrameBufferHandle fb, bgfx::TextureHandle composite, bgfx::TextureHandle from, Blending mode, u16 w, u16 h, f32 proj[16], f32 transform[16]); + constexpr static bool CubicRealAccept(f64 t) { + return 0.0 <= t && t <= 1.0; + } + constexpr static f64 GetCubicUniqueReal(f64 a, f64 b, f64 c, f64 d) { - static constexpr auto accept = [](f64 t){ return 0.0 <= t && t <= 1.0; }; f64 a1 = b/a, a2 = c/a, a3 = d/a; f64 Q = (a1 * a1 - 3.0 * a2) / 9.0, R = (2.0 * a1 * a1 * a1 - 9.0 * a1 * a2 + 27.0 * a3) / 54.0, Qcubed = Q * Q * Q, D = Qcubed - R * R; - if (D >= 0) { - f64 theta = acos(R / sqrt(Qcubed)); - f64 sqrtQ = sqrt(Q); - f64 r1 = -2.0 * sqrtQ * cos( theta / 3.0) - a1 / 3.0, - r2 = -2.0 * sqrtQ * cos((theta + 2.0 * std::numbers::pi) / 3.0) - a1 / 3.0, - r3 = -2.0 * sqrtQ * cos((theta + 4.0 * std::numbers::pi) / 3.0) - a1 / 3.0; - return accept(r1) ? r1 : (accept(r2) ? r2 : r3); - } - else { - f64 e = std::pow(std::sqrt(-D) + std::abs(R), 1.0 / 3.0); - if (R > 0.0) - e = -e; - return (e + Q / e) - a1 / 3.; - } + f64 theta = acos(R / sqrt(Qcubed)); + f64 sqrtQ = sqrt(Q); + f64 r1 = -2.0 * sqrtQ * cos( theta / 3.0) - a1 / 3.0, + r2 = -2.0 * sqrtQ * cos((theta + 2.0 * std::numbers::pi) / 3.0) - a1 / 3.0, + r3 = -2.0 * sqrtQ * cos((theta + 4.0 * std::numbers::pi) / 3.0) - a1 / 3.0; + f64 e = std::pow(std::sqrt(-D) + std::abs(R), 1.0 / 3.0); + e = (R > 0.0) ? -e : e; + return D >= 0 ? CubicRealAccept(r1) ? r1 : (CubicRealAccept(r2) ? r2 : r3) : (e + Q / e) - a1 / 3.; } constexpr static f64 CubicBezier(f64 a, f64 b, f64 c, f64 d, f64 t) { diff --git a/Keishiki/include/Resource.h b/Keishiki/include/Resource.h index 1b5c700..5143fcf 100644 --- a/Keishiki/include/Resource.h +++ b/Keishiki/include/Resource.h @@ -3,6 +3,7 @@ #include #include #include +#include namespace K::Resource { extern std::filesystem::path ffmpeg_path;