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

Plot update refactor (prototype) #4550

Draft
wants to merge 58 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
7671e0c
prototype scatter
ffreyer Oct 19, 2024
ddf6375
add a few notes on text
ffreyer Oct 19, 2024
bcfcd93
add a couple more notes
ffreyer Oct 19, 2024
f0d4d2a
Merge branch 'master' into ff/plot-updates
ffreyer Oct 23, 2024
05a6b31
first backend prototype
ffreyer Oct 23, 2024
d911ced
extract some generics
ffreyer Oct 23, 2024
c45a8bb
fix plot cleanup, color handling, compilation
ffreyer Oct 24, 2024
2380a07
fix overdraw
ffreyer Oct 24, 2024
616cfae
some fixes to make update!() work
ffreyer Oct 24, 2024
04f1c71
extract generic uniforms
ffreyer Oct 24, 2024
36f22be
move remaining color inits, fix compilation
ffreyer Oct 24, 2024
c18cccf
disable prints, fix scene updates
ffreyer Oct 25, 2024
7ad65d1
try improving performance
ffreyer Oct 25, 2024
e6ca564
Merge branch 'master' into ff/plot-updates
ffreyer Oct 26, 2024
65aacb3
check for screen closed, add render_asap for benchmarking
ffreyer Oct 26, 2024
314e324
whitespace changes
ffreyer Oct 28, 2024
3369a54
Observables compat
ffreyer Oct 28, 2024
542135d
fix rotation, ppu, quad_offset,
ffreyer Oct 28, 2024
29c6f28
fix intensity with missmatched length
ffreyer Oct 28, 2024
6e8e511
fix px_per_unit, avoid update of unbound buffers
ffreyer Oct 28, 2024
21a79a1
get image markers working
ffreyer Oct 28, 2024
795c559
temp fix Colorbar
ffreyer Oct 28, 2024
7849095
get FastPixel working
ffreyer Oct 29, 2024
bb372cb
some notes
ffreyer Oct 29, 2024
09bc1f4
streamline uv_offset_width, scale, quad_offset
ffreyer Oct 29, 2024
fcd383e
recognize Quaternionf as a native type
ffreyer Oct 29, 2024
14a5772
minor cleanup
ffreyer Oct 29, 2024
0817729
more changes for native Quarternion support
ffreyer Oct 29, 2024
97d9b34
fix Colorbar
ffreyer Oct 29, 2024
5dab37b
fix depthsorting
ffreyer Oct 29, 2024
dbadfd6
fix clip planes
ffreyer Oct 29, 2024
9de8c78
fix waterfall
ffreyer Oct 29, 2024
a3e57e9
add glue for input args updates
ffreyer Oct 29, 2024
47922dd
fix color scaling
ffreyer Oct 29, 2024
44f5e30
fix billboarding
ffreyer Oct 29, 2024
b781be7
fix layouting (partially?)
ffreyer Oct 29, 2024
9be0fa4
add haskey for robj, remove set_eixsting!
ffreyer Oct 29, 2024
ba04827
Merge branch 'master' into ff/plot-updates
ffreyer Oct 29, 2024
b1db2f6
fix Legend, fix model updates, minor cleanup
ffreyer Oct 29, 2024
40d45f5
fix colorscale conversion error
ffreyer Oct 29, 2024
499f758
fix lowclip/highclip in Colorbar
ffreyer Oct 29, 2024
dd77718
fix legend scatter color
ffreyer Oct 29, 2024
6ba9963
fix specapi
ffreyer Oct 30, 2024
6dcfb9f
add comment [skip ci]
ffreyer Oct 30, 2024
c7315e5
try fix create performance
ffreyer Oct 30, 2024
bb2c2a4
use arg<i> and args to set args
ffreyer Oct 30, 2024
adc60bc
add notes on generic update!()
ffreyer Oct 31, 2024
2621be5
merge master
SimonDanisch Nov 6, 2024
0eeb950
generalize with cached_robj-like function
ffreyer Nov 6, 2024
6c84389
move render_asap
ffreyer Nov 6, 2024
6018c36
move lines to new interface
ffreyer Nov 7, 2024
2ce7491
fix lines colorscaling [skip ci]
ffreyer Nov 7, 2024
25c3aac
Merge branch 'master' into ff/plot-updates
ffreyer Nov 7, 2024
369b34c
fix single value colors, indices printing, args update [skip ci]
ffreyer Nov 7, 2024
04bdb70
Merge branch 'ff/plot-updates' of https://github.com/MakieOrg/Makie.j…
ffreyer Nov 7, 2024
c3d591b
fix incomplete projection, attribute setindex
ffreyer Nov 7, 2024
53ea8d7
fix duplication of indices
ffreyer Nov 7, 2024
19d74ac
improve type stability
ffreyer Nov 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions GLMakie/assets/shader/dots.vert
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ struct Nothing{ //Nothing type, to encode if some variable doesn't contain any d
bool _; //empty structs are not allowed
};

{{vertex_type}} vertex;
{{position_type}} position;
{{color_type}} color;
{{color_norm_type}} color_norm;
{{color_map_type}} color_map;
Expand Down Expand Up @@ -56,7 +56,7 @@ uniform float px_per_unit;
uniform vec3 upvector;

void main(){
vec4 world_position = model * _position(vertex);
vec4 world_position = model * _position(position);
process_clip_planes(world_position.xyz);
vec4 clip_pos = projectionview * world_position;
gl_Position = vec4(clip_pos.xy, clip_pos.z + (clip_pos.w * depth_shift), clip_pos.w);
Expand Down
1 change: 1 addition & 0 deletions GLMakie/src/GLAbstraction/GLRenderObject.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ end

Base.getindex(obj::RenderObject, symbol::Symbol) = obj.uniforms[symbol]
Base.setindex!(obj::RenderObject, value, symbol::Symbol) = obj.uniforms[symbol] = value
Base.haskey(obj::RenderObject, symbol::Symbol) = haskey(obj.uniforms, symbol)

Base.getindex(obj::RenderObject, symbol::Symbol, x::Function) = getindex(obj, Val(symbol), x)
Base.getindex(obj::RenderObject, ::Val{:prerender}, x::Function) = obj.prerenderfunctions[x]
Expand Down
14 changes: 8 additions & 6 deletions GLMakie/src/GLAbstraction/GLTypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ end
########################################################################################
# OpenGL Arrays

const GLArrayEltypes = Union{StaticVector,Real,Colorant}
const GLArrayEltypes = Union{StaticVector,Quaternion,Real,Colorant}
"""
Transform julia datatypes to opengl enum type
"""
julia2glenum(x::Type{T}) where {T <: FixedPoint} = julia2glenum(FixedPointNumbers.rawtype(x))
julia2glenum(x::Union{Type{T},T}) where {T <: Union{StaticVector,Colorant}} = julia2glenum(eltype(x))
julia2glenum(x::Union{Type{T},T}) where {T <: Union{StaticVector,Colorant,Quaternion}} = julia2glenum(eltype(x))
julia2glenum(::Type{OffsetInteger{O,T}}) where {O,T} = julia2glenum(T)
julia2glenum(::Type{GLubyte}) = GL_UNSIGNED_BYTE
julia2glenum(::Type{GLbyte}) = GL_BYTE
Expand Down Expand Up @@ -281,12 +281,14 @@ end


function Base.show(io::IO, vao::GLVertexArray)
show(io, vao.program)
# show(io, vao.program)
println(io, "GLVertexArray $(vao.id):")
print(io, "GLVertexArray $(vao.id) buffers: ")
writemime(io, MIME("text/plain"), vao.buffers)
println(io, "\nGLVertexArray $(vao.id) indices: ", vao.indices)
print(io, "buffers: ")
show(io, MIME("text/plain"), vao.buffers)
_print_indices(io, vao.indices)
end
_print_indices(io::IO, is::AbstractVector{<: Integer}) = println(io, "\nindices: ", Int64.(is))
_print_indices(io::IO, fs) = println(io, "\nfaces: ", fs)

##################################################################################

Expand Down
17 changes: 12 additions & 5 deletions GLMakie/src/GLAbstraction/GLUniforms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

const GLSL_COMPATIBLE_NUMBER_TYPES = (GLfloat, GLint, GLuint, GLdouble)
const NATIVE_TYPES = Union{
StaticVector, Mat, GLSL_COMPATIBLE_NUMBER_TYPES...,
StaticVector, Mat, Quaternion, GLSL_COMPATIBLE_NUMBER_TYPES...,
ZeroIndex{GLint}, ZeroIndex{GLuint},
GLBuffer, GPUArray, Shader, GLProgram
}
Expand Down Expand Up @@ -35,18 +35,20 @@ end

gluniform(location::Integer, x::Nothing) = nothing

function gluniform(location::Integer, x::Union{StaticVector, Mat, Colorant})
function gluniform(location::Integer, x::Union{StaticVector, Mat, Colorant, Quaternion})
xref = [x]
gluniform(location, xref)
end

_size(p) = size(p)
_size(p::Colorant) = (length(p),)
_size(::Type{<: Quaternion}) = (4,)
_size(p::Type{T}) where {T <: Colorant} = (length(p),)
_ndims(p) = ndims(p)
_ndims(p::Type{T}) where {T <: Colorant} = 1
_ndims(p::Type{T}) where {T <: Quaternion} = 1

@generated function gluniform(location::Integer, x::Vector{FSA}) where FSA <: Union{Mat, Colorant, StaticVector}
@generated function gluniform(location::Integer, x::Vector{FSA}) where FSA <: Union{Mat, Colorant, StaticVector, Quaternion}
func = uniformfunc(eltype(FSA), _size(FSA))
callexpr = if _ndims(FSA) == 2
:($func(location, length(x), GL_FALSE, x))
Expand Down Expand Up @@ -76,6 +78,7 @@ function gluniform(loc::Integer, x::Observable{T}) where T
gluniform(GLint(loc), to_value(x))
end

gluniform(location::Integer, x::Int64) = glUniform1i(GLint(location), GLint(x))
gluniform(location::Integer, x::Union{GLubyte, GLushort, GLuint}) = glUniform1ui(GLint(location), x)
gluniform(location::Integer, x::Union{GLbyte, GLshort, GLint, Bool}) = glUniform1i(GLint(location), x)
gluniform(location::Integer, x::GLfloat) = glUniform1f(GLint(location), x)
Expand All @@ -94,7 +97,7 @@ glsl_typename(t::Type{GLfloat}) = "float"
glsl_typename(t::Type{GLdouble}) = "double"
glsl_typename(t::Type{GLuint}) = "uint"
glsl_typename(t::Type{GLint}) = "int"
glsl_typename(t::Type{T}) where {T <: Union{StaticVector, Colorant}} = string(opengl_prefix(eltype(T)), "vec", length(T))
glsl_typename(t::Type{T}) where {T <: Union{StaticVector, Colorant, Quaternion}} = string(opengl_prefix(eltype(T)), "vec", length(T))
glsl_typename(t::Type{TextureBuffer{T}}) where {T} = string(opengl_prefix(eltype(T)), "samplerBuffer")

function glsl_typename(t::Texture{T, D}) where {T, D}
Expand All @@ -108,7 +111,9 @@ function glsl_typename(t::Type{T}) where T <: Mat
string(opengl_prefix(eltype(t)), "mat", M==N ? M : string(N, "x", M))
end
toglsltype_string(t::Observable) = toglsltype_string(to_value(t))
toglsltype_string(x::T) where {T<:Union{Real, Mat, StaticVector, Texture, Colorant, TextureBuffer, Nothing}} = "uniform $(glsl_typename(x))"
function toglsltype_string(x::T) where {T<:Union{Real, Mat, StaticVector, Quaternion, Texture, Colorant, TextureBuffer, Nothing}}
return "uniform $(glsl_typename(x))"
end
#Handle GLSL structs, which need to be addressed via single fields
function toglsltype_string(x::T) where T
if isa_gl_struct(x)
Expand Down Expand Up @@ -187,6 +192,7 @@ gl_promote(x::Type{T}) where {T <: BGR} = BGR{gl_promote(eltype(T))}

gl_promote(x::Type{Vec{N, T}}) where {N, T} = Vec{N, gl_promote(T)}
gl_promote(x::Type{Point{N, T}}) where {N, T} = Point{N, gl_promote(T)}
gl_promote(x::Type{Quaternion{T}}) where {T} = Quaternion{gl_promote(T)}

gl_convert(x::AbstractVector{Vec3f}) = x

Expand Down Expand Up @@ -237,6 +243,7 @@ gl_convert(a::T) where {T <: NATIVE_TYPES} = a
gl_convert(s::Observable{T}) where {T <: NATIVE_TYPES} = s
gl_convert(s::Observable{T}) where T = const_lift(gl_convert, s)
gl_convert(x::StaticVector{N, T}) where {N, T} = map(gl_promote(T), x)
gl_convert(x::Quaternion{T}) where {T} = convert(Quaternion{gl_promote(T)}, x)
gl_convert(x::Mat{N, M, T}) where {N, M, T} = map(gl_promote(T), x)
gl_convert(a::AbstractVector{<: AbstractFace}) = indexbuffer(s)
gl_convert(t::Type{T}, a::T; kw_args...) where T <: NATIVE_TYPES = a
Expand Down
2 changes: 2 additions & 0 deletions GLMakie/src/drawing_primitives.jl
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ function draw_atomic(screen::Screen, scene::Scene, @nospecialize(plot::Union{Sca
end
end

#=
function draw_atomic(screen::Screen, scene::Scene, @nospecialize(plot::Lines))
return cached_robj!(screen, scene, plot) do gl_attributes
linestyle = pop!(gl_attributes, :linestyle)
Expand Down Expand Up @@ -541,6 +542,7 @@ function draw_atomic(screen::Screen, scene::Scene, @nospecialize(plot::Lines))
return draw_lines(screen, positions, data)
end
end
=#

function draw_atomic(screen::Screen, scene::Scene, @nospecialize(plot::LineSegments))
return cached_robj!(screen, scene, plot) do gl_attributes
Expand Down
1 change: 1 addition & 0 deletions GLMakie/src/gl_backend.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ include("picking.jl")
include("rendering.jl")
include("events.jl")
include("drawing_primitives.jl")
include("plot_updates.jl")
include("display.jl")
2 changes: 1 addition & 1 deletion GLMakie/src/glshaders/particles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ vec2quaternion(rotation::VectorTypes) = const_lift(x-> vec2quaternion.(x), rotat
vec2quaternion(rotation::Observable) = lift(vec2quaternion, rotation)
vec2quaternion(rotation::Makie.Quaternion)= Vec4f(rotation.data)
vec2quaternion(rotation)= vec2quaternion(to_rotation(rotation))
GLAbstraction.gl_convert(rotation::Makie.Quaternion)= Vec4f(rotation.data)
# GLAbstraction.gl_convert(rotation::Makie.Quaternion)= Vec4f(rotation.data)
to_pointsize(x::Number) = Float32(x)
to_pointsize(x) = Float32(x[1])
struct PointSizeRender
Expand Down
Loading
Loading