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

Rework postprocessor handling in GLMakie #4689

Draft
wants to merge 128 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
5b99033
pull tweaks from #4689
ffreyer Jan 2, 2025
fed962b
pull context validation from #4689
ffreyer Jan 2, 2025
442b271
handle texture atlas explicitly + fix errors
ffreyer Jan 2, 2025
1310186
explicitly clean up shaders & programs
ffreyer Jan 2, 2025
fb4bf07
handle GLBuffer, GLVertexArray, Postprocessors
ffreyer Jan 2, 2025
e8bf0fe
handle Texture explicitly
ffreyer Jan 2, 2025
d12c511
fix SSAO error
ffreyer Jan 2, 2025
affbfa9
test cleanup
ffreyer Jan 2, 2025
18fb15f
add some sanity checks
ffreyer Jan 2, 2025
437ac9f
fix tests
ffreyer Jan 2, 2025
662c971
cleanup finalizers, free(), unsafe_free()
ffreyer Jan 2, 2025
ca120a9
skip GLFW initialized assert for CI
ffreyer Jan 2, 2025
3eb56a1
update changelog
ffreyer Jan 2, 2025
4722f58
fix freeing of unused uniforms & cleanup unused pattern_sections
ffreyer Jan 2, 2025
39c7357
count and check failed OpenGL cleanup
ffreyer Jan 2, 2025
dbbf3f7
try to handle GLFW CI failure
ffreyer Jan 2, 2025
a500572
Merge branch 'master' into ff/safe-context
ffreyer Jan 2, 2025
e94363f
try fix CI
ffreyer Jan 2, 2025
a47ed68
require context for Texture and GLBuffer in most cases
ffreyer Jan 2, 2025
4b74544
fix incorrect uniform cleanup
ffreyer Jan 2, 2025
c096311
CI please
ffreyer Jan 2, 2025
4a1d278
fix typo
ffreyer Jan 2, 2025
e638450
try handling GLFW init errors differently
ffreyer Jan 2, 2025
3b46514
maybe just destroy the window if the context dies?
ffreyer Jan 2, 2025
c7285ca
fix typos
ffreyer Jan 2, 2025
0296205
maybe also cleanup dead screens when trying to reopen?
ffreyer Jan 2, 2025
b819240
tweak require_context to maybe catch error earlier
ffreyer Jan 2, 2025
6c64137
switch before requiring
ffreyer Jan 2, 2025
07e6d2e
avoid requiring context for get_texture and thus robj cleanup
ffreyer Jan 3, 2025
6f6eb32
treat scene finalizer
ffreyer Jan 3, 2025
54f1c1b
Treat scene finalizer in texture atlas too
ffreyer Jan 3, 2025
73f78c2
add missing passthrough
ffreyer Jan 3, 2025
c3f2131
move object deletion test to end
ffreyer Jan 3, 2025
86d4b0b
warn on dead context
ffreyer Jan 3, 2025
e54c2e2
avoid the last few current_context() calls
ffreyer Jan 3, 2025
c31bac8
fix scatter indices
ffreyer Jan 3, 2025
6e4adda
start reworking render pipeline
ffreyer Dec 23, 2024
ad80f6a
move gl part of Framebuffer to GLAbstraction
ffreyer Dec 23, 2024
377d3f2
add show()
ffreyer Dec 24, 2024
ffe5b7c
fix incorrect rename
ffreyer Dec 24, 2024
fa47aa3
change copy-to-screen to a Blit operation
ffreyer Dec 24, 2024
0d3b8ed
fix tests
ffreyer Dec 24, 2024
7da8700
add Render step
ffreyer Dec 24, 2024
18973b6
fix SSAO
ffreyer Dec 24, 2024
c98b311
add SortPlots task and cleanup render_frame
ffreyer Dec 24, 2024
ecd804b
use dedicated framebuffers
ffreyer Dec 24, 2024
1d726d2
fix tests
ffreyer Dec 24, 2024
70d056b
fix depthbuffer()
ffreyer Dec 24, 2024
7820e69
simplify glDrawBuffer(s)
ffreyer Dec 24, 2024
84440a4
add prototype for abstracted RenderPipeline
ffreyer Dec 26, 2024
67ee4f0
switch to Vector of connections
ffreyer Dec 26, 2024
f490da1
split up multi-step stages
ffreyer Dec 26, 2024
ca0af0e
rename Format to avoid name collision
ffreyer Dec 26, 2024
17209e7
collect framebuffer buffers in array, prepare some utilities
ffreyer Dec 26, 2024
d1306c8
integrate GLMakie with new render pipeline (prototype)
ffreyer Dec 27, 2024
8dac598
fix SSAO
ffreyer Dec 27, 2024
c177679
fix FXAA
ffreyer Dec 27, 2024
4b0d697
fix picking, use config.ssao
ffreyer Dec 27, 2024
8572000
try recreating Framebuffer instead of removing attachments
ffreyer Dec 27, 2024
8b71811
some cleanup & performance tweaks
ffreyer Dec 27, 2024
c502d0b
try to get some debug info out of CI
ffreyer Dec 28, 2024
1c1ef31
fix FXAA in CI?
ffreyer Dec 28, 2024
055c1c4
add changelog entry
ffreyer Dec 28, 2024
9176626
cleanup GLAbstraction
ffreyer Dec 28, 2024
35ea37b
cleanup, add extras to format, usability improvements
ffreyer Dec 28, 2024
25bff2f
add stage attributes, format extras
ffreyer Dec 28, 2024
57d3af0
add pipeline show and fix OIT
ffreyer Dec 28, 2024
9c3e27f
add GLRenderPipeline
ffreyer Dec 28, 2024
8a900d7
add construct and reconstruct, unify input buffer names
ffreyer Dec 28, 2024
d84e986
use reconstruct to reuse postprocessor render objects
ffreyer Dec 28, 2024
cd7b898
reuse GLRenderPipeline & be a bit more careful with caching
ffreyer Dec 28, 2024
02474d9
temp fix SSAO clearing bug
ffreyer Dec 29, 2024
15bca85
add more destroy!() to maybe fix CI
ffreyer Dec 29, 2024
fc84123
is it buffer reuse?
ffreyer Dec 29, 2024
9dc0b27
is it reconstruct?
ffreyer Dec 29, 2024
8411c13
Revert to green CI
ffreyer Dec 29, 2024
114d0c6
Revert revert + undo debugging
ffreyer Dec 29, 2024
326713c
add some more context switches, idk
ffreyer Dec 29, 2024
ffb6321
add more context switches
ffreyer Dec 30, 2024
94d0ead
cleanup enum -> name
ffreyer Dec 30, 2024
a26dbe8
fix plots not displaying with ssao = true in non SSAO pipeline
ffreyer Dec 30, 2024
807d2ff
add test to verify all render stage parameters render
ffreyer Dec 30, 2024
44a7c2f
fix tick test
ffreyer Dec 30, 2024
82325b9
fix test
ffreyer Dec 30, 2024
28fb7e5
switch config to include (Makie) render pipeline & cover all settings
ffreyer Dec 30, 2024
0f7f9f5
fix docs
ffreyer Dec 31, 2024
620e3a1
test a few other pipelines
ffreyer Dec 31, 2024
658d4db
free more things
ffreyer Dec 31, 2024
8bd6f67
some performance tweaks
ffreyer Jan 1, 2025
5930579
some more safety tweaks
ffreyer Jan 1, 2025
188a294
add tests for Makie render Pipeline
ffreyer Jan 1, 2025
fde46f8
revert fix attempts & assert correct context instead
ffreyer Jan 2, 2025
0bc8751
use enum for type handling to avoid runtime dispatch
ffreyer Jan 3, 2025
d187a65
remove Connection type for better performance
ffreyer Jan 3, 2025
6992b74
cleanup rebase
ffreyer Jan 4, 2025
e327caa
minor cleanup
ffreyer Jan 4, 2025
abe3d91
put finalizers behind debug constant
ffreyer Jan 4, 2025
bab465e
don't skip observable cleanup in free
ffreyer Jan 4, 2025
fa61c24
cleanup require_context
ffreyer Jan 4, 2025
8c58f93
fix typo
ffreyer Jan 4, 2025
667094d
fix test errors
ffreyer Jan 4, 2025
a01ef76
Merge branch 'ff/safe-context' into ff/render_pipeline_master
ffreyer Jan 4, 2025
d3ff367
fix typo
ffreyer Jan 4, 2025
33aff9c
rename OIT buffers
ffreyer Jan 5, 2025
d31feed
fix & test connecting two already connected nodes
ffreyer Jan 5, 2025
836421d
add experimental GUI
ffreyer Jan 5, 2025
f07d3a4
remove pipeline caching
ffreyer Jan 5, 2025
60201e7
turn on ci against rebase branch
ffreyer Jan 5, 2025
1b61a16
fix freeing of reused framebuffer attachments, fix tests
ffreyer Jan 5, 2025
d9fa43d
git pls
ffreyer Jan 5, 2025
f3980ab
fix tests
ffreyer Jan 5, 2025
0577f78
improve default placement of stages in GUI
ffreyer Jan 6, 2025
fa94cc3
fix SSAO
ffreyer Jan 6, 2025
5a3abcd
add test for custom render pass
ffreyer Jan 6, 2025
7d356cd
get renderpipeline to persist from activate!()
ffreyer Jan 6, 2025
c07e4b9
fix missing to_value
ffreyer Jan 6, 2025
4d106cf
fix another incorrect free
ffreyer Jan 7, 2025
e026969
bit of convenience
ffreyer Jan 7, 2025
41351c7
clean up
SimonDanisch Jan 7, 2025
8529efb
fix errors
SimonDanisch Jan 8, 2025
a952645
fix freeing of GLBuffer Observables
SimonDanisch Jan 8, 2025
27e15c3
rename Pipeline -> RenderPipeline
ffreyer Jan 8, 2025
1afd177
document rendering in Cairo, GL and WGLMakie
ffreyer Jan 8, 2025
1ee95f7
cleanup unsafe_free
ffreyer Jan 8, 2025
d20a281
cleanup called_from_finalizer & add comments to implied functions
ffreyer Jan 8, 2025
f86d313
some cleanup
ffreyer Jan 8, 2025
0bf88ce
Merge branch 'ff/safe-context' into ff/render_pipeline_master
ffreyer Jan 8, 2025
44cef5f
fix more tests
ffreyer Jan 8, 2025
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- '*.md'
branches:
- master
- ff/safe-context
push:
tags:
- '*'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/compilation-benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- '*.md'
branches:
- master
- ff/safe-context

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/reference_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- '*.md'
branches:
- master
- ff/safe-context
push:
tags:
- '*'
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Unreleased]

- Fixed indexing error edge case in violin median code [#4682](https://github.com/MakieOrg/Makie.jl/pull/4682)
- Refactored rendering in GLMakie to go through a series of steps abstracted by a render pipeline. This allows rendering to be adjusted from outside and should simplify introducing more post-processing options in the future. [#4689](https://github.com/MakieOrg/Makie.jl/pull/4689)

## [0.22.0] - 2024-12-12

Expand All @@ -28,6 +29,7 @@
- Fixed gaps in corners of `poly(Rect2(...))` stroke [#4664](https://github.com/MakieOrg/Makie.jl/pull/4664)
- Fixed an issue where `reinterpret`ed arrays of line points were not handled correctly in CairoMakie [#4668](https://github.com/MakieOrg/Makie.jl/pull/4668).
- Fixed various issues with `markerspace = :data`, `transform_marker = true` and `rotation` for scatter in CairoMakie (incorrect marker transformations, ignored transformations, Cairo state corruption) [#4663](https://github.com/MakieOrg/Makie.jl/pull/4663)
- Refactored OpenGL cleanup to run immediately rather than on GC [#4699](https://github.com/MakieOrg/Makie.jl/pull/4699)

## [0.21.18] - 2024-12-12

Expand Down
2 changes: 1 addition & 1 deletion GLMakie/assets/shader/fragment_output.frag
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ void write2framebuffer(vec4 color, uvec2 id){

// // if transparency == false && ssao = true
// fragment_color = color;
// fragment_position = o_view_pos;
// fragment_position.xyz = o_view_pos;
// fragment_normal_occlusion.xyz = o_view_normal;

// // else
Expand Down
8 changes: 4 additions & 4 deletions GLMakie/assets/shader/postprocessing/OIT_blend.frag
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
in vec2 frag_uv;

// contains sum_i C_i * weight(depth_i, alpha_i)
uniform sampler2D sum_color;
uniform sampler2D color_sum_buffer;
// contains pod_i (1 - alpha_i)
uniform sampler2D prod_alpha;
uniform sampler2D transmittance_buffer;

out vec4 fragment_color;

void main(void)
{
vec4 summed_color_weight = texture(sum_color, frag_uv);
float transmittance = texture(prod_alpha, frag_uv).r;
vec4 summed_color_weight = texture(color_sum_buffer, frag_uv);
float transmittance = texture(transmittance_buffer, frag_uv).r;

vec3 weighted_transparent = summed_color_weight.rgb / max(summed_color_weight.a, 0.00001);
vec3 full_weighted_transparent = weighted_transparent * (1 - transmittance);
Expand Down
13 changes: 7 additions & 6 deletions GLMakie/assets/shader/postprocessing/SSAO.frag
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// SSAO
uniform sampler2D position_buffer;
uniform sampler2D normal_occlusion_buffer;
uniform sampler2D normal_buffer;
uniform sampler2D noise;
uniform vec3 kernel[{{N_samples}}];
uniform vec2 noise_scale;
Expand All @@ -16,18 +16,18 @@ uniform float radius;

in vec2 frag_uv;
// occlusion.xyz is a normal vector, occlusion.w the occlusion value
out vec4 o_normal_occlusion;
out float o_occlusion;


void main(void)
{
vec3 view_pos = texture(position_buffer, frag_uv).xyz;
vec3 normal = texture(normal_occlusion_buffer, frag_uv).xyz;
vec3 normal = texture(normal_buffer, frag_uv).xyz;

// The normal buffer gets cleared every frame. (also position, color etc)
// If normal == vec3(1) then there is no geometry at this fragment.
// Therefore skip SSAO calculation
if (normal != vec3(1)) {
if (normal != vec3(0)) {
vec3 rand_vec = vec3(texture(noise, frag_uv * noise_scale).xy, 0.0);
vec3 tangent = normalize(rand_vec - normal * dot(rand_vec, normal));
vec3 bitangent = cross(normal, tangent);
Expand Down Expand Up @@ -78,13 +78,14 @@ void main(void)
sample_frag_pos.xyz = sample_frag_pos.xyz * 0.5 + 0.5;
sample_frag_pos.xy += (frag_uv - 0.5) * clip_pos_w / sample_clip_pos_w;

if (texture(normal_buffer, sample_frag_pos.xy).xyz == vec3(0)) continue;

float sample_depth = texture(position_buffer, sample_frag_pos.xy).z;
float range_check = smoothstep(0.0, 1.0, radius / abs(view_pos.z - sample_depth));
occlusion += (sample_depth >= sample_view_offset.z + view_pos.z + bias ? 1.0 : 0.0) * range_check;
}
o_normal_occlusion.w = occlusion / {{N_samples}};
o_occlusion = occlusion / {{N_samples}};
} else {
o_normal_occlusion.w = 0.0;
o_occlusion = 0.0;
}
}
17 changes: 9 additions & 8 deletions GLMakie/assets/shader/postprocessing/SSAO_blur.frag
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{GLSL_VERSION}}

// occlusion.w is the occlusion value
uniform sampler2D normal_occlusion;
uniform sampler2D color_texture;
uniform usampler2D ids;
uniform sampler2D occlusion_buffer;
uniform sampler2D color_buffer;
uniform usampler2D objectid_buffer;
uniform vec2 inv_texel_size;
// Settings/Attributes
uniform int blur_range;
Expand All @@ -14,31 +14,32 @@ out vec4 fragment_color;
void main(void)
{
// occlusion blur
uvec2 id0 = texture(ids, frag_uv).xy;
uvec2 id0 = texture(objectid_buffer, frag_uv).xy;
if (id0.x == uint(0)){
fragment_color = texture(color_texture, frag_uv);
fragment_color = texture(color_buffer, frag_uv);
// fragment_color = vec4(1,0,1,1); // show discarded
return;
}

float blurred_occlusion = 0.0;
float weight = 0;

// TODO: Could use :linear filtering and/ro mipmap to simplify this maybe?
for (int x = -blur_range; x <= blur_range; ++x){
for (int y = -blur_range; y <= blur_range; ++y){
vec2 offset = vec2(float(x), float(y)) * inv_texel_size;
// The id check makes it so that the blur acts per object.
// Without this, a high (low) occlusion from one object can bleed
// into the low (high) occlusion of another, giving an unwanted
// shine effect.
uvec2 id = texture(ids, frag_uv + offset).xy;
uvec2 id = texture(objectid_buffer, frag_uv + offset).xy;
float valid = float(id == id0);
blurred_occlusion += valid * texture(normal_occlusion, frag_uv + offset).w;
blurred_occlusion += valid * texture(occlusion_buffer, frag_uv + offset).x;
weight += valid;
}
}
blurred_occlusion = 1.0 - blurred_occlusion / weight;
fragment_color = texture(color_texture, frag_uv) * blurred_occlusion;
fragment_color = texture(color_buffer, frag_uv) * blurred_occlusion;
// Display occlusion instead:
// fragment_color = vec4(vec3(blurred_occlusion), 1.0);
}
4 changes: 2 additions & 2 deletions GLMakie/assets/shader/postprocessing/copy.frag
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{{GLSL_VERSION}}

uniform sampler2D color_texture;
uniform sampler2D color_buffer;
in vec2 frag_uv;
out vec4 fragment_color;

void main(void)
{
vec4 color = texture(color_texture, frag_uv);
vec4 color = texture(color_buffer, frag_uv);
fragment_color.rgb = color.rgb;
fragment_color.a = 1.0;
}
31 changes: 16 additions & 15 deletions GLMakie/assets/shader/postprocessing/fxaa.frag
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ FxaaFloat4 FxaaPixelShader(

precision highp float;

uniform sampler2D color_texture;
uniform sampler2D color_luma_buffer;
uniform vec2 RCPFrame;
in vec2 frag_uv;

Expand All @@ -1028,23 +1028,24 @@ out vec4 fragment_color;

void main(void)
{
// fragment_color = texture(color_texture, frag_uv);
// fragment_color = texture(color_luma_buffer, frag_uv);
// fragment_color.rgb = vec3(texture(color_luma_buffer, frag_uv).a);
fragment_color.rgb = FxaaPixelShader(
frag_uv,
FxaaFloat4(0.0f, 0.0f, 0.0f, 0.0f), // FxaaFloat4 fxaaConsolePosPos,
color_texture, // FxaaTex tex,
color_texture, // FxaaTex fxaaConsole360TexExpBiasNegOne,
color_texture, // FxaaTex fxaaConsole360TexExpBiasNegTwo,
RCPFrame, // FxaaFloat2 fxaaQualityRcpFrame,
FxaaFloat4(0.0f, 0.0f, 0.0f, 0.0f), // FxaaFloat4 fxaaConsoleRcpFrameOpt,
FxaaFloat4(0.0f, 0.0f, 0.0f, 0.0f), // FxaaFloat4 fxaaConsoleRcpFrameOpt2,
FxaaFloat4(0.0f, 0.0f, 0.0f, 0.0f), // FxaaFloat4 fxaaConsole360RcpFrameOpt2,
FxaaFloat4(0.0f, 0.0f, 0.0f, 0.0f), // FxaaFloat4 fxaaConsolePosPos,
color_luma_buffer, // FxaaTex tex,
color_luma_buffer, // FxaaTex fxaaConsole360TexExpBiasNegOne,
color_luma_buffer, // FxaaTex fxaaConsole360TexExpBiasNegTwo,
RCPFrame, // FxaaFloat2 fxaaQualityRcpFrame,
FxaaFloat4(0.0f, 0.0f, 0.0f, 0.0f), // FxaaFloat4 fxaaConsoleRcpFrameOpt,
FxaaFloat4(0.0f, 0.0f, 0.0f, 0.0f), // FxaaFloat4 fxaaConsoleRcpFrameOpt2,
FxaaFloat4(0.0f, 0.0f, 0.0f, 0.0f), // FxaaFloat4 fxaaConsole360RcpFrameOpt2,
0.75f, // FxaaFloat fxaaQualitySubpix,
0.166f, // FxaaFloat fxaaQualityEdgeThreshold,
0.0833f, // FxaaFloat fxaaQualityEdgeThresholdMin,
0.0f, // FxaaFloat fxaaConsoleEdgeSharpness,
0.0f, // FxaaFloat fxaaConsoleEdgeThreshold,
0.0f, // FxaaFloat fxaaConsoleEdgeThresholdMin,
0.166f, // FxaaFloat fxaaQualityEdgeThreshold,
0.0833f, // FxaaFloat fxaaQualityEdgeThresholdMin,
0.0f, // FxaaFloat fxaaConsoleEdgeSharpness,
0.0f, // FxaaFloat fxaaConsoleEdgeThreshold,
0.0f, // FxaaFloat fxaaConsoleEdgeThresholdMin,
FxaaFloat4(0.0f, 0.0f, 0.0f, 0.0f) // FxaaFloat fxaaConsole360ConstDir,
).rgb;
}
15 changes: 11 additions & 4 deletions GLMakie/assets/shader/postprocessing/postprocess.frag
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{{GLSL_VERSION}}

{{FILTER_IN_SHADER}}

in vec2 frag_uv;

uniform sampler2D color_texture;
uniform usampler2D object_ids;
uniform sampler2D color_buffer;
uniform usampler2D objectid_buffer;

layout(location=0) out vec4 fragment_color;

Expand All @@ -21,20 +23,25 @@ bool unpack_bool(uint id) {

void main(void)
{
vec4 color = texture(color_texture, frag_uv).rgba;
vec4 color = texture(color_buffer, frag_uv).rgba;
if(color.a <= 0){
discard;
}

uint id = texture(object_ids, frag_uv).x;
uint id = texture(objectid_buffer, frag_uv).x;
// do tonemappings
//opaque = linear_tone_mapping(color.rgb, 1.8); // linear color output
fragment_color.rgb = color.rgb;

#ifdef FILTER_IN_SHADER
// we store fxaa = true/false in highbit of the object id
if (unpack_bool(id)) {
fragment_color.a = dot(color.rgb, vec3(0.299, 0.587, 0.114)); // compute luma
} else {
// we disable fxaa by setting luma to 1
fragment_color.a = 1.0;
}
#else
fragment_color.a = dot(color.rgb, vec3(0.299, 0.587, 0.114)); // compute luma
#endif
}
4 changes: 2 additions & 2 deletions GLMakie/src/GLAbstraction/AbstractGPUArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ gpu_setindex!(t) = error("gpu_setindex! not implemented for: $(typeof(t)). This
max_dim(t) = error("max_dim not implemented for: $(typeof(t)). This happens, when you call setindex! on an array, without implementing the GPUArray interface")


function (::Type{GPUArrayType})(data::Observable; kw...) where GPUArrayType <: GPUArray
gpu_mem = GPUArrayType(data[]; kw...)
function (::Type{GPUArrayType})(context, data::Observable; kw...) where GPUArrayType <: GPUArray
gpu_mem = GPUArrayType(context, data[]; kw...)
# TODO merge these and handle update tracking during construction
obs2 = on(new_data -> update!(gpu_mem, new_data), data)
if GPUArrayType <: TextureBuffer
Expand Down
24 changes: 23 additions & 1 deletion GLMakie/src/GLAbstraction/GLAbstraction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ import FixedPointNumbers: N0f8, N0f16, N0f8, Normed

import Base: merge, resize!, similar, length, getindex, setindex!

# Debug tools
const GLMAKIE_DEBUG = Ref(false)

# implemented in GLMakie/glwindow.jl
function require_context_no_error(args...) end

function require_context(ctx, current = ShaderAbstractions.current_context())
msg = require_context_no_error(ctx, current)
isnothing(msg) && return nothing
error(msg)
end

export require_context

include("AbstractGPUArray.jl")

#Methods which get overloaded by GLExtendedFunctions.jl:
Expand All @@ -41,9 +55,9 @@ import ModernGL.glGetShaderiv
import ModernGL.glViewport
import ModernGL.glScissor

include("shaderabstraction.jl")
include("GLUtils.jl")

include("shaderabstraction.jl")
include("GLTypes.jl")
export GLProgram # Shader/program object
export Texture # Texture object, basically a 1/2/3D OpenGL data array
Expand Down Expand Up @@ -99,4 +113,12 @@ export getUniformsInfo
export getProgramInfo
export getAttributesInfo

include("GLFramebuffer.jl")
export GLRenderbuffer
export GLFramebuffer
export attach_colorbuffer, attach_depthbuffer, attach_stencilbuffer, attach_depthstencilbuffer
export get_attachment, get_buffer
export set_draw_buffers
export check_framebuffer

end # module
Loading
Loading