diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a191ed8e..5dcdd7ed 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,10 +10,12 @@ jobs: matrix: include: - platform: x64 - os: windows-2022 + os: windows-latest triplet: x64-windows runs-on: ${{ matrix.os }} env: + VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg-cache + VCPKG_BINARY_SOURCES: 'clear;files,${{ github.workspace }}/vcpkg-cache,readwrite' VCPKG_DEFAULT_TRIPLET: ${{ matrix.triplet }}-release VCPKG_TARGET_TRIPLET: ${{ matrix.triplet }}-release VCPKG_INSTALLED_DIR: ${{ github.workspace }}/vcpkg_installed/ @@ -22,7 +24,7 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: submodules: "recursive" @@ -33,22 +35,32 @@ jobs: $short=$(git rev-parse --short HEAD) (Get-Content $file -Raw) -replace '(#define\s+CFG_VERSION_NUM\s+"[^"]*)(")', "`$1-$short`$2" | Set-Content $file - - name: run-vcpkg - uses: lukka/run-vcpkg@v11 + - name: Prepare cache directory + shell: powershell + run: "mkdir -Force ${{ env.VCPKG_DEFAULT_BINARY_CACHE }}" + + - name: Cache vcpkg dependencies + uses: actions/cache@v6 with: - vcpkgJsonGlob: "./vcpkg.json" - runVcpkgInstall: true + path: ${{ env.VCPKG_DEFAULT_BINARY_CACHE }} + key: vcpkg-${{ runner.os }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}-${{ github.run_id }} + restore-keys: | + vcpkg-${{ runner.os }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}- + vcpkg-${{ runner.os }}- - - name: Setup MSBuild - uses: microsoft/setup-msbuild@v2 + - name: Bootstrap vcpkg + shell: powershell + run: | + .\vcpkg\bootstrap-vcpkg.bat - name: Obtain and run CMake - uses: threeal/cmake-action@v1.3.0 + uses: threeal/cmake-action@v2.1.0 with: source-dir: "." build-dir: "build" - generator: "Visual Studio 17 2022" - options: CMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake CMAKE_INSTALL_PREFIX="${{ env.INST_DIR }}" VCPKG_TARGET_TRIPLET="${{ env.VCPKG_TARGET_TRIPLET }}" + generator: "Visual Studio 18 2026" + options: CMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake CMAKE_INSTALL_PREFIX=${{ env.INST_DIR }} VCPKG_INSTALLED_DIR=${{ env.VCPKG_INSTALLED_DIR }} VCPKG_TARGET_TRIPLET=${{ env.VCPKG_TARGET_TRIPLET }} + run-build: false - name: Build DLL run: "cmake --build build --config Release -t INSTALL" @@ -62,19 +74,19 @@ jobs: } else { Write-Host "DLL not found" } - name: Archive DLL - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: SimpleGraphic-${{ matrix.triplet }}.dll path: "${{ env.INST_DIR }}/SimpleGraphic.dll" - name: Archive DLL symbols - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: SimpleGraphic-${{ matrix.triplet }}.pdb path: "${{ github.workspace }}/build/Release/SimpleGraphic.pdb" - name: Archive dependency DLLs - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: SimpleGraphic-${{ matrix.triplet }}-deps.dll path: | @@ -82,7 +94,7 @@ jobs: !${{ env.INST_DIR }}/SimpleGraphic.dll - name: Archive dependency DLL symbols - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: SimpleGraphic-${{ matrix.triplet }}-deps.pdb path: | @@ -99,7 +111,7 @@ jobs: - name: Notify PathOfBuilding repo if: ${{ github.event_name == 'release' }} - uses: peter-evans/repository-dispatch@v3 + uses: peter-evans/repository-dispatch@v4 with: token: ${{ secrets.WIRES77_PAT }} repository: ${{ github.repository_owner }}/PathOfBuilding @@ -108,7 +120,7 @@ jobs: - name: Notify PathOfBuilding-PoE2 repo if: ${{ github.event_name == 'release' }} - uses: peter-evans/repository-dispatch@v3 + uses: peter-evans/repository-dispatch@v4 with: token: ${{ secrets.WIRES77_PAT }} repository: ${{ github.repository_owner }}/PathOfBuilding-PoE2 diff --git a/.gitmodules b/.gitmodules index 4fdcaad5..2d41c11d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,9 +7,6 @@ [submodule "dep/imgui"] path = dep/imgui url = https://github.com/ocornut/imgui.git -[submodule "dep/glm"] - path = dep/glm - url = https://github.com/g-truc/glm.git [submodule "libs/luautf8"] path = libs/luautf8 url = https://github.com/starwing/luautf8.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e0ccfca..4eed9f17 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,23 @@ include(${PROJECT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake) set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION ".") include(InstallRequiredSystemLibraries) -add_subdirectory(dep/glm) + +find_package(unofficial-angle CONFIG REQUIRED) +find_package(CMakeRC CONFIG REQUIRED) +find_package(CURL CONFIG REQUIRED) +find_package(fmt CONFIG REQUIRED) +find_package(glfw3 CONFIG REQUIRED) +find_package(gli CONFIG REQUIRED) +find_package(glm CONFIG REQUIRED) +find_package(LuaJIT REQUIRED) +find_package(Microsoft.GSL CONFIG REQUIRED) +find_package(PkgConfig REQUIRED) +find_package(re2 CONFIG REQUIRED) +find_package(sol2 CONFIG REQUIRED) +find_package(Threads REQUIRED) +find_package(zstd REQUIRED) +find_package(ZLIB REQUIRED) +find_package(WebP) set(SIMPLEGRAPHIC_SOURCES "config.h" @@ -76,61 +92,58 @@ set(SIMPLEGRAPHIC_SOURCES "ui_subscript.h" ) -set (SIMPLEGRAPHIC_PLATFORM_SOURCES) +add_library(SimpleGraphic SHARED + ${SIMPLEGRAPHIC_SOURCES} +) + +cmrc_add_resource_library(SimpleGraphic-Assets ALIAS SimpleGraphic::Assets NAMESPACE SimpleGraphic) + +cmrc_add_resources(SimpleGraphic-Assets + "assets/gles/display_render_target.frag" + "assets/gles/display_render_target.vert" + "assets/gles/tinted_texture.frag" + "assets/gles/tinted_texture.vert" +) + if (APPLE) - set (SIMPLEGRAPHIC_PLATFORM_SOURCES + target_sources(SimpleGraphic PRIVATE "engine/system/win/sys_macos.mm" ) endif() if (WIN32) - set (SIMPLEGRAPHIC_PLATFORM_SOURCES + target_sources(SimpleGraphic PRIVATE "engine/system/win/sys_console.cpp" "SimpleGraphic.rc" ) else() - list (APPEND SIMPLEGRAPHIC_PLATFORM_SOURCES + target_sources(SimpleGraphic PRIVATE "engine/system/win/sys_console_unix.cpp" ) endif() -add_library(SimpleGraphic SHARED - ${SIMPLEGRAPHIC_SOURCES} - ${SIMPLEGRAPHIC_PLATFORM_SOURCES} -) target_compile_definitions(SimpleGraphic PRIVATE - "UNICODE" "_CRT_SECURE_NO_DEPRECATE" "_CRT_SECURE_NO_WARNINGS" "_SCL_SECURE_NO_DEPRECATE" "_SCL_SECURE_NO_WARNINGS" - "GLFW_INCLUDE_NONE" "GL_SILENCE_DEPRECATION" + "GLFW_INCLUDE_NONE" + "GLM_ENABLE_EXPERIMENTAL" + "NOMINMAX" "SIMPLEGRAPHIC_EXPORTS" + "UNICODE" ) +target_compile_options(SimpleGraphic PRIVATE "$<$:/MP>") + target_include_directories(SimpleGraphic PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/engine" ) -find_package(unofficial-angle CONFIG REQUIRED) -find_package(CURL CONFIG REQUIRED) -find_package(fmt CONFIG REQUIRED) -find_package(glfw3 CONFIG REQUIRED) -find_package(gli CONFIG REQUIRED) -find_package(LuaJIT REQUIRED) -find_package(Microsoft.GSL CONFIG REQUIRED) -find_package(PkgConfig REQUIRED) -find_package(re2 CONFIG REQUIRED) -find_package(sol2 CONFIG REQUIRED) -find_package(Threads REQUIRED) -find_package(zstd REQUIRED) -find_package(ZLIB REQUIRED) -find_package(WebP) - add_library(cmp_core STATIC dep/compressonator/cmp_core/source/cmp_core.cpp dep/compressonator/cmp_core/source/cmp_core.h @@ -237,6 +250,7 @@ target_link_libraries(SimpleGraphic LuaJIT::LuaJIT Microsoft.GSL::GSL re2::re2 + SimpleGraphic::Assets Threads::Threads WebP::webpdecoder ZLIB::ZLIB @@ -252,7 +266,7 @@ if (WIN32) if (NOT VCPKG_TARGET_TRIPLET MATCHES "-release") find_file(LuaJIT_DLL_DEBUG NAMES "lua51.dll" PATHS "${DEPS_DIR}" PATH_SUFFIXES "debug/bin" REQUIRED NO_DEFAULT_PATH) - find_file(ZLIB_DLL_DEBUG NAMES "zlibd1.dll" + find_file(ZLIB_DLL_DEBUG NAMES "zd.dll" PATHS "${DEPS_DIR}" PATH_SUFFIXES "debug/bin" REQUIRED NO_DEFAULT_PATH) install(FILES @@ -265,7 +279,7 @@ if (WIN32) find_file(LuaJIT_DLL_RELEASE NAMES "lua51.dll" PATHS "${DEPS_DIR}" PATH_SUFFIXES "bin" REQUIRED NO_DEFAULT_PATH) - find_file(ZLIB_DLL_RELEASE NAMES "zlib1.dll" + find_file(ZLIB_DLL_RELEASE NAMES "z.dll" PATHS "${DEPS_DIR}" PATH_SUFFIXES "bin" REQUIRED NO_DEFAULT_PATH) install(FILES diff --git a/assets/gles/display_render_target.frag b/assets/gles/display_render_target.frag new file mode 100644 index 00000000..0a12096c --- /dev/null +++ b/assets/gles/display_render_target.frag @@ -0,0 +1,13 @@ +#version 300 es +precision mediump float; + +uniform highp sampler2D s_tex; + +in vec2 v_texcoord; + +out vec4 f_fragColor; + +void main(void) { + vec3 color = texture(s_tex, v_texcoord).rgb; + f_fragColor = vec4(color, 1.0); +} diff --git a/assets/gles/display_render_target.vert b/assets/gles/display_render_target.vert new file mode 100644 index 00000000..190d72ac --- /dev/null +++ b/assets/gles/display_render_target.vert @@ -0,0 +1,10 @@ +#version 300 es +in vec4 a_position; +in vec2 a_texcoord; + +out vec2 v_texcoord; + +void main(void) { + gl_Position = a_position; + v_texcoord = a_texcoord; +} diff --git a/assets/gles/tinted_texture.frag b/assets/gles/tinted_texture.frag new file mode 100644 index 00000000..7bc4315a --- /dev/null +++ b/assets/gles/tinted_texture.frag @@ -0,0 +1,18 @@ +#version 300 es +precision mediump float; + +uniform highp sampler2DArray s_tex[{SG_TEXTURE_COUNT}]; + +in vec2 v_screenPos; +in vec2 v_texcoord; +in vec4 v_tint; +in vec2 v_texId; + +out vec4 f_fragColor; + +void main(void) +{{ + vec4 color; + {SG_TEXTURE_SWITCH} + f_fragColor = color * v_tint; +}} diff --git a/assets/gles/tinted_texture.vert b/assets/gles/tinted_texture.vert new file mode 100644 index 00000000..cc101888 --- /dev/null +++ b/assets/gles/tinted_texture.vert @@ -0,0 +1,28 @@ +#version 300 es + +uniform vec2 u_screenSize; + +in vec2 a_vertex; +in vec2 a_texcoord; +in vec4 a_tint; +in vec2 a_texId; + +out vec2 v_screenPos; +out vec2 v_texcoord; +out vec4 v_tint; +out vec2 v_texId; + +vec2 SceneToNdc(vec2 scenePos) { + vec2 unitPos = scenePos / u_screenSize; + return mix(vec2(-1.0, 1.0), vec2(1.0, -1.0), unitPos); +} + +void main(void) +{ + v_texcoord = a_texcoord; + v_tint = a_tint; + v_texId = a_texId; + vec2 pos = SceneToNdc(a_vertex); + v_screenPos = pos; + gl_Position = vec4(pos, 0, 1); +} diff --git a/dep/glm b/dep/glm deleted file mode 160000 index 47585fde..00000000 --- a/dep/glm +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 47585fde0c49fa77a2bf2fb1d2ead06999fd4b6e diff --git a/dep/imgui b/dep/imgui index 0962c9fb..f1cc2ae1 160000 --- a/dep/imgui +++ b/dep/imgui @@ -1 +1 @@ -Subproject commit 0962c9fb723ee1498a533f0e592d81f7e6c1ffd8 +Subproject commit f1cc2ae15e53a861a874c3034aae6798fde194ab diff --git a/engine/core/core_config.cpp b/engine/core/core_config.cpp index d5f41355..d3a3795b 100644 --- a/engine/core/core_config.cpp +++ b/engine/core/core_config.cpp @@ -10,6 +10,7 @@ #include "core_config.h" #include +#include // ======================= // core_IConfig Interface diff --git a/engine/render.h b/engine/render.h index 0bb36813..4b6aa7ae 100644 --- a/engine/render.h +++ b/engine/render.h @@ -5,6 +5,7 @@ // #include +#include // ======= // Classes @@ -44,13 +45,6 @@ enum r_texFlag_e { TF_ASYNC = 0x08, // Load asynchronously }; -// Blend modes -enum r_blendMode_e { - RB_ALPHA, - RB_PRE_ALPHA, - RB_ADDITIVE -}; - // Shader handle class r_shaderHnd_c { friend class r_renderer_c; @@ -93,12 +87,11 @@ class r_IRenderer { virtual void SetDrawSubLayer(int subLayer) = 0; virtual int GetDrawLayer() = 0; virtual void SetViewport(int x = 0, int y = 0, int width = 0, int height = 0) = 0; - virtual void SetBlendMode(int mode) = 0; virtual void DrawColor(const col4_t col = NULL) = 0; virtual void DrawColor(dword col) = 0; virtual void GetDrawColor(col4_t color) = 0; - virtual void DrawImage(r_shaderHnd_c* hnd, glm::vec2 pos, glm::vec2 extent, glm::vec2 uv1 = { 0, 0 }, glm::vec2 uv2 = { 1, 1 }, int stackLayer = 0, std::optional maskLayer = {}) = 0; - virtual void DrawImageQuad(r_shaderHnd_c* hnd, glm::vec2 p0, glm::vec2 p1, glm::vec2 p2, glm::vec2 p3, glm::vec2 uv0 = { 0, 0 }, glm::vec2 uv1 = { 1, 0 }, glm::vec2 uv2 = { 1, 1 }, glm::vec2 uv3 = { 0, 1 }, int stackLayer = 0, std::optional maskLayer = {}) = 0; + virtual void DrawImage(r_shaderHnd_c* hnd, glm::vec2 pos, glm::vec2 extent, glm::vec2 uv1 = { 0, 0 }, glm::vec2 uv2 = { 1, 1 }, int stackLayer = 0) = 0; + virtual void DrawImageQuad(r_shaderHnd_c* hnd, glm::vec2 p0, glm::vec2 p1, glm::vec2 p2, glm::vec2 p3, glm::vec2 uv0 = { 0, 0 }, glm::vec2 uv1 = { 1, 0 }, glm::vec2 uv2 = { 1, 1 }, glm::vec2 uv3 = { 0, 1 }, int stackLayer = 0) = 0; virtual void DrawString(float x, float y, int align, int height, const col4_t col, int font, const char* str) = 0; virtual void DrawStringFormat(float x, float y, int align, int height, const col4_t col, int font, const char* fmt, ...) = 0; virtual int DrawStringWidth(int height, int font, const char* str) = 0; diff --git a/engine/render/r_main.cpp b/engine/render/r_main.cpp index 9cce5dfc..c94433ca 100644 --- a/engine/render/r_main.cpp +++ b/engine/render/r_main.cpp @@ -23,11 +23,12 @@ #include #include +#include #include #include #include -static uint64_t MurmurHash64A(void const* data, int len, uint64_t seed); +CMRC_DECLARE(SimpleGraphic); // ======= // Classes @@ -101,36 +102,14 @@ r_shaderHnd_c::~r_shaderHnd_c() } } -struct Mat4 { - float m[16]; - - float const* data() const { - return m; - } -}; - -Mat4 OrthoMatrix(double left, double right, double bottom, double top, double nearVal, double farVal) -{ - Mat4 ret; - std::fill_n(ret.m, 16, 0.0f); - ret.m[0] = (float)(2.0f / (right - left)); - ret.m[5] = (float)(2.0f / (top - bottom)); - ret.m[10] = (float)(-2.0f / (farVal - nearVal)); - ret.m[12] = (float)-((right + left) / (right - left)); - ret.m[13] = (float)-((top + bottom) / (top - bottom)); - ret.m[14] = (float)-((farVal + nearVal) / (farVal - nearVal)); - ret.m[15] = 1.0f; - return ret; -} - // ================= // Layer queue class // ================= +#pragma pack(push, r_layerCmd, 1) struct r_layerCmd_s { - enum Command { + enum Command : uint8_t { VIEWPORT, - BLEND, BIND, COLOR, QUAD, @@ -142,11 +121,6 @@ struct r_layerCmdViewport_s { r_viewport_s viewport; }; -struct r_layerCmdBlend_s { - r_layerCmd_s::Command cmd; - int blendMode; -}; - struct r_layerCmdBind_s { r_layerCmd_s::Command cmd; r_tex_c* tex; @@ -164,9 +138,10 @@ struct r_layerCmdQuad_s { float t[4]; float x[4]; float y[4]; - int stackLayer, maskLayer; + int stackLayer; } quad; }; +#pragma pack(pop, r_layerCmd) r_layer_c::r_layer_c(r_renderer_c* renderer, int layer, int subLayer) : renderer(renderer), layer(layer), subLayer(subLayer) @@ -184,7 +159,6 @@ static size_t CommandSize(r_layerCmd_s::Command cmd, size_t extraSize = 0) { using Tag = r_layerCmd_s::Command; switch (cmd) { case Tag::VIEWPORT: return sizeof(r_layerCmdViewport_s); - case Tag::BLEND: return sizeof(r_layerCmdBlend_s); case Tag::BIND: return sizeof(r_layerCmdBind_s); case Tag::COLOR: return sizeof(r_layerCmdColor_s); case Tag::QUAD: return sizeof(r_layerCmdQuad_s); @@ -233,18 +207,7 @@ void r_layer_c::SetViewport(r_viewport_s* viewport) { if (auto* cmd = (r_layerCmdViewport_s*)NewCommand(CommandSize(r_layerCmd_s::VIEWPORT))) { cmd->cmd = r_layerCmd_s::VIEWPORT; - cmd->viewport.x = viewport->x; - cmd->viewport.y = viewport->y; - cmd->viewport.width = viewport->width; - cmd->viewport.height = viewport->height; - } -} - -void r_layer_c::SetBlendMode(int mode) -{ - if (auto* cmd = (r_layerCmdBlend_s*)NewCommand(CommandSize(r_layerCmd_s::BLEND))) { - cmd->cmd = r_layerCmd_s::BLEND; - cmd->blendMode = mode; + cmd->viewport = *viewport; } } @@ -264,7 +227,7 @@ void r_layer_c::Color(col4_t col) } } -void r_layer_c::Quad(float s0, float t0, float x0, float y0, float s1, float t1, float x1, float y1, float s2, float t2, float x2, float y2, float s3, float t3, float x3, float y3, int stackLayer, int maskLayer) +void r_layer_c::Quad(float s0, float t0, float x0, float y0, float s1, float t1, float x1, float y1, float s2, float t2, float x2, float y2, float s3, float t3, float x3, float y3, int stackLayer) { if (auto* cmd = (r_layerCmdQuad_s*)NewCommand(CommandSize(r_layerCmd_s::QUAD))) { cmd->cmd = r_layerCmd_s::QUAD; @@ -273,59 +236,14 @@ void r_layer_c::Quad(float s0, float t0, float x0, float y0, float s1, float t1, cmd->quad.x[0] = x0; cmd->quad.x[1] = x1; cmd->quad.x[2] = x2; cmd->quad.x[3] = x3; cmd->quad.y[0] = y0; cmd->quad.y[1] = y1; cmd->quad.y[2] = y2; cmd->quad.y[3] = y3; cmd->quad.stackLayer = stackLayer; - cmd->quad.maskLayer = maskLayer; } } -// ================= -// Geometric queries -// ================= - -struct r_aabb_s { - float lo[2]; - float hi[2]; -}; - -r_aabb_s AabbFromCmdQuad(decltype(r_layerCmdQuad_s::quad)& q, r_viewport_s& vp) -{ - r_aabb_s r{ - {+FLT_MAX, +FLT_MAX}, - {-FLT_MAX, -FLT_MAX}, - }; - for (size_t i = 0; i < 4; ++i) { - r.lo[0] = (std::min)(r.lo[0], (float)q.x[i]); - r.lo[1] = (std::min)(r.lo[1], (float)q.y[i]); - r.hi[0] = (std::max)(r.hi[0], (float)q.x[i]); - r.hi[1] = (std::max)(r.hi[1], (float)q.y[i]); - } - r.lo[0] += vp.x; - r.lo[1] += vp.y; - r.hi[0] += vp.x; - r.hi[1] += vp.y; - return r; -} - -r_aabb_s AabbFromViewport(r_viewport_s& vp) -{ - r_aabb_s r{ - {(float)vp.x, (float)vp.y }, - {(float)(vp.x + vp.width), (float)(vp.y + vp.height) }, - }; - return r; -} - -bool AabbAabbIntersects(r_aabb_s& a, r_aabb_s& b) -{ - // A.lo <= B.hi && A.hi >= B.lo - return a.lo[0] <= b.hi[0] && a.lo[1] <= b.hi[1] && a.hi[0] >= b.lo[0] && a.hi[1] >= b.lo[1]; -} - struct Vertex { float x, y; float u, v; float r, g, b, a; - float viewX, viewY, viewW, viewH; - float texId, stackIdx, maskIdx; + float texId, stackIdx; }; struct Batch { @@ -340,7 +258,6 @@ struct Batch { GLint xyAttr; GLint uvAttr; GLint tintAttr; - GLint viewportAttr; GLint texIdAttr; std::vector vertices; @@ -354,7 +271,6 @@ Batch::Batch(GLuint prog) xyAttr = glGetAttribLocation(prog, "a_vertex"); uvAttr = glGetAttribLocation(prog, "a_texcoord"); tintAttr = glGetAttribLocation(prog, "a_tint"); - viewportAttr = glGetAttribLocation(prog, "a_viewport"); texIdAttr = glGetAttribLocation(prog, "a_texId"); } @@ -363,7 +279,6 @@ Batch::Batch(Batch&& rhs) , xyAttr(rhs.xyAttr) , uvAttr(rhs.uvAttr) , tintAttr(rhs.tintAttr) - , viewportAttr(rhs.viewportAttr) , texIdAttr(rhs.texIdAttr) , vertices(std::move(rhs.vertices)) { @@ -374,7 +289,6 @@ Batch& Batch::operator = (Batch&& rhs) { xyAttr = rhs.xyAttr; uvAttr = rhs.uvAttr; tintAttr = rhs.tintAttr; - viewportAttr = rhs.viewportAttr; texIdAttr = rhs.texIdAttr; vertices = std::move(rhs.vertices); @@ -397,18 +311,15 @@ void Batch::Execute(GLuint sharedVbo, size_t vertexBase) glVertexAttribPointer(xyAttr, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void const*)offsetof(Vertex, x)); glVertexAttribPointer(uvAttr, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void const*)offsetof(Vertex, u)); glVertexAttribPointer(tintAttr, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void const*)offsetof(Vertex, r)); - glVertexAttribPointer(viewportAttr, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void const*)offsetof(Vertex, viewX)); - glVertexAttribPointer(texIdAttr, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void const*)offsetof(Vertex, texId)); + glVertexAttribPointer(texIdAttr, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void const*)offsetof(Vertex, texId)); glEnableVertexAttribArray(xyAttr); glEnableVertexAttribArray(uvAttr); glEnableVertexAttribArray(tintAttr); - glEnableVertexAttribArray(viewportAttr); glEnableVertexAttribArray(texIdAttr); glDrawArrays(GL_TRIANGLES, 0, (GLsizei)vertices.size()); glDisableVertexAttribArray(xyAttr); glDisableVertexAttribArray(uvAttr); glDisableVertexAttribArray(tintAttr); - glDisableVertexAttribArray(viewportAttr); glDisableVertexAttribArray(texIdAttr); glBindBuffer(GL_ARRAY_BUFFER, 0); vertices.clear(); @@ -420,17 +331,12 @@ struct RenderStrategy { virtual void ProcessCommand(r_layerCmd_s* cmd) = 0; virtual void Flush() = 0; virtual void SetShowStats(bool showStats) { showStats_ = showStats; } + virtual bool UsedIncompleteTextures() const { return false; } protected: bool showStats_{}; }; -static std::map const s_blendModeString{ - {RB_ALPHA, "RB_ALPHA"}, - {RB_PRE_ALPHA, "RB_PRE_ALPHA"}, - {RB_ADDITIVE, "RB_ADDITIVE"}, -}; - struct AdjacentMergeStrategy : RenderStrategy { AdjacentMergeStrategy(r_layer_c* layer, r_renderer_c* renderer, GLuint prog) : layer_(layer), renderer_(renderer), prog_(prog), batch_(prog) @@ -442,20 +348,22 @@ struct AdjacentMergeStrategy : RenderStrategy { } texLocs_.push_back(loc); } - mvpMatrixLoc_ = glGetUniformLocation(prog_, "mvp_matrix"); + uScreenSizeLoc_ = glGetUniformLocation(prog_, "u_screenSize"); batchTextureCap_ = texLocs_.size(); glGenBuffers(1, &vbo_); + glEnable(GL_SCISSOR_TEST); } ~AdjacentMergeStrategy() { + glDisable(GL_SCISSOR_TEST); glDeleteBuffers(1, &vbo_); } struct BatchKey { - int blendMode = -1; + r_viewport_s viewport{}; bool operator < (BatchKey const& rhs) const { - return blendMode < rhs.blendMode; + return viewport < rhs.viewport; } bool operator == (BatchKey const& rhs) const { @@ -471,18 +379,11 @@ struct AdjacentMergeStrategy : RenderStrategy { switch (cmd->cmd) { case r_layerCmd_s::VIEWPORT: { auto* c = (r_layerCmdViewport_s*)cmd; - nextViewport_ = c->viewport; + latchKey_.viewport = c->viewport; if (showStats_) { // ImGui::Text("VIEWPORT: %dx%d @ %d,%d", c->viewport.width, c->viewport.height, c->viewport.x, c->viewport.y); } } break; - case r_layerCmd_s::BLEND: { - auto* c = (r_layerCmdBlend_s*)cmd; - latchKey_.blendMode = c->blendMode; - if (showStats_) { - // ImGui::Text("BLEND: %s", s_blendModeString.at((r_blendMode_e)c->blendMode)); - } - } break; case r_layerCmd_s::BIND: { auto* c = (r_layerCmdBind_s*)cmd; nextTex_ = c->tex; @@ -500,14 +401,17 @@ struct AdjacentMergeStrategy : RenderStrategy { // ImGui::Text("QUAD"); } + const auto vp = latchKey_.viewport; + // Cull the quad first before it influences any boundary cuts. if (!!renderer_->r_drawCull->intVal) { - auto a = AabbFromCmdQuad(c->quad, nextViewport_); - auto b = AabbFromViewport(nextViewport_); - bool intersects = AabbAabbIntersects(a, b); - if (!intersects) { + const auto minX = *std::min_element(std::begin(c->quad.x), std::end(c->quad.x)); + const auto maxX = *std::max_element(std::begin(c->quad.x), std::end(c->quad.x)); + const auto minY = *std::min_element(std::begin(c->quad.y), std::end(c->quad.y)); + const auto maxY = *std::max_element(std::begin(c->quad.y), std::end(c->quad.y)); + const bool intersects = minX < vp.extent.x && maxX > 0.0f && minY < vp.extent.y && maxY > 0.0f; + if (!intersects) break; - } } // If the current batch is incompatible key-wise, dispatch it to get a fresh @@ -536,22 +440,16 @@ struct AdjacentMergeStrategy : RenderStrategy { Vertex quad[4]{}; for (int v = 0; v < 4; v++) { auto& q = quad[v]; - auto& vp = nextViewport_; q.u = c->quad.s[v]; q.v = c->quad.t[v]; - q.x = c->quad.x[v]; - q.y = c->quad.y[v]; + q.x = c->quad.x[v] + vp.lo.x; + q.y = c->quad.y[v] + vp.lo.y; q.r = tint_[0]; q.g = tint_[1]; q.b = tint_[2]; q.a = tint_[3]; - q.viewX = (float)vp.x; - q.viewY = (float)vp.y; - q.viewW = (float)vp.width; - q.viewH = (float)vp.height; q.texId = (float)texSlot; q.stackIdx = (float)c->quad.stackLayer; - q.maskIdx = (float)c->quad.maskLayer; } // 3-2 // |/| @@ -574,6 +472,8 @@ struct AdjacentMergeStrategy : RenderStrategy { } } + bool UsedIncompleteTextures() const override { return usedIncompleteTextures; }; + private: void Dispatch() { glBindBuffer(GL_ARRAY_BUFFER, vbo_); @@ -582,6 +482,7 @@ struct AdjacentMergeStrategy : RenderStrategy { size_t vertexCount = batch.vertices.size(); glBufferData(GL_ARRAY_BUFFER, vertexCount * sizeof(Vertex), nullptr, GL_STREAM_DRAW); glUseProgram(prog_); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); auto& key = batch_.key; auto& lastKey = lastDispatchKey_; @@ -591,31 +492,19 @@ struct AdjacentMergeStrategy : RenderStrategy { ImGui::Text("%d verts", batch.vertices.size()); } + int virtualW = renderer_->VirtualScreenWidth(); + int virtualH = renderer_->VirtualScreenHeight(); { - auto& vid = renderer_->sys->video->vid; - float fbScaleX = vid.fbSize[0] / (float)vid.size[0]; - float fbScaleY = vid.fbSize[1] / (float)vid.size[1]; - int virtualW = renderer_->VirtualScreenWidth(); - int virtualH = renderer_->VirtualScreenHeight(); glViewport(0, 0, virtualW, virtualH); - Mat4 mvpMatrix = OrthoMatrix(0, virtualW, virtualH, 0, -9999, 9999); - glUniformMatrix4fv(mvpMatrixLoc_, 1, GL_FALSE, mvpMatrix.data()); + glm::vec2 uScreenSize(virtualW, virtualH); + glUniform2fv(uScreenSizeLoc_, 1, glm::value_ptr(uScreenSize)); } - if (!lastKey || lastKey->blendMode != key.blendMode) { + if (!lastKey || lastKey->viewport != key.viewport) { if (showStats_) { - ImGui::Text("New blend mode %s", s_blendModeString.at((r_blendMode_e)key.blendMode)); - } - switch (key.blendMode) { - case RB_ALPHA: - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - break; - case RB_PRE_ALPHA: - glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); - break; - case RB_ADDITIVE: - glBlendFunc(GL_ONE, GL_ONE); - break; + ImGui::Text("New viewport at %d,%d with size %dx%d", key.viewport.lo.x, key.viewport.lo.y, key.viewport.extent.x, key.viewport.extent.y); } + const GLint scissorY = virtualH - key.viewport.extent.y - key.viewport.lo.y; + glScissor(key.viewport.lo.x, scissorY, key.viewport.extent.x, key.viewport.extent.y); } { for (size_t i = 0, numTex = texLocs_.size(); i < numTex; ++i) { @@ -625,7 +514,10 @@ struct AdjacentMergeStrategy : RenderStrategy { auto tex = textures[i]; tex->Bind(); if (showStats_) { - ImGui::Text("New tex %d (%s)", tex->texId, tex->fileName.c_str()); + ImGui::Text("New tex %d (%s) %d", tex->texId, tex->fileName.c_str(), tex->status.load()); + } + if (!usedIncompleteTextures && tex->status != r_tex_c::Status::DONE) { + usedIncompleteTextures = true; } } else { @@ -650,14 +542,14 @@ struct AdjacentMergeStrategy : RenderStrategy { r_renderer_c* renderer_{}; GLuint prog_{}; std::vector texLocs_; - GLint mvpMatrixLoc_{}; + GLint uScreenSizeLoc_{}; size_t batchTextureCap_{}; GLuint vbo_{}; struct TexturedBatch { explicit TexturedBatch(GLuint prog) : batch(prog) { - textures.reserve(1ull << 20); + textures.reserve(128); } BatchKey key{}; @@ -666,7 +558,6 @@ struct AdjacentMergeStrategy : RenderStrategy { }; BatchKey latchKey_{}; - r_viewport_s nextViewport_{}; r_tex_c* nextTex_{}; std::optional lastDispatchKey_; TexturedBatch batch_; @@ -675,9 +566,11 @@ struct AdjacentMergeStrategy : RenderStrategy { size_t totalVertexCount_ = 0; size_t batchIndex = 0; + + bool usedIncompleteTextures = false; }; -void r_layer_c::Render() +bool r_layer_c::Render() { int const optLevel = renderer->r_layerOptimize->intVal; bool const shuffle = renderer->r_layerShuffle->intVal == 1; @@ -715,6 +608,8 @@ void r_layer_c::Render() if (renderer->glPopGroupMarkerEXT) { renderer->glPopGroupMarkerEXT(); } + + return strat->UsedIncompleteTextures(); } void r_layer_c::Discard() @@ -783,102 +678,27 @@ static std::string GetProgramInfoLog(GLuint id) return std::string(msg.data(), msg.data() + len); } -static char const* s_tintedTextureVertexSource = R"(#version 300 es - -uniform mat4 mvp_matrix; - -in vec2 a_vertex; -in vec2 a_texcoord; -in vec4 a_tint; -in vec4 a_viewport; -in vec3 a_texId; - -out vec2 v_screenPos; -out vec2 v_texcoord; -out vec4 v_tint; -out vec4 v_viewport; -out vec3 v_texId; +// ============= +// Init/Shutdown +// ============= -void main(void) +static std::tuple ResourceViewOpenGL(cmrc::file file) { - v_texcoord = a_texcoord; - v_tint = a_tint; - v_texId = a_texId; - vec2 vp0 = a_viewport.xy + vec2(0.0, a_viewport.w); - vec2 vp1 = a_viewport.xy + vec2(a_viewport.z, 0.0); - v_viewport = vec4( - (mvp_matrix * vec4(vp0, 0.0, 1.0)).xy, - (mvp_matrix * vec4(vp1, 0.0, 1.0)).xy); - vec4 pos = mvp_matrix * vec4(a_vertex + a_viewport.xy, 0.0, 1.0); - v_screenPos = pos.xy; - gl_Position = pos; -} -)"; - -static char const* s_tintedTextureFragmentTemplate = R"(#version 300 es -precision mediump float; - -uniform highp sampler2DArray s_tex[{SG_TEXTURE_COUNT}]; -uniform vec4 i_tint; - -in vec2 v_screenPos; -in vec2 v_texcoord; -in vec4 v_tint; -in vec4 v_viewport; // x0, y0, x1, y1 -in vec3 v_texId; - -out vec4 f_fragColor; - -void main(void) -{{ - float x = v_screenPos[0], y = v_screenPos[1]; - if (x < v_viewport[0] || - y < v_viewport[1] || - x >= v_viewport[2] || - y >= v_viewport[3]) {{ - discard; - }} - vec4 color; - {SG_TEXTURE_SWITCH} - f_fragColor = color * v_tint; -}} -)"; - -std::string const s_scaleVsSource = R"(#version 300 es -in vec4 a_position; -in vec2 a_texcoord; - -out vec2 v_texcoord; - -void main(void) { - gl_Position = a_position; - v_texcoord = a_texcoord; + return {(const GLchar*)file.begin(), (GLint)file.size()}; } -)"; - -std::string const s_scaleFsSource = R"(#version 300 es -precision mediump float; - -uniform highp sampler2D s_tex; -in vec2 v_texcoord; - -out vec4 f_fragColor; - -void main(void) { - vec3 color = texture(s_tex, v_texcoord).rgb; - f_fragColor = vec4(color, 1.0); +static std::string_view ResourceStringView(cmrc::file file) +{ + return std::string_view(file.begin(), file.size()); } -)"; - -// ============= -// Init/Shutdown -// ============= void r_renderer_c::Init(r_featureFlag_e features) { sys->con->PrintFunc("Render Init"); + const auto resources = cmrc::SimpleGraphic::get_filesystem(); + frameHashState.reset(XXH3_createState(), XXH3_freeState); + apiDpiAware = !!(features & F_DPI_AWARE); timer_c timer; @@ -961,7 +781,8 @@ void r_renderer_c::Init(r_featureFlag_e features) GLint success = GL_FALSE; GLuint prog = glCreateProgram(); GLuint vs = glCreateShader(GL_VERTEX_SHADER); - glShaderSource(vs, 1, &s_tintedTextureVertexSource, nullptr); + auto [tintVertexSourceText, tintVertexSourceLen] = ResourceViewOpenGL(resources.open("assets/gles/tinted_texture.vert")); + glShaderSource(vs, 1, &tintVertexSourceText, &tintVertexSourceLen); glCompileShader(vs); if (!GetShaderCompileSuccess(vs)) { std::string log = GetShaderInfoLog(vs); @@ -983,18 +804,22 @@ void r_renderer_c::Init(r_featureFlag_e features) } fmt::format_to(fmt::appender(buf), R"( {{ color = texture(s_tex[{}], vec3(v_texcoord, v_texId.y)); - if (v_texId.z > -0.5) - color *= texture(s_tex[{}], vec3(v_texcoord, v_texId.z)); }} )", i, i); } textureSwitch = to_string(buf); } - std::string fragSource = fmt::format(s_tintedTextureFragmentTemplate, - fmt::arg("SG_TEXTURE_COUNT", maxTextureImageUnits), - fmt::arg("SG_TEXTURE_SWITCH", textureSwitch)); - char const* fragSourcePtr = fragSource.c_str(); - glShaderSource(fs, 1, &fragSourcePtr, nullptr); + const auto tintFragmentTemplate = ResourceStringView(resources.open("assets/gles/tinted_texture.frag")); + try { + std::string fragSource = fmt::format(fmt::runtime(tintFragmentTemplate), + fmt::arg("SG_TEXTURE_COUNT", maxTextureImageUnits), + fmt::arg("SG_TEXTURE_SWITCH", textureSwitch)); + char const* fragSourcePtr = fragSource.c_str(); + glShaderSource(fs, 1, &fragSourcePtr, nullptr); + } + catch (std::exception& e) { + sys->Error(u8"Failed to format fragment shader:\n%s", e.what()); + } glCompileShader(fs); if (!GetShaderCompileSuccess(fs)) { std::string log = GetShaderInfoLog(fs); @@ -1044,12 +869,12 @@ void r_renderer_c::Init(r_featureFlag_e features) return id; }; - auto vsId = compileShader(s_scaleVsSource, GL_VERTEX_SHADER); + auto vsId = compileShader(ResourceStringView(resources.open("assets/gles/display_render_target.vert")), GL_VERTEX_SHADER); if (!GetShaderCompileSuccess(vsId)) { auto log = GetShaderInfoLog(vsId); sys->con->Printf("Scaling VS compile failure: %s\n", log.c_str()); } - auto fsId = compileShader(s_scaleFsSource, GL_FRAGMENT_SHADER); + auto fsId = compileShader(ResourceStringView(resources.open("assets/gles/display_render_target.frag")), GL_FRAGMENT_SHADER); if (!GetShaderCompileSuccess(fsId)) { auto log = GetShaderInfoLog(fsId); sys->con->Printf("Scaling FS compile failure: %s\n", log.c_str()); @@ -1105,9 +930,11 @@ void r_renderer_c::Shutdown() sys->con->Printf("Unloading resources...\n"); - ImGui_ImplOpenGL3_Shutdown(); - ImGui_ImplGlfw_Shutdown(); - ImGui::DestroyContext(imguiCtx); + if (imguiCtx) { + ImGui_ImplOpenGL3_Shutdown(); + ImGui_ImplGlfw_Shutdown(); + ImGui::DestroyContext(imguiCtx); + } delete whiteImage; @@ -1152,12 +979,6 @@ void r_renderer_c::Shutdown() void r_renderer_c::PumpShaders() { texMan->ProcessPendingTextureUploads(); - for (size_t idx = 0; idx < numShader; ++idx) - if (auto* sh = shaderList[idx]) - if (auto tex = sh->tex; tex && tex->status != r_tex_c::DONE) { - inhibitElision = true; - break; - } } void r_renderer_c::BeginFrame() @@ -1201,7 +1022,6 @@ void r_renderer_c::BeginFrame() curLayer = layerList[0]; SetViewport(); - SetBlendMode(RB_ALPHA); DrawColor(); beginFrameToc = std::chrono::steady_clock::now(); @@ -1333,20 +1153,18 @@ void r_renderer_c::EndFrame() ImGui::EndDisabled(); CVarCheckbox("Draw command culling", r_drawCull); - size_t totalFootprint{}, totalDenseFootprint{}; + size_t totalDenseFootprint{}; for (int l = 0; l < numLayer; ++l) { size_t byteAcc{}; auto layer = layerSort[l]; size_t const numCmd = layer->numCmd; - totalFootprint += numCmd * sizeof(r_layerCmdQuad_s); // legacy footprint totalDenseFootprint += layer->cmdCursor; } - ImGui::Text("Total payload footprint: %sB", BinaryUnitPrefix(totalFootprint).c_str()); ImGui::Text("Total dense footprint: %sB", BinaryUnitPrefix(totalDenseFootprint).c_str()); size_t totalCmd{}; - if (ImGui::BeginTable("Layer stats", 7, ImGuiTableFlags_Borders | ImGuiTableFlags_SizingFixedFit)) { + if (ImGui::BeginTable("Layer stats", 6, ImGuiTableFlags_Borders | ImGuiTableFlags_SizingFixedFit)) { ImGui::TableSetupColumn("Index"); ImGui::TableSetupColumn("Layer"); ImGui::TableSetupColumn("Sublayer"); @@ -1385,83 +1203,46 @@ void r_renderer_c::EndFrame() if (inhibitElision || elideFrames != !!r_elideFrames->intVal) { elideFrames = !!r_elideFrames->intVal; - lastFrameHash.clear(); + lastFrameHash = 0; } - std::future>> elidedFrameHashFut; + auto tic = std::chrono::high_resolution_clock::now(); + + uint64_t commandDigest = 0; if (elideFrames) { - elidedFrameHashFut = std::async([&]() -> std::optional> { - std::vector commandDigest; - - for (auto lIdx = 0; lIdx < numLayer; ++lIdx) { - auto layer = layerSort[lIdx]; - uint64_t subHash = MurmurHash64A(layer->cmdStorage.data(), (int)layer->cmdCursor, 0ull); - uint8_t const* p = (uint8_t const*)&subHash; - commandDigest.insert(commandDigest.end(), p, p + sizeof(subHash)); - } + auto* frameHasher = frameHashState.get(); + XXH3_64bits_reset(frameHasher); - return commandDigest; - }); - } - else { - std::promise>> p; - elidedFrameHashFut = p.get_future(); - p.set_value({}); - } + for (auto lIdx = 0; lIdx < numLayer; ++lIdx) { + auto layer = layerSort[lIdx]; + uint64_t subHash = XXH3_64bits(layer->cmdStorage.data(), (int)layer->cmdCursor); + XXH3_64bits_update(frameHasher, &subHash, sizeof(subHash)); + } - elidedFrameHashFut.wait(); + commandDigest = XXH3_64bits_digest(frameHasher); + } ++totalFrames; - bool decideDraw = false; - bool elideDraw = false; + const bool elideDraw = lastFrameHash != 0 && lastFrameHash == commandDigest; + if (!elideDraw) { glBindFramebuffer(GL_FRAMEBUFFER, GetDrawRenderTarget().framebuffer); glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); - int l{}; - for (l = 0; l < numLayer; l++) { - if (!decideDraw && elidedFrameHashFut.wait_for(std::chrono::milliseconds(0)) == std::future_status::ready) { - decideDraw = true; - auto commandDigest = elidedFrameHashFut.get(); - if (commandDigest) { - if (*commandDigest == lastFrameHash) { - elideDraw = true; - break; - } - else { - lastFrameHash = *commandDigest; - } - } - else { - lastFrameHash.clear(); - } - } + for (int l = 0; l < numLayer; l++) { auto& layer = layerSort[l]; if (layerBreak && layerBreak->first == layer->layer && layerBreak->second == layer->subLayer) { #ifdef _WIN32 DebugBreak(); #endif } - layer->Render(); - } - if (!elideDraw) { - presentRtt = 1 - presentRtt; - ++drawnFrames; + inhibitElision = layer->Render() || inhibitElision; } + presentRtt = 1 - presentRtt; + ++drawnFrames; } - if (!decideDraw) { - if (auto commandDigest = elidedFrameHashFut.get()) { - lastFrameHash = *commandDigest; - } - else { - lastFrameHash.clear(); - } - } - - if (inhibitElision) { - // If we explicitly inhibited elision due to things like incomplete textures, make sure that the next frame is drawn. - lastFrameHash.clear(); - } + // If we explicitly inhibited elision due to things like incomplete textures, make sure that the next frame is drawn. + lastFrameHash = inhibitElision ? 0 : commandDigest; for (int l = 0; l < numLayer; ++l) { layerSort[l]->Discard(); @@ -1502,7 +1283,7 @@ void r_renderer_c::EndFrame() if (ImGui::Begin("Hash")) { char* b64{}; size_t b64Len{}; - Base64UrlEncode((char const*)lastFrameHash.data(), lastFrameHash.size(), &b64, &b64Len); + Base64UrlEncode((char const*)&lastFrameHash, sizeof(lastFrameHash), &b64, &b64Len); ImGui::Text("%s", b64); free(b64); } @@ -1697,7 +1478,6 @@ void r_renderer_c::SetDrawLayer(int layer, int subLayer) } curLayer = newCurLayer; curLayer->SetViewport(&curViewport); - curLayer->SetBlendMode(curBlendMode); } void r_renderer_c::SetDrawSubLayer(int subLayer) @@ -1717,19 +1497,11 @@ void r_renderer_c::SetViewport(int x, int y, int width, int height) width = VirtualScreenWidth(); height = VirtualScreenHeight(); } - curViewport.x = x; - curViewport.y = y; - curViewport.width = width; - curViewport.height = height; + curViewport.lo = glm::ivec2(x, y); + curViewport.extent = glm::ivec2(width, height); curLayer->SetViewport(&curViewport); } -void r_renderer_c::SetBlendMode(int mode) -{ - curBlendMode = mode; - curLayer->SetBlendMode(mode); -} - void r_renderer_c::DrawColor(const col4_t col) { if (col) { @@ -1759,7 +1531,7 @@ void r_renderer_c::GetDrawColor(col4_t color) color[3] = drawColor[3]; } -void r_renderer_c::DrawImage(r_shaderHnd_c* hnd, glm::vec2 pos, glm::vec2 extent, glm::vec2 uv1, glm::vec2 uv2, int stackLayer, std::optional maskLayer) +void r_renderer_c::DrawImage(r_shaderHnd_c* hnd, glm::vec2 pos, glm::vec2 extent, glm::vec2 uv1, glm::vec2 uv2, int stackLayer) { DrawImageQuad(hnd, pos, @@ -1770,10 +1542,10 @@ void r_renderer_c::DrawImage(r_shaderHnd_c* hnd, glm::vec2 pos, glm::vec2 extent { uv2.s, uv1.t }, uv2, { uv1.s, uv2.t }, - stackLayer, maskLayer); + stackLayer); } -void r_renderer_c::DrawImageQuad(r_shaderHnd_c* hnd, glm::vec2 p0, glm::vec2 p1, glm::vec2 p2, glm::vec2 p3, glm::vec2 uv0, glm::vec2 uv1, glm::vec2 uv2, glm::vec2 uv3, int stackLayer, std::optional maskLayer) +void r_renderer_c::DrawImageQuad(r_shaderHnd_c* hnd, glm::vec2 p0, glm::vec2 p1, glm::vec2 p2, glm::vec2 p3, glm::vec2 uv0, glm::vec2 uv1, glm::vec2 uv2, glm::vec2 uv3, int stackLayer) { if (hnd) { curLayer->Bind(hnd->sh->tex); @@ -1789,7 +1561,7 @@ void r_renderer_c::DrawImageQuad(r_shaderHnd_c* hnd, glm::vec2 p0, glm::vec2 p1, uv1.s, uv1.t, p1.x, p1.y, uv2.s, uv2.t, p2.x, p2.y, uv3.s, uv3.t, p3.x, p3.y, - stackLayer, maskLayer.value_or(-1)); + stackLayer); } void r_renderer_c::DrawString(float x, float y, int align, int height, const col4_t col, int font, const char* str) @@ -2012,74 +1784,3 @@ r_renderer_c::RenderTarget& r_renderer_c::GetPresentRenderTarget() { return rttMain[presentRtt]; } - -// =========================================================== -// MurmurHash implementation from public domain, obtained from -// https://github.com/explosion/murmurhash/blob/9281c4825c24e64476457db89fb1d39bf09b3d23/murmurhash/MurmurHash2.cpp -// =========================================================== - -#if _WIN32 -#define BIG_CONSTANT(x) (x) -#else -#define BIG_CONSTANT(x) (x##LLU) -#endif - -static inline uint64_t MurmurHashGetBlock(const uint64_t* p) -{ -#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) - return *p; -#else - const uint8_t* c = (const uint8_t*)p; - return (uint64_t)c[0] | - (uint64_t)c[1] << 8 | - (uint64_t)c[2] << 16 | - (uint64_t)c[3] << 24 | - (uint64_t)c[4] << 32 | - (uint64_t)c[5] << 40 | - (uint64_t)c[6] << 48 | - (uint64_t)c[7] << 56; -#endif -} - -uint64_t MurmurHash64A(const void* key, int len, uint64_t seed) -{ - const uint64_t m = BIG_CONSTANT(0xc6a4a7935bd1e995); - const int r = 47; - - uint64_t h = seed ^ (len * m); - - const uint64_t* data = (const uint64_t*)key; - const uint64_t* end = data + (len / 8); - - while (data != end) - { - uint64_t k = MurmurHashGetBlock(data++); - - k *= m; - k ^= k >> r; - k *= m; - - h ^= k; - h *= m; - } - - const unsigned char* data2 = (const unsigned char*)data; - - switch (len & 7) - { - case 7: h ^= uint64_t(data2[6]) << 48; - case 6: h ^= uint64_t(data2[5]) << 40; - case 5: h ^= uint64_t(data2[4]) << 32; - case 4: h ^= uint64_t(data2[3]) << 24; - case 3: h ^= uint64_t(data2[2]) << 16; - case 2: h ^= uint64_t(data2[1]) << 8; - case 1: h ^= uint64_t(data2[0]); - h *= m; - }; - - h ^= h >> r; - h *= m; - h ^= h >> r; - - return h; -} diff --git a/engine/render/r_main.h b/engine/render/r_main.h index f7072fb4..04a6b345 100644 --- a/engine/render/r_main.h +++ b/engine/render/r_main.h @@ -15,6 +15,7 @@ #include #include #include +#include // ======= // Classes @@ -22,10 +23,21 @@ // Render viewport struct r_viewport_s { - int x; - int y; - int width; - int height; + glm::ivec2 lo; + glm::ivec2 extent; + + bool operator < (r_viewport_s const& rhs) const { + return std::tie(lo.x, lo.y, extent.x, extent.y) + < std::tie(rhs.lo.x, rhs.lo.y, rhs.extent.x, rhs.extent.y); + } + + bool operator == (r_viewport_s const& rhs) const { + return !(*this < rhs) && !(rhs < *this); + } + + bool operator != (r_viewport_s const& rhs) const { + return !(*this == rhs); + } }; // Render layer @@ -42,11 +54,10 @@ class r_layer_c { ~r_layer_c(); void SetViewport(r_viewport_s* viewport); - void SetBlendMode(int mode); void Bind(r_tex_c* tex); void Color(col4_t col); - void Quad(float s0, float t0, float x0, float y0, float s1, float t1, float x1, float y1, float s2, float t2, float x2, float y2, float s3, float t3, float x3, float y3, int stackLayer = 0, int maskLayer = -1); - void Render(); + void Quad(float s0, float t0, float x0, float y0, float s1, float t1, float x1, float y1, float s2, float t2, float x2, float y2, float s3, float t3, float x3, float y3, int stackLayer = 0); + bool Render(); void Discard(); struct CmdHandle { @@ -86,12 +97,11 @@ class r_renderer_c: public r_IRenderer, public conCmdHandler_c { void SetDrawSubLayer(int subLayer); int GetDrawLayer(); void SetViewport(int x = 0, int y = 0, int width = 0, int height = 0); - void SetBlendMode(int mode); void DrawColor(const col4_t col = NULL); void DrawColor(dword col); void GetDrawColor(col4_t color); - void DrawImage(r_shaderHnd_c* hnd, glm::vec2 pos, glm::vec2 extent, glm::vec2 uv1 = { 0, 0 }, glm::vec2 uv2 = { 1, 1 }, int stackLayer = 0, std::optional maskLayer = {}); - void DrawImageQuad(r_shaderHnd_c* hnd, glm::vec2 p0, glm::vec2 p1, glm::vec2 p2, glm::vec2 p3, glm::vec2 uv0 = { 0, 0 }, glm::vec2 uv1 = { 1, 0 }, glm::vec2 uv2 = { 1, 1 }, glm::vec2 uv3 = { 0, 1 }, int stackLayer = 0, std::optional maskLayer = {}); + void DrawImage(r_shaderHnd_c* hnd, glm::vec2 pos, glm::vec2 extent, glm::vec2 uv1 = { 0, 0 }, glm::vec2 uv2 = { 1, 1 }, int stackLayer = 0 ); + void DrawImageQuad(r_shaderHnd_c* hnd, glm::vec2 p0, glm::vec2 p1, glm::vec2 p2, glm::vec2 p3, glm::vec2 uv0 = { 0, 0 }, glm::vec2 uv1 = { 1, 0 }, glm::vec2 uv2 = { 1, 1 }, glm::vec2 uv3 = { 0, 1 }, int stackLayer = 0); void DrawString(float x, float y, int align, int height, const col4_t col, int font, const char* str); void DrawStringFormat(float x, float y, int align, int height, const col4_t col, int font, const char* fmt, ...); int DrawStringWidth(int height, int font, const char* str); @@ -147,8 +157,7 @@ class r_renderer_c: public r_IRenderer, public conCmdHandler_c { col4_t drawColor = {}; // Current draw color - r_viewport_s curViewport; // Current viewport - int curBlendMode = 0; // Current blend mode + r_viewport_s curViewport; // Current viewport int numShader = 0; class r_shader_c *shaderList[R_MAXSHADERS] = {}; @@ -180,7 +189,8 @@ class r_renderer_c: public r_IRenderer, public conCmdHandler_c { RenderTarget rttMain[2]; int presentRtt = 0; - std::vector lastFrameHash{}; + std::shared_ptr frameHashState; + uint64_t lastFrameHash{}; uint64_t totalFrames{}; uint64_t drawnFrames{}; diff --git a/libs/luautf8 b/libs/luautf8 index 1bb70d45..d65ebfa4 160000 --- a/libs/luautf8 +++ b/libs/luautf8 @@ -1 +1 @@ -Subproject commit 1bb70d45208d4033dcc75efee968be70534dd3ab +Subproject commit d65ebfa4a00d6e582970ab729013bb2a629e74c9 diff --git a/ui_api.cpp b/ui_api.cpp index 5ca7a322..73f40fc0 100644 --- a/ui_api.cpp +++ b/ui_api.cpp @@ -60,8 +60,8 @@ ** GetDrawLayer() ** SetViewport([x, y, width, height]) ** SetDrawColor(red, green, blue[, alpha]) / SetDrawColor("") -** DrawImage({imgHandle|nil}, left, top, width, height[, tcLeft, tcTop, tcRight, tcBottom][, stackIdx[, maskIdx]]) maskIdx: use a stack layer as multiplicative mask -** DrawImageQuad({imgHandle|nil}, x1, y1, x2, y2, x3, y3, x4, y4[, s1, t1, s2, t2, s3, t3, s4, t4][, stackIdx[, maskIdx]]) +** DrawImage({imgHandle|nil}, left, top, width, height[, tcLeft, tcTop, tcRight, tcBottom][, stackIdx]) +** DrawImageQuad({imgHandle|nil}, x1, y1, x2, y2, x3, y3, x4, y4[, s1, t1, s2, t2, s3, t3, s4, t4][, stackIdx]) ** DrawString(left, top, align{"LEFT"|"CENTER"|"RIGHT"|"CENTER_X"|"RIGHT_X"}, height, font{"FIXED"|"VAR"|"VAR BOLD"|"FONTIN SC"|"FONTIN SC ITALIC"|"FONTIN"|"FONTIN ITALIC"}, "") ** width = DrawStringWidth(height, font{"FIXED"|"VAR"|"VAR BOLD"|"FONTIN SC"|"FONTIN SC ITALIC"|"FONTIN"|"FONTIN ITALIC"}, "") ** index = DrawStringCursorIndex(height, font{"FIXED"|"VAR"|"VAR BOLD"|"FONTIN SC"|"FONTIN SC ITALIC"|"FONTIN"|"FONTIN ITALIC"}, "", cursorX, cursorY) @@ -813,18 +813,6 @@ static int l_SetViewport(lua_State* L) return 0; } -static int l_SetBlendMode(lua_State* L) -{ - ui_main_c* ui = GetUIPtr(L); - ui->LAssert(L, ui->renderer != NULL, "Renderer is not initialised"); - ui->LAssert(L, ui->renderEnable, "SetViewport() called outside of OnFrame"); - int n = lua_gettop(L); - ui->LAssert(L, n >= 1, "Usage: SetBlendMode(mode)"); - static const char* modeMap[6] = { "ALPHA", "PREALPHA", "ADDITIVE", NULL }; - ui->renderer->SetBlendMode(luaL_checkoption(L, 1, "ALPHA", modeMap)); - return 0; -} - static int l_SetDrawColor(lua_State* L) { ui_main_c* ui = GetUIPtr(L); @@ -894,7 +882,7 @@ static int l_DrawImage(lua_State* L) ui->LAssert(L, ui->renderer != NULL, "Renderer is not initialised"); ui->LAssert(L, ui->renderEnable, "DrawImage() called outside of OnFrame"); int n = lua_gettop(L); - const char* usage = "Usage: DrawImage({imgHandle|nil}, left, top, width, height[, tcLeft, tcTop, tcRight, tcBottom][, stackIdx[, mask]])"; + const char* usage = "Usage: DrawImage({imgHandle|nil}, left, top, width, height[, tcLeft, tcTop, tcRight, tcBottom][, stackIdx])"; ui->LAssert(L, n >= 5, usage); if (!lua_isnil(L, 1) && !ui->IsUserData(L, 1, "uiimghandlemeta")) { @@ -904,23 +892,18 @@ static int l_DrawImage(lua_State* L) r_shaderHnd_c* hnd = NULL; glm::vec2 xys[2]{}, uvs[2]{}; int stackLayer = 0; - std::optional maskLayer{}; - // | n |img| corners | uvs | stack | mask | - // | 5 | X | X | | | | - // | 6 | X | X | | X | | - // | 7 | X | X | | X | X | - // | 9 | X | X | X | | | - // | 10 | X | X | X | X | | - // | 11 | X | X | X | X | X | + // | n |img| corners | uvs | stack | + // | 5 | X | X | | | + // | 6 | X | X | | X | + // | 9 | X | X | X | | + // | 10 | X | X | X | X | - enum ArgFlag : uint8_t { AF_IMG = 0x1, AF_XY = 0x2, AF_UV = 0x4, AF_STACK = 0x8, AF_MASK = 0x10 }; + enum ArgFlag : uint8_t { AF_IMG = 0x1, AF_XY = 0x2, AF_UV = 0x4, AF_STACK = 0x8 }; ArgFlag af{}; switch (n) { - case 11: af = (ArgFlag)(af | AF_MASK); case 10: af = (ArgFlag)(af | AF_STACK); case 9: af = (ArgFlag)(af | AF_IMG | AF_XY | AF_UV); break; - case 7: af = (ArgFlag)(af | AF_MASK); case 6: af = (ArgFlag)(af | AF_STACK); case 5: af = (ArgFlag)(af | AF_IMG | AF_XY); break; default: ui->LAssert(L, false, usage); @@ -987,23 +970,7 @@ static int l_DrawImage(lua_State* L) k += 1; } - if (af & AF_MASK) { - if (!lua_isnil(L, k)) { - int isInt; - int val = (int)lua_tointegerx(L, k, &isInt); - - if (!isInt) { - ui->LAssert(L, false, "DrawImage() argument %d: expected integer or nil, got %s", k, luaL_typename(L, k)); - } - ui->LAssert(L, val > 0, "DrawImage() argument %d: expected positive integer, got %d", k, val); - if (maxStackValue.has_value()) - ui->LAssert(L, val <= *maxStackValue, "DrawImage() argument %d: expected valid stack index <= %d, got %d", k, *maxStackValue, val); - maskLayer = val - 1; - } - k += 1; - } - - ui->renderer->DrawImage(hnd, xys[0], xys[1], uvs[0], uvs[1], stackLayer, maskLayer); + ui->renderer->DrawImage(hnd, xys[0], xys[1], uvs[0], uvs[1], stackLayer); return 0; } @@ -1014,7 +981,7 @@ static int l_DrawImageQuad(lua_State* L) ui->LAssert(L, ui->renderer != NULL, "Renderer is not initialised"); ui->LAssert(L, ui->renderEnable, "DrawImageQuad() called outside of OnFrame"); int n = lua_gettop(L); - const char* usage = "Usage: DrawImageQuad({imgHandle|nil}, x1, y1, x2, y2, x3, y3, x4, y4[, s1, t1, s2, t2, s3, t3, s4, t4][, stackIdx[, mask]])"; + const char* usage = "Usage: DrawImageQuad({imgHandle|nil}, x1, y1, x2, y2, x3, y3, x4, y4[, s1, t1, s2, t2, s3, t3, s4, t4][, stackIdx])"; ui->LAssert(L, n >= 9, usage); if (!lua_isnil(L, 1) && ! ui->IsUserData(L, 1, "uiimghandlemeta")) { ui->LAssert(L, false, "DrawImageQuad() argument 1: expected image handle or nil, got %s", luaL_typename(L, 1)); @@ -1023,23 +990,18 @@ static int l_DrawImageQuad(lua_State* L) r_shaderHnd_c* hnd = NULL; glm::vec2 xys[4]{}, uvs[4]{}; int stackLayer = 0; - std::optional maskLayer{}; - // | n |img| corners | uvs | stack | mask | - // | 9 | X | X | | | | - // | 10 | X | X | | X | | - // | 11 | X | X | | X | X | - // | 17 | X | X | X | | | - // | 18 | X | X | X | X | | - // | 19 | X | X | X | X | X | - - enum ArgFlag : uint8_t { AF_IMG = 0x1, AF_XY = 0x2, AF_UV = 0x4, AF_STACK = 0x8, AF_MASK = 0x10 }; + // | n |img| corners | uvs | stack | + // | 9 | X | X | | | + // | 10 | X | X | | X | + // | 17 | X | X | X | | + // | 18 | X | X | X | X | + + enum ArgFlag : uint8_t { AF_IMG = 0x1, AF_XY = 0x2, AF_UV = 0x4, AF_STACK = 0x8 }; ArgFlag af{}; switch (n) { - case 19: af = (ArgFlag)(af | AF_MASK); case 18: af = (ArgFlag)(af | AF_STACK); case 17: af = (ArgFlag)(af | AF_IMG | AF_XY | AF_UV); break; - case 11: af = (ArgFlag)(af | AF_MASK); case 10: af = (ArgFlag)(af | AF_STACK); case 9: af = (ArgFlag)(af | AF_IMG | AF_XY); break; default: ui->LAssert(L, false, usage); @@ -1108,25 +1070,7 @@ static int l_DrawImageQuad(lua_State* L) k += 1; } - if (af & AF_MASK) { - if (!lua_isnil(L, k)) { - int isInt; - const int val = (int)lua_tointegerx(L, k, &isInt); - - if (!isInt) { - ui->LAssert(L, false, "DrawImageQuad() argument %d: expected integer or nil, got %s", k, luaL_typename(L, k)); - } - ui->LAssert(L, val > 0, "DrawImageQuad() argument %d: expected positive integer, got %d", k, val); - if (maxStackValue.has_value()) - ui->LAssert(L, val <= *maxStackValue, "DrawImageQuad() argument %d: expected valid stack index <= %d, got %d", k, *maxStackValue, val); - - maskLayer = val - 1; - } - k += 1; - } - - - ui->renderer->DrawImageQuad(hnd, xys[0], xys[1], xys[2], xys[3], uvs[0], uvs[1], uvs[2], uvs[3], stackLayer, maskLayer); + ui->renderer->DrawImageQuad(hnd, xys[0], xys[1], xys[2], xys[3], uvs[0], uvs[1], uvs[2], uvs[3], stackLayer); return 0; } @@ -2274,7 +2218,6 @@ int ui_main_c::InitAPI(lua_State* L) ADDFUNC(SetDrawLayer); ADDFUNC(GetDrawLayer); ADDFUNC(SetViewport); - ADDFUNC(SetBlendMode); ADDFUNC(SetDrawColor); ADDFUNC(GetDrawColor); ADDFUNC(SetDPIScaleOverridePercent); diff --git a/vcpkg b/vcpkg index 66c0373d..04a9d8e5 160000 --- a/vcpkg +++ b/vcpkg @@ -1 +1 @@ -Subproject commit 66c0373dc7fca549e5803087b9487edfe3aca0a1 +Subproject commit 04a9d8e5212d01ee1dd9478eadd9caade4f8b0d4 diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json index ab524ed0..f697b257 100644 --- a/vcpkg-configuration.json +++ b/vcpkg-configuration.json @@ -1,13 +1,13 @@ { "default-registry": { "kind": "builtin", - "baseline": "66c0373dc7fca549e5803087b9487edfe3aca0a1" + "baseline": "04a9d8e5212d01ee1dd9478eadd9caade4f8b0d4" }, "registries": [ { "kind": "filesystem", "path": "vcpkg-ports", - "baseline": "2026-07-22", + "baseline": "2026-09-09", "packages": ["glfw3", "gli", "luajit"] } ] diff --git a/vcpkg-ports/ports/gli/2026-09-09/ignore-vendored-glm.patch b/vcpkg-ports/ports/gli/2026-09-09/ignore-vendored-glm.patch new file mode 100644 index 00000000..c16bc7e7 --- /dev/null +++ b/vcpkg-ports/ports/gli/2026-09-09/ignore-vendored-glm.patch @@ -0,0 +1,12 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b705dbaf..a7d8f70c 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -115,7 +115,6 @@ add_library(gli INTERFACE) + target_include_directories(gli INTERFACE + $ + $ +- $ + ) + install(TARGETS gli EXPORT gliTargets) + diff --git a/vcpkg-ports/ports/gli/2026-09-09/portfile.cmake b/vcpkg-ports/ports/gli/2026-09-09/portfile.cmake new file mode 100644 index 00000000..ea19e0ad --- /dev/null +++ b/vcpkg-ports/ports/gli/2026-09-09/portfile.cmake @@ -0,0 +1,30 @@ +#header-only library + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO g-truc/gli + REF 3542f8830178061e0661f5df1e89d36ba7d7b0ab + SHA512 785eba47f08c033b38ebb5ce61ec7a8fd69faf95478da0f47d5d01dce07b89dbc15c33079b4fe9361b0541dd5194d229b635bed747fc4f099f6ea1fbd292b3ba + HEAD_REF master + PATCHES + ignore-vendored-glm.patch + pr-197-fix-static_assert.patch + pr-197-remove-make_vec4-conflict.patch +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS "-DGLI_TEST_ENABLE=OFF" +) + +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/gli) + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug") +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/lib") +file(REMOVE "${CURRENT_PACKAGES_DIR}/include/gli/CMakeLists.txt") + +# Put the license file where vcpkg expects it +# manual.md contains the "licenses" section for the project +file(INSTALL "${SOURCE_PATH}/manual.md" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) \ No newline at end of file diff --git a/vcpkg-ports/ports/gli/2026-09-09/pr-197-fix-static_assert.patch b/vcpkg-ports/ports/gli/2026-09-09/pr-197-fix-static_assert.patch new file mode 100644 index 00000000..ac4f60a1 --- /dev/null +++ b/vcpkg-ports/ports/gli/2026-09-09/pr-197-fix-static_assert.patch @@ -0,0 +1,23 @@ +From a12695bed72c7a49b772b868ac1c9c16178a720f Mon Sep 17 00:00:00 2001 +From: Beato +Date: Mon, 2 Feb 2026 11:14:21 -0300 +Subject: [PATCH] Update old GLM < 0.9.9 "GLM_STATIC_ASSERT" macro to C++11 + static_assert + +--- + gli/core/format.inl | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/gli/core/format.inl b/gli/core/format.inl +index 180bf4f74..17744fcb3 100644 +--- a/gli/core/format.inl ++++ b/gli/core/format.inl +@@ -279,7 +279,7 @@ namespace detail + { 1, glm::u8vec3(1, 1, 1), 3, swizzles(SWIZZLE_RED, SWIZZLE_GREEN, SWIZZLE_BLUE, SWIZZLE_ONE), CAP_PACKED8_BIT | CAP_NORMALIZED_BIT | CAP_UNSIGNED_BIT | CAP_DDS_GLI_EXT_BIT}, //FORMAT_RG3B2_UNORM_PACK8, + }; + +- GLM_STATIC_ASSERT(sizeof(Table) / sizeof(Table[0]) == FORMAT_COUNT, "GLI error: format descriptor list doesn't match number of supported formats"); ++ static_assert( sizeof(Table) / sizeof(Table[0]) == FORMAT_COUNT, "GLI error: format descriptor list doesn't match number of supported formats" ); + GLI_ASSERT(Format != FORMAT_UNDEFINED); + + return Table[Format - FORMAT_FIRST]; diff --git a/vcpkg-ports/ports/gli/2026-09-09/pr-197-remove-make_vec4-conflict.patch b/vcpkg-ports/ports/gli/2026-09-09/pr-197-remove-make_vec4-conflict.patch new file mode 100644 index 00000000..17ec90f2 --- /dev/null +++ b/vcpkg-ports/ports/gli/2026-09-09/pr-197-remove-make_vec4-conflict.patch @@ -0,0 +1,83 @@ +From 7c561c636cc2c5aebc433b63513cfc6c3bb53670 Mon Sep 17 00:00:00 2001 +From: Beato +Date: Mon, 2 Feb 2026 11:46:59 -0300 +Subject: [PATCH] remove GLI GLM "make_vec4" conflict + +--- + gli/core/convert_func.hpp | 8 ++++---- + gli/type.hpp | 25 +------------------------ + 2 files changed, 5 insertions(+), 28 deletions(-) + +diff --git a/gli/core/convert_func.hpp b/gli/core/convert_func.hpp +index 8f3e7a88a..b9bcede9f 100644 +--- a/gli/core/convert_func.hpp ++++ b/gli/core/convert_func.hpp +@@ -176,7 +176,7 @@ namespace detail + + static vec<4, retType, P> fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { +- return make_vec4(vec(access::load(Texture, TexelCoord, Layer, Face, Level))); ++ return glm::make_vec4(vec(access::load(Texture, TexelCoord, Layer, Face, Level))); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, vec<4, retType, P> const & Texel) +@@ -205,7 +205,7 @@ namespace detail + static vec<4, retType, P> fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_NORM requires a float sampler"); +- return make_vec4(compNormalize(access::load(Texture, TexelCoord, Layer, Face, Level))); ++ return glm::make_vec4(compNormalize(access::load(Texture, TexelCoord, Layer, Face, Level))); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, vec<4, retType, P> const & Texel) +@@ -223,7 +223,7 @@ namespace detail + static vec<4, retType, P> fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_SRGB requires a float sampler"); +- return make_vec4(convertSRGBToLinear(compNormalize(access::load(Texture, TexelCoord, Layer, Face, Level)))); ++ return glm::make_vec4(convertSRGBToLinear(compNormalize(access::load(Texture, TexelCoord, Layer, Face, Level)))); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, vec<4, retType, P> const & Texel) +@@ -277,7 +277,7 @@ namespace detail + static vec<4, retType, P> fetch(textureType const & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level) + { + static_assert(std::numeric_limits::is_iec559, "CONVERT_MODE_HALF requires a float sampler"); +- return make_vec4(vec(unpackHalf(access::load(Texture, TexelCoord, Layer, Face, Level)))); ++ return glm::make_vec4(vec(unpackHalf(access::load(Texture, TexelCoord, Layer, Face, Level)))); + } + + static void write(textureType & Texture, typename textureType::extent_type const & TexelCoord, typename textureType::size_type Layer, typename textureType::size_type Face, typename textureType::size_type Level, vec<4, retType, P> const & Texel) +diff --git a/gli/type.hpp b/gli/type.hpp +index 6b88cede2..e38220aaf 100644 +--- a/gli/type.hpp ++++ b/gli/type.hpp +@@ -40,27 +40,4 @@ namespace gli + typedef ivec3 extent3d; + typedef ivec4 extent4d; + +- template +- inline vec<4, T, P> make_vec4(vec<1, T, P> const & v) +- { +- return vec<4, T, P>(v.x, static_cast(0), static_cast(0), static_cast(1)); +- } +- +- template +- inline vec<4, T, P> make_vec4(vec<2, T, P> const & v) +- { +- return vec<4, T, P>(v.x, v.y, static_cast(0), static_cast(1)); +- } +- +- template +- inline vec<4, T, P> make_vec4(vec<3, T, P> const & v) +- { +- return vec<4, T, P>(v.x, v.y, v.z, static_cast(1)); +- } +- +- template +- inline vec<4, T, P> make_vec4(vec<4, T, P> const & v) +- { +- return v; +- } +-}//namespace gli ++} //namespace gli diff --git a/vcpkg-ports/ports/gli/2026-09-09/vcpkg.json b/vcpkg-ports/ports/gli/2026-09-09/vcpkg.json new file mode 100644 index 00000000..4ae5b2e3 --- /dev/null +++ b/vcpkg-ports/ports/gli/2026-09-09/vcpkg.json @@ -0,0 +1,18 @@ +{ + "name": "gli", + "version-date": "2026-09-09", + "port-version": 0, + "description": "OpenGL Image (GLI)", + "homepage": "https://gli.g-truc.net", + "dependencies": [ + "glm", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/vcpkg-ports/versions/baseline.json b/vcpkg-ports/versions/baseline.json index 7b4c091f..4bb72631 100644 --- a/vcpkg-ports/versions/baseline.json +++ b/vcpkg-ports/versions/baseline.json @@ -16,5 +16,10 @@ "glfw3": { "baseline": "3.4", "port-version": 1 }, "gli": { "baseline": "2021-07-06", "port-version": 3 }, "luajit": { "baseline": "2026-07-20", "port-version": 1 } + }, + "2026-09-09": { + "glfw3": { "baseline": "3.4", "port-version": 1 }, + "gli": { "baseline": "2026-09-09", "port-version": 0 }, + "luajit": { "baseline": "2026-07-20", "port-version": 1 } } } \ No newline at end of file diff --git a/vcpkg-ports/versions/g-/gli.json b/vcpkg-ports/versions/g-/gli.json index e0edf1ef..f41753ae 100644 --- a/vcpkg-ports/versions/g-/gli.json +++ b/vcpkg-ports/versions/g-/gli.json @@ -1,5 +1,10 @@ { "versions": [ + { + "version-date": "2026-09-09", + "port-version": 0, + "path": "$/ports/gli/2026-09-09" + }, { "version-date": "2021-07-06", "port-version": 3, diff --git a/vcpkg.json b/vcpkg.json index 31e24967..3f981210 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -8,16 +8,19 @@ "features": [ "metal" ], "platform": "osx" }, + "cmakerc", "curl", "fmt", "glfw3", "gli", + "glm", "libwebp", "luajit", "ms-gsl", "pkgconf", "re2", "sol2", + "xxhash", "zstd", "zlib" ]