Skip to content

Commit

Permalink
Merge branch 'master' into as/3d_surface_glmakie
Browse files Browse the repository at this point in the history
  • Loading branch information
asinghvi17 authored Oct 15, 2024
2 parents 84d6e89 + 97a8bb0 commit 46067b6
Show file tree
Hide file tree
Showing 64 changed files with 1,419 additions and 418 deletions.
24 changes: 24 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
<!--
* Any PR that is not ready for review should be created as a draft PR.
* Please don't force push to PRs, it removes the history, creates bad notifications, and we will squash and merge in the end anyways.
* Feel free to ping for a review when it passes all tests after a few days (@simondanisch, @ffreyer). We can't guarantee a review in a certain time frame, but we can guarantee to forget about PRs after a while.
* Allowing write access on the PR makes things more convenient, since we can make edits to the PR directly and update it if it gets out of sync with `master` (should be automatic if not disabled).
* Please understand, that some PRs will take very long to get merged. You can do a few things to optimize the time to get it merged:
* The more tests you add, the easier it is to see that your change works without putting the work on us.
* The clearer the problem being solved the easier. A PR best only addresses one bug fix or feature.
* The more you explain the motivation or describe your feature (best with pictures), the easier it will be for us to priorize the PR.
* Changes with more ambigious benefits are best discussed in a github [discussion](https://github.com/MakieOrg/Makie.jl/discussions) before a PR.
* What deserves a unit test or a reference image test isn't easy to decide, but here are a few pointers:
* Makie unit tests are preferable, since they're fast to execute and easy to maintain, so if you can add tests to `Makie/src/test`
* For new recipes or any changes that may get rendered differently by the backends, one should add a reference image test to the best fitting file in `Makie\ReferenceTests\src\tests\**` looking like this:
```julia
@reference_test "name of test" begin
# code of test
...
# make sure the last line is a Figure, FigureAxisPlot or Scene
end
```
Adding a reference image test will let your PR fail with the status "n reference images missing", which a maintainer will need to approve and fix.
Ideally, a comment with a screenshot of the expected output of the reference image test should be added to the PR.
We prefer one reference image test with many subplots over multiple reference image tests.
-->
# Description

Fixes # (issue)
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/Docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Install Julia
uses: julia-actions/setup-julia@v2
with:
version: '1'
version: '1.10'
- uses: julia-actions/cache@v2
- name: Build and deploy docs
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
matrix:
version:
- '1.6'
- '1' # automatically expands to the latest stable 1.x release of Julia
- '1.10'
os:
- ubuntu-20.04
arch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/compilation-benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y xorg-dev mesa-utils xvfb libgl1 freeglut3-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libxext-dev
- uses: julia-actions/setup-julia@v2
with:
version: '1'
version: '1.10'
arch: x64
- uses: julia-actions/cache@v2
- name: Benchmark
Expand Down
15 changes: 8 additions & 7 deletions .github/workflows/reference_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
matrix:
version:
- '1.6'
- '1' # automatically expands to the latest stable 1.x release of Julia
- '1.10'
os:
- ubuntu-20.04
arch:
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
matrix:
version:
- '1.6'
- '1' # automatically expands to the latest stable 1.x release of Julia
- '1.10'
os:
- ubuntu-20.04
arch:
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
matrix:
version:
- '1.6'
- '1' # automatically expands to the latest stable 1.x release of Julia
- '1.10'
os:
- ubuntu-20.04
arch:
Expand Down Expand Up @@ -172,15 +172,15 @@ jobs:
steps:
- uses: actions/download-artifact@v4
with:
name: ReferenceImages_WGLMakie_1
name: ReferenceImages_WGLMakie_1.10
path: ./ReferenceImages/WGLMakie
- uses: actions/download-artifact@v4
with:
name: ReferenceImages_CairoMakie_1
name: ReferenceImages_CairoMakie_1.10
path: ./ReferenceImages/CairoMakie
- uses: actions/download-artifact@v4
with:
name: ReferenceImages_GLMakie_1
name: ReferenceImages_GLMakie_1.10
path: ./ReferenceImages/GLMakie
- name: Consolidate reference image folders
run: |
Expand All @@ -198,9 +198,10 @@ jobs:
# Loop through the directories and concatenate the files, and copy recorded folders
for dir in WGLMakie CairoMakie GLMakie; do
# Concatenate scores.tsv and new_files.txt
# Concatenate scores.tsv, new_files.txt and missing_files.txt
cat "${baseDir}/${dir}/scores.tsv" >> "./ReferenceImagesCombined/scores.tsv"
cat "${baseDir}/${dir}/new_files.txt" >> "./ReferenceImagesCombined/new_files.txt"
cat "${baseDir}/${dir}/missing_files.txt" >> "./ReferenceImagesCombined/missing_files.txt"
# Copy recorded folder
mkdir -p "./ReferenceImagesCombined/recorded/${dir}/"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/relocatability.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1' # automatically expands to the latest stable 1.x release of Julia
- '1.10'
os:
- ubuntu-20.04
arch:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rprmakie.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1' # automatically expands to the latest stable 1.x release of Julia
- '1.10'
os:
- ubuntu-20.04
arch:
Expand Down
19 changes: 16 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@

## [Unreleased]

- Fix `merge(attr1, attr2)` modifying nested attributes in `attr1` [#4416](https://github.com/MakieOrg/Makie.jl/pull/4416)
- Improved performance of `record` by avoiding unnecessary copying in common cases [#4475](https://github.com/MakieOrg/Makie.jl/pull/4475).

## [0.21.14] - 2024-10-11

- Fixed relocatability of GLMakie [#4461](https://github.com/MakieOrg/Makie.jl/pull/4461).
- Fixed relocatability of WGLMakie [#4467](https://github.com/MakieOrg/Makie.jl/pull/4467).
- Fixed `space` keyword for `barplot` [#4435](https://github.com/MakieOrg/Makie.jl/pull/4435).

## [0.21.13] - 2024-10-07

- Optimize SpecApi, re-use Blocks better and add API to access the created block objects [#4354](https://github.com/MakieOrg/Makie.jl/pull/4354).
- Fixed `merge(attr1, attr2)` modifying nested attributes in `attr1` [#4416](https://github.com/MakieOrg/Makie.jl/pull/4416)
- Fixed issue with CairoMakie rendering scene backgrounds at the wrong position [#4425](https://github.com/MakieOrg/Makie.jl/pull/4425)
- Fix incorrect inverse transformation in `position_on_plot` for lines, causing incorrect tooltip placement in DataInspector [#4402](https://github.com/MakieOrg/Makie.jl/pull/4402)
- Fixed incorrect inverse transformation in `position_on_plot` for lines, causing incorrect tooltip placement in DataInspector [#4402](https://github.com/MakieOrg/Makie.jl/pull/4402)
- Added new `Checkbox` block [#4336](https://github.com/MakieOrg/Makie.jl/pull/4336).
- Added ability to override legend element attributes by pairing labels or plots with override attributes [#4427](https://github.com/MakieOrg/Makie.jl/pull/4427).
- Added threshold before a drag starts which improves false negative rates for clicks. `Button` can now trigger on click and not mouse-down which is the canonical behavior in other GUI systems [#4336](https://github.com/MakieOrg/Makie.jl/pull/4336).
Expand Down Expand Up @@ -619,7 +630,9 @@ All other changes are collected [in this PR](https://github.com/MakieOrg/Makie.j
- Fixed rendering of `heatmap`s with one or more reversed ranges in CairoMakie, as in `heatmap(1:10, 10:-1:1, rand(10, 10))` [#1100](https://github.com/MakieOrg/Makie.jl/pull/1100).
- Fixed volume slice recipe and added docs for it [#1123](https://github.com/MakieOrg/Makie.jl/pull/1123).

[Unreleased]: https://github.com/MakieOrg/Makie.jl/compare/v0.21.12...HEAD
[Unreleased]: https://github.com/MakieOrg/Makie.jl/compare/v0.21.14...HEAD
[0.21.14]: https://github.com/MakieOrg/Makie.jl/compare/v0.21.13...v0.21.14
[0.21.13]: https://github.com/MakieOrg/Makie.jl/compare/v0.21.12...v0.21.13
[0.21.12]: https://github.com/MakieOrg/Makie.jl/compare/v0.21.11...v0.21.12
[0.21.11]: https://github.com/MakieOrg/Makie.jl/compare/v0.21.10...v0.21.11
[0.21.10]: https://github.com/MakieOrg/Makie.jl/compare/v0.21.9...v0.21.10
Expand Down
4 changes: 2 additions & 2 deletions CairoMakie/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "CairoMakie"
uuid = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
author = ["Simon Danisch <sdanisch@gmail.com>"]
version = "0.12.12"
version = "0.12.14"

[deps]
CRC32c = "8bf52ea8-c179-5cab-976a-9e18b702a9bc"
Expand All @@ -24,7 +24,7 @@ FileIO = "1.1"
FreeType = "3, 4.0"
GeometryBasics = "0.4.11"
LinearAlgebra = "1.0, 1.6"
Makie = "=0.21.12"
Makie = "=0.21.14"
PrecompileTools = "1.0"
julia = "1.3"

Expand Down
2 changes: 1 addition & 1 deletion CairoMakie/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ functions = [:volume, :volume!, :uv_mesh]
CairoMakie.activate!(type = "png", px_per_unit = 1)
ReferenceTests.mark_broken_tests(excludes, functions=functions)
recorded_files, recording_dir = @include_reference_tests CairoMakie "refimages.jl"
missing_images, scores = ReferenceTests.record_comparison(recording_dir)
missing_images, scores = ReferenceTests.record_comparison(recording_dir, "CairoMakie")
ReferenceTests.test_comparison(scores; threshold = 0.05)
end

Expand Down
4 changes: 2 additions & 2 deletions GLMakie/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "GLMakie"
uuid = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
version = "0.10.12"
version = "0.10.14"

[deps]
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Expand Down Expand Up @@ -30,7 +30,7 @@ FreeTypeAbstraction = "0.10"
GLFW = "3.4.3"
GeometryBasics = "0.4.11"
LinearAlgebra = "1.0, 1.6"
Makie = "=0.21.12"
Makie = "=0.21.14"
Markdown = "1.0, 1.6"
MeshIO = "0.4"
ModernGL = "1"
Expand Down
Binary file removed GLMakie/assets/loading.bin
Binary file not shown.
35 changes: 23 additions & 12 deletions GLMakie/src/GLMakie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,42 @@ function ShaderSource(path)
return ShaderSource(typ, source, name)
end

const GL_ASSET_DIR = RelocatableFolders.@path joinpath(@__DIR__, "..", "assets")
const SHADER_DIR = RelocatableFolders.@path joinpath(GL_ASSET_DIR, "shader")
const SHADER_DIR = normpath(joinpath(@__DIR__, "..", "assets", "shader"))
const LOADED_SHADERS = Dict{String, ShaderSource}()
const WARN_ON_LOAD = Ref(false)

const SHADER_PATHS = Dict{String,Union{RelocatableFolders.Path, String}}()

# Turns out, loading shaders is so slow, that it actually makes sense to memoize it :-O
# when creating 1000 plots with the PlotSpec API, timing drop from 1.5s to 1s just from this change:
function shader_path(name)
return get!(SHADER_PATHS, name) do
return joinpath(SHADER_DIR, name)
function loadshader(name)
return get!(LOADED_SHADERS, name) do
if WARN_ON_LOAD[]
@warn("Reloading shader")
end
return ShaderSource(joinpath(SHADER_DIR, name))
end
end

function loadshader(name)
return get!(LOADED_SHADERS, name) do
return ShaderSource(shader_path(name))
function load_all_shaders(folder)
for name in readdir(folder)
path = joinpath(folder, name)
if isdir(path)
load_all_shaders(path)
elseif any(x -> endswith(name, x), [".frag", ".vert", ".geom"])
path = relpath(path, SHADER_DIR)
loadshader(replace(path, "\\" => "/"))
end
end
end


gl_texture_atlas() = Makie.get_texture_atlas(2048, 64)

# don't put this into try catch, to not mess with normal errors
include("gl_backend.jl")

# We load all shaders to compile them into the package Image
# Making them relocatable
load_all_shaders(SHADER_DIR)
WARN_ON_LOAD[] = true

function __init__()
activate!()
end
Expand Down
2 changes: 1 addition & 1 deletion GLMakie/src/precompiles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ let
close(screen)

empty!(atlas_texture_cache)
closeall()
closeall(; empty_shader=false)
@assert isempty(SCREEN_REUSE_POOL)
@assert isempty(ALL_SCREENS)
@assert isempty(SINGLETON_SCREEN)
Expand Down
53 changes: 5 additions & 48 deletions GLMakie/src/screen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -677,10 +677,13 @@ function Base.close(screen::Screen; reuse=true)
return
end

function closeall()
function closeall(; empty_shader=true)
# Since we call closeall to reload any shader
# We empty the shader source cache here
empty!(LOADED_SHADERS)
if empty_shader
empty!(LOADED_SHADERS)
WARN_ON_LOAD[] = false
end
while !isempty(SCREEN_REUSE_POOL)
screen = pop!(SCREEN_REUSE_POOL)
delete!(ALL_SCREENS, screen)
Expand Down Expand Up @@ -811,52 +814,6 @@ end

Makie.to_native(x::Screen) = x.glscreen

"""
get_loading_image(resolution)
Loads the makie loading icon, embeds it in an image the size of `resolution`,
and returns the image.
"""
function get_loading_image(resolution)
icon = Matrix{N0f8}(undef, 192, 192)
open(joinpath(GL_ASSET_DIR, "loading.bin")) do io
read!(io, icon)
end
img = zeros(RGBA{N0f8}, resolution...)
center = resolution 2
center_icon = size(icon) 2
start = CartesianIndex(max.(center .- center_icon, 1))
I1 = CartesianIndex(1, 1)
stop = min(start + CartesianIndex(size(icon)) - I1, CartesianIndex(resolution))
for idx in start:stop
gray = icon[idx - start + I1]
img[idx] = RGBA{N0f8}(gray, gray, gray, 1.0)
end
return img
end

function display_loading_image(screen::Screen)
fb = screen.framebuffer
fbsize = size(fb)
image = get_loading_image(fbsize)
if size(image) == fbsize
nw = to_native(screen)
# transfer loading image to gpu framebuffer
fb.buffers[:color][1:size(image, 1), 1:size(image, 2)] = image
ShaderAbstractions.is_context_active(nw) || return
w, h = fbsize
glBindFramebuffer(GL_FRAMEBUFFER, 0) # transfer back to window
glViewport(0, 0, w, h)
glClearColor(0, 0, 0, 0)
glClear(GL_COLOR_BUFFER_BIT)
# GLAbstraction.render(fb.postprocess[end]) # copy postprocess
GLAbstraction.render(screen.postprocessors[end].robjs[1])
GLFW.SwapBuffers(nw)
else
error("loading_image needs to be Matrix{RGBA{N0f8}} with size(loading_image) == resolution")
end
end

function renderloop_running(screen::Screen)
return !screen.stop_renderloop && !isnothing(screen.rendertask) && !istaskdone(screen.rendertask)
end
Expand Down
2 changes: 1 addition & 1 deletion GLMakie/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ include("unit_tests.jl")
@testset "refimages" begin
ReferenceTests.mark_broken_tests()
recorded_files, recording_dir = @include_reference_tests GLMakie "refimages.jl" joinpath(@__DIR__, "glmakie_refimages.jl")
missing_images, scores = ReferenceTests.record_comparison(recording_dir)
missing_images, scores = ReferenceTests.record_comparison(recording_dir, "GLMakie")
ReferenceTests.test_comparison(scores; threshold = 0.05)
end

Expand Down
2 changes: 1 addition & 1 deletion MakieCore/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MakieCore"
uuid = "20f20a25-4f0e-4fdf-b5d1-57303727442b"
authors = ["Simon Danisch"]
version = "0.8.8"
version = "0.8.9"

[deps]
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Makie"
uuid = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
authors = ["Simon Danisch", "Julius Krumbiegel"]
version = "0.21.12"
version = "0.21.14"

[deps]
Animations = "27a7e980-b3e6-11e9-2bcd-0b925532e340"
Expand Down Expand Up @@ -94,7 +94,7 @@ KernelDensity = "0.5, 0.6"
LaTeXStrings = "1.2"
LinearAlgebra = "1.0, 1.6"
MacroTools = "0.5"
MakieCore = "=0.8.8"
MakieCore = "=0.8.9"
Markdown = "1.0, 1.6"
MathTeXEngine = "0.5, 0.6"
Observables = "0.5.5"
Expand Down
4 changes: 2 additions & 2 deletions RPRMakie/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RPRMakie"
uuid = "22d9f318-5e34-4b44-b769-6e3734a732a6"
authors = ["Simon Danisch"]
version = "0.7.12"
version = "0.7.14"

[deps]
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Expand All @@ -17,7 +17,7 @@ Colors = "0.9, 0.10, 0.11, 0.12"
FileIO = "1.6"
GeometryBasics = "0.4.11"
LinearAlgebra = "1.0, 1.6"
Makie = "=0.21.12"
Makie = "=0.21.14"
Printf = "1.0, 1.6"
RadeonProRender = "0.3.0"
julia = "1.3"
Expand Down
Loading

0 comments on commit 46067b6

Please sign in to comment.