Skip to content

Commit

Permalink
opengl/context: disable SSBO on GLSL < 140
Browse files Browse the repository at this point in the history
The layout of variables inside an SSBO is implementation-defined making
it not really safe to use without layout specification, which is
supported on GLSL >= 140.
  • Loading branch information
kasper93 committed Feb 12, 2023
1 parent 56abbd2 commit 6c30dde
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/opengl/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ pl_opengl pl_opengl_create(pl_log log, const struct pl_opengl_params *params)
params->max_glsl_version, glsl->version);
}

// The layout of variables inside an SSBO is implementation-defined,
// disable SSBO if layout qualifier is not supported.
struct pl_gpu_t *gpu = (struct pl_gpu_t *) pl_gl->gpu;
if (gpu->glsl.version < 140)
gpu->limits.max_ssbo_size = 0;

gl_release_current(pl_gl);
return pl_gl;

Expand Down
6 changes: 2 additions & 4 deletions src/tests/gpu_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ static void pl_buffer_tests(pl_gpu gpu)
}

// `compute_queues` check is to exclude dummy GPUs here
if (buf_size <= gpu->limits.max_ssbo_size &&
gpu->limits.compute_queues &&
gpu->glsl.version >= 130)
if (buf_size <= gpu->limits.max_ssbo_size && gpu->limits.compute_queues)
{
printf("test endian swapping\n");
buf = pl_buf_create(gpu, pl_buf_params(
Expand Down Expand Up @@ -1158,7 +1156,7 @@ static void pl_render_tests(pl_gpu gpu)
hook = pl_mpv_user_shader_parse(gpu, user_shader_tests[i],
strlen(user_shader_tests[i]));

if (gpu->glsl.compute) {
if (gpu->glsl.compute && gpu->limits.max_ssbo_size) {
REQUIRE(hook);
} else {
// Not all shaders compile without compute shader support
Expand Down

0 comments on commit 6c30dde

Please sign in to comment.