Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix px_per_unit scaling while rendering in GLMakie #4687

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ffreyer
Copy link
Collaborator

@ffreyer ffreyer commented Dec 22, 2024

Description

The framebuffer_size optimization from #4485 broke rendering with px_per_unit != 1 for me. For example

f,a,p = scatter(rand(10))
# img = Makie.save("px_per_unit.png", f)
screen = display(f, px_per_unit = 0.5)

results in:

render saved render with fix
Screenshot 2024-12-22 192731 px_per_unit Screenshot 2024-12-22 192744

The current version sets the viewport of the final output to the size of the framebuffer color attachment, which is scaled by px_per_unit. The final output is however sized based on real pixels, so we only draw to half of them like this.

This is not caught by tests because they rely on colorbuffer() which reads the framebuffer color attachment, which the copy-to-screen task does not affect.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • Added an entry in CHANGELOG.md (for new features and breaking changes)
  • Added or changed relevant sections in the documentation
  • Added unit tests for new algorithms, conversion methods, etc.
  • Added reference image tests for new plotting functions, recipes, visual options, etc.

@asinghvi17
Copy link
Member

asinghvi17 commented Dec 22, 2024

I just tried this PR on an M1 Mac and got this error when precompiling GLMakie:

Failed to precompile GLMakie [e9467ef8-e4e7-5192-8a1a-b1aee30e663a] to "/Users/anshul/.julia/compiled/v1.11/GLMakie/jl_J0dVQk".
ERROR: LoadError: InexactError: Int32(Inf32)
Stacktrace:
  [1] Int32
    @ ./float.jl:994 [inlined]
  [2] convert
    @ ./number.jl:7 [inlined]
  [3] cconvert
    @ ./essentials.jl:687 [inlined]
  [4] glViewport(x::Int64, y::Int64, width::Float32, height::Float32)
    @ ModernGL ~/.julia/packages/ModernGL/yNrOu/src/functionloading.jl:64
  [5] (::GLMakie.var"#40#42"{Nothing, GLMakie.GLAbstraction.RenderObject{GLMakie.PostprocessPrerender}})(screen::GLMakie.Screen{GLFW.Window})
    @ GLMakie ~/.julia/dev/Makie/GLMakie/src/postprocessing.jl:296
  [6] render_frame(screen::GLMakie.Screen{GLFW.Window}; resize_buffers::Bool)
    @ GLMakie ~/.julia/dev/Makie/GLMakie/src/rendering.jl:102
  [7] render_frame
    @ ~/.julia/dev/Makie/GLMakie/src/rendering.jl:29 [inlined]
  [8] refreshwindowcb(screen::GLMakie.Screen{GLFW.Window}, window::GLFW.Window)
    @ GLMakie ~/.julia/dev/Makie/GLMakie/src/screen.jl:867
  [9] (::GLMakie.var"#74#75"{GLMakie.Screen{GLFW.Window}})(window::GLFW.Window)
    @ GLMakie ~/.julia/dev/Makie/GLMakie/src/screen.jl:871
 [10] _WindowRefreshCallbackWrapper(window::GLFW.Window)
    @ GLFW ~/.julia/packages/GLFW/wmoTL/src/callback.jl:43
in expression starting at /Users/anshul/.julia/dev/Makie/GLMakie/src/precompiles.jl:15
in expression starting at /Users/anshul/.julia/dev/Makie/GLMakie/src/GLMakie.jl:1
in expression starting at stdin:

@MakieBot
Copy link
Collaborator

MakieBot commented Dec 22, 2024

Benchmark Results

SHA: d96598b1a96b00165ce64658468bf6f51a19e96b

Warning

These results are subject to substantial noise because GitHub's CI runs on shared machines that are not ideally suited for benchmarking.

GLMakie
CairoMakie
WGLMakie

@ffreyer
Copy link
Collaborator Author

ffreyer commented Dec 22, 2024

fair enough. Changed it to use size(root_scene) which is also used for framebuffers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Work in progress
Development

Successfully merging this pull request may close these issues.

3 participants