Skip to content

Commit

Permalink
test cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ffreyer committed Jan 2, 2025
1 parent d12c511 commit affbfa9
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 3 deletions.
4 changes: 1 addition & 3 deletions GLMakie/src/postprocessing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,6 @@ function to_screen_postprocessor(framebuffer, shader_cache, screen_fb_id = nothi
end

function destroy!(pp::PostProcessor)
while !isempty(pp.robjs)
destroy!(pop!(pp.robjs))
end
foreach(destroy!, pp.robjs)
return
end
78 changes: 78 additions & 0 deletions GLMakie/test/unit_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -486,3 +486,81 @@ end
@test robj.uniforms[:resolution][] == screen.px_per_unit[] * cam.resolution[]
@test robj.uniforms[:projectionview][] == cam.projectionview[]
end

@testset "gl Object deletion" begin
# image so we have a user generated texture in the mix
# texture atlas is triggered by text
# include SSAO to make sure its cleanup works too
f,a,p = image(rand(4,4))
screen = display(f, ssao = true, visible = false)
colorbuffer(screen)

# verify that SSAO is active
@test screen.postprocessors[1] != GLMakie.empty_postprocessor()

framebuffer = screen.framebuffer
framebuffer_textures = copy(screen.framebuffer.buffers)
atlas_textures = first.(values(GLMakie.atlas_texture_cache))
shaders = vcat([[shader for shader in values(shaders)] for shaders in values(screen.shader_cache.shader_cache)]...)
programs = [program for program in values(screen.shader_cache.program_cache)]
postprocessors = copy(screen.postprocessors)
robjs = last.(screen.renderlist)

GLMakie.destroy!(screen)

@testset "Texture Atlas" begin
for tex in atlas_textures
@test tex.id == 0
end
end

@testset "Framebuffer" begin
@test framebuffer.id == 0
for (k, tex) in framebuffer_textures
@test tex.id == 0
end
end

@testset "ShaderCache" begin
for shader in shaders
@test shader.id == 0
end
for program in programs
@test program.id == 0
end
end

function validate_robj(robj)
for uniform in robj.uniforms
if to_value(uniform) isa GLMakie.GLAbstraction.GPUArray
@test to_value(uniform).id == 0
end
end
@test robj.vertexarray.id == 0
if robj.vertexarray.indices isa GLMakie.GLAbstraction.GPUArray
@test robj.vertexarray.indices.id == 0
end
for buffer in values(robj.vertexarray.buffers)
@test buffer.id == 0
end
@test robj.vertexarray.program.id == 0
for shader in robj.vertexarray.program.shader
@test shader.id == 0
end
end

@testset "PostProcessors" begin
@test map(pp -> length(pp.robjs), postprocessors) == [2,1,2,1]
for pp in postprocessors
for robj in pp.robjs
validate_robj(robj)
end
end
end

@testset "RenderObjects" begin
for robj in robjs
validate_robj(robj)
end
end
end

0 comments on commit affbfa9

Please sign in to comment.