You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
vlc/1244.patch

260 lines
9.5 KiB

From 110d69c8245bb2bc1f0cf183dcdd6ba636973bfc Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.dev>
Date: Tue, 18 Jan 2022 16:47:22 +0100
Subject: [PATCH 1/4] Revert "opengl: vout_helper: use pl_gpu_dummy for
shaders"
This reverts commit 2437484d7684a4661048df1e095484a276bbea0b.
The referenced commit is not a good way of fixing the issue described in
its commit message. Attaching a dummy GPU to the pl_shader makes the
shader think a GPU is actually available, and can lead to e.g. the use
of a dither texture (which VLC has no mapping code for, and would thus
result in a shader compilation error).
All of the queried limits are also irrelevant for the way we use shaders
in this code, since they only affect GPU resources (which we can't use)
or texture sampling (which we don't use).
Fixes #26503 by removing the conflicting code
---
modules/video_output/opengl/converter.h | 1 -
modules/video_output/opengl/vout_helper.c | 78 +----------------------
2 files changed, 2 insertions(+), 77 deletions(-)
diff --git a/modules/video_output/opengl/converter.h b/modules/video_output/opengl/converter.h
index f8f0c12024..b69807f8cd 100644
--- a/modules/video_output/opengl/converter.h
+++ b/modules/video_output/opengl/converter.h
@@ -340,7 +340,6 @@ struct opengl_tex_converter_t
bool yuv_color;
GLfloat yuv_coefficients[16];
- const struct pl_gpu *pl_gpu;
struct pl_shader *pl_sh;
const struct pl_shader_res *pl_sh_res;
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index bf07c1c03f..711a14b7ae 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -44,12 +44,6 @@
#include "vout_helper.h"
#include "internal.h"
-#if HAVE_LIBPLACEBO
-#if PL_API_VER >= 18
-#include <libplacebo/dummy.h>
-#endif
-#endif
-
#ifndef GL_CLAMP_TO_EDGE
# define GL_CLAMP_TO_EDGE 0x812F
#endif
@@ -576,10 +570,6 @@ opengl_deinit_program(vout_display_opengl_t *vgl, struct prgm *prgm)
#ifdef HAVE_LIBPLACEBO
FREENULL(tc->uloc.pl_vars);
-#if PL_API_VER >= 18
- if (tc->pl_gpu)
- pl_gpu_dummy_destroy(&tc->pl_gpu);
-#endif
if (tc->pl_ctx)
pl_context_destroy(&tc->pl_ctx);
#endif
@@ -632,78 +622,14 @@ opengl_init_program(vout_display_opengl_t *vgl, struct prgm *prgm,
// create the main libplacebo context
if (!subpics)
{
-#if PL_API_VER >= 18
- struct pl_gpu_dummy_params gpu_dummy_params = {
- .caps = PL_GPU_CAP_INPUT_VARIABLES,
- .glsl = (struct pl_glsl_desc) {
-#ifdef USE_OPENGL_ES2
- .version = 100,
- .gles = true,
-#else
- .version = 120,
-#endif
- .vulkan = false,
- },
- .limits = { 0 }
- };
-#endif
-
- const opengl_vtable_t *vt = tc->vt;
-
-#if PL_API_VER >= 18
- vt->GetIntegerv(GL_MAX_TEXTURE_SIZE,
- (GLint *)&gpu_dummy_params.limits.max_tex_1d_dim);
- gpu_dummy_params.limits.max_tex_2d_dim = gpu_dummy_params.limits.max_tex_1d_dim;
-#ifndef USE_OPENGL_ES2
- vt->GetIntegerv(GL_MAX_3D_TEXTURE_SIZE,
- (GLint *)&gpu_dummy_params.limits.max_tex_3d_dim);
- vt->GetIntegerv(GL_MAX_UNIFORM_BLOCK_SIZE,
- (GLint *)&gpu_dummy_params.limits.max_ubo_size);
- vt->GetIntegerv(GL_MAX_SHADER_STORAGE_BLOCK_SIZE,
- (GLint *)&gpu_dummy_params.limits.max_ssbo_size);
- vt->GetIntegerv(GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET_ARB,
- (GLint *)&gpu_dummy_params.limits.min_gather_offset);
- vt->GetIntegerv(GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET_ARB,
- (GLint *)&gpu_dummy_params.limits.max_gather_offset);
- vt->GetIntegerv(GL_MAX_COMPUTE_SHARED_MEMORY_SIZE,
- (GLint *)&gpu_dummy_params.limits.max_shmem_size);
- vt->GetIntegerv(GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS,
- (GLint *)&gpu_dummy_params.limits.max_group_threads);
- if (vt->GetIntegeri_v != NULL)
- {
- for (int i = 0; i < 3; i++)
- {
- vt->GetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_COUNT, i,
- (GLint *)&gpu_dummy_params.limits.max_dispatch[i]);
- vt->GetIntegeri_v(GL_MAX_COMPUTE_WORK_GROUP_SIZE, i,
- (GLint *)&gpu_dummy_params.limits.max_group_size[i]);
- }
- }
-#endif
-#endif
-
- /* Drain potential errors, non-existing variables will be set to zero */
- while (vt->GetError() != GL_NO_ERROR) {}
-
tc->pl_ctx = pl_context_create(PL_API_VER, &(struct pl_context_params) {
.log_cb = log_cb,
.log_priv = tc,
.log_level = PL_LOG_INFO,
});
-
if (tc->pl_ctx) {
-#if PL_API_VER >= 18
- /* pl_gpu = NULL is not fatal but might generate incorrect shaders
- * depending or more recent GLSL version than VLC shaders. */
- tc->pl_gpu = pl_gpu_dummy_create(tc->pl_ctx, &gpu_dummy_params);
-
- struct pl_shader_params shader_params = {
- .gpu = tc->pl_gpu,
- };
-#endif
-
# if PL_API_VER >= 20
- tc->pl_sh = pl_shader_alloc(tc->pl_ctx, &shader_params);
+ tc->pl_sh = pl_shader_alloc(tc->pl_ctx, NULL);
# elif PL_API_VER >= 6
tc->pl_sh = pl_shader_alloc(tc->pl_ctx, NULL, 0);
# else
@@ -861,7 +787,7 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
GET_PROC_ADDR_CORE(GetError);
GET_PROC_ADDR_CORE(GetIntegerv);
#ifndef USE_OPENGL_ES2
- GET_PROC_ADDR_OPTIONAL(GetIntegeri_v);
+ GET_PROC_ADDR_CORE(GetIntegeri_v);
#endif
GET_PROC_ADDR_CORE(GetString);
GET_PROC_ADDR_CORE(PixelStorei);
--
GitLab
From 6d145e38c03d4ffa5b6bff31e358a5ca6ceb3461 Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.dev>
Date: Tue, 18 Jan 2022 17:07:25 +0100
Subject: [PATCH 2/4] opengl: vout_helper: use pl_shader_params.glsl
This is the proper way to limit the GLSL version when using standalone
shaders without an associated GPU backend.
---
modules/video_output/opengl/vout_helper.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index 711a14b7ae..a98621a859 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -629,7 +629,10 @@ opengl_init_program(vout_display_opengl_t *vgl, struct prgm *prgm,
});
if (tc->pl_ctx) {
# if PL_API_VER >= 20
- tc->pl_sh = pl_shader_alloc(tc->pl_ctx, NULL);
+ tc->pl_sh = pl_shader_alloc(tc->pl_ctx, &(struct pl_shader_params) {
+ .glsl.version = tc->glsl_version,
+ .glsl.gles = tc->is_gles,
+ });
# elif PL_API_VER >= 6
tc->pl_sh = pl_shader_alloc(tc->pl_ctx, NULL, 0);
# else
--
GitLab
From 645cbd6fac5bd07d1c973be9fc048b0f329c087c Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.dev>
Date: Tue, 18 Jan 2022 17:19:27 +0100
Subject: [PATCH 3/4] opengl: don't error on no-op libplacebo shader
See 6efc345d81a12
---
modules/video_output/opengl/fragment_shaders.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/video_output/opengl/fragment_shaders.c b/modules/video_output/opengl/fragment_shaders.c
index e0b98732ca..ecf7226f0e 100644
--- a/modules/video_output/opengl/fragment_shaders.c
+++ b/modules/video_output/opengl/fragment_shaders.c
@@ -765,8 +765,8 @@ opengl_fragment_shader_init_impl(opengl_tex_converter_t *tc, GLenum tex_target,
}
#ifdef HAVE_LIBPLACEBO
- if (tc->pl_sh_res) {
- const struct pl_shader_res *res = tc->pl_sh_res;
+ const struct pl_shader_res *res = tc->pl_sh_res;
+ if (res && res->input != PL_SHADER_SIG_NONE) {
assert(res->input == PL_SHADER_SIG_COLOR);
assert(res->output == PL_SHADER_SIG_COLOR);
ADDF(" result = %s(result);\n", res->name);
--
GitLab
From 37bf74e6645d3023c1ebcbd81ffae1e552d3a73e Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.dev>
Date: Tue, 18 Jan 2022 18:03:48 +0100
Subject: [PATCH 4/4] opengl: drop unneeded GetIntegeri_v
This causes issues on some platforms, and we don't need it
---
modules/video_output/opengl/converter.h | 3 ---
modules/video_output/opengl/vout_helper.c | 3 ---
2 files changed, 6 deletions(-)
diff --git a/modules/video_output/opengl/converter.h b/modules/video_output/opengl/converter.h
index b69807f8cd..7000e1f38e 100644
--- a/modules/video_output/opengl/converter.h
+++ b/modules/video_output/opengl/converter.h
@@ -167,9 +167,6 @@ typedef struct {
PFNGLGENTEXTURESPROC GenTextures;
PFNGLGETERRORPROC GetError;
PFNGLGETINTEGERVPROC GetIntegerv;
-#ifndef USE_OPENGL_ES2
- PFNGLGETINTEGERIVPROC GetIntegeri_v;
-#endif
PFNGLGETSTRINGPROC GetString;
PFNGLPIXELSTOREIPROC PixelStorei;
PFNGLTEXIMAGE2DPROC TexImage2D;
diff --git a/modules/video_output/opengl/vout_helper.c b/modules/video_output/opengl/vout_helper.c
index a98621a859..13d65e04c8 100644
--- a/modules/video_output/opengl/vout_helper.c
+++ b/modules/video_output/opengl/vout_helper.c
@@ -789,9 +789,6 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
GET_PROC_ADDR_CORE(GenTextures);
GET_PROC_ADDR_CORE(GetError);
GET_PROC_ADDR_CORE(GetIntegerv);
-#ifndef USE_OPENGL_ES2
- GET_PROC_ADDR_CORE(GetIntegeri_v);
-#endif
GET_PROC_ADDR_CORE(GetString);
GET_PROC_ADDR_CORE(PixelStorei);
GET_PROC_ADDR_CORE(TexImage2D);
--
GitLab