From 8ed8301452fef61e7ddbc574de5f4a252e1559a4 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 12 Jan 2022 06:34:00 -0800 Subject: [PATCH] libobs-opengl: Fix border color support on GL textures --- libobs-opengl/gl-helpers.h | 6 ++++++ libobs-opengl/gl-subsystem.c | 9 +++++++++ libobs-opengl/gl-subsystem.h | 1 + 3 files changed, 16 insertions(+) diff --git a/libobs-opengl/gl-helpers.h b/libobs-opengl/gl-helpers.h index 8daad18a3..216cca28a 100644 --- a/libobs-opengl/gl-helpers.h +++ b/libobs-opengl/gl-helpers.h @@ -173,6 +173,12 @@ static inline bool gl_tex_param_f(GLenum target, GLenum param, GLfloat val) return gl_success("glTexParameterf"); } +static inline bool gl_tex_param_fv(GLenum target, GLenum param, GLfloat *val) +{ + glTexParameterfv(target, param, val); + return gl_success("glTexParameterf"); +} + static inline bool gl_tex_param_i(GLenum target, GLenum param, GLint val) { glTexParameteri(target, param, val); diff --git a/libobs-opengl/gl-subsystem.c b/libobs-opengl/gl-subsystem.c index d53f9e123..e49c89788 100644 --- a/libobs-opengl/gl-subsystem.c +++ b/libobs-opengl/gl-subsystem.c @@ -199,6 +199,8 @@ void convert_sampler_info(struct gs_sampler_state *sampler, else if (sampler->max_anisotropy > max_anisotropy_max) sampler->max_anisotropy = max_anisotropy_max; + vec4_from_rgba(&sampler->border_color, info->border_color); + blog(LOG_DEBUG, "convert_sampler_info: 1 <= max_anisotropy <= " "%d violated, selected: %d, set: %d", @@ -473,6 +475,13 @@ static bool load_texture_sampler(gs_texture_t *tex, gs_samplerstate_t *ss) success = false; if (!gl_tex_param_i(tex->gl_target, GL_TEXTURE_WRAP_R, ss->address_w)) success = false; + if (ss->address_u == GL_CLAMP_TO_BORDER || + ss->address_v == GL_CLAMP_TO_BORDER || + ss->address_w == GL_CLAMP_TO_BORDER) { + if (!gl_tex_param_fv(tex->gl_target, GL_TEXTURE_BORDER_COLOR, + ss->border_color.ptr)) + success = false; + } if (GLAD_GL_EXT_texture_filter_anisotropic) { if (!gl_tex_param_i(tex->gl_target, GL_TEXTURE_MAX_ANISOTROPY_EXT, diff --git a/libobs-opengl/gl-subsystem.h b/libobs-opengl/gl-subsystem.h index e1958b72a..b2ea76cdc 100644 --- a/libobs-opengl/gl-subsystem.h +++ b/libobs-opengl/gl-subsystem.h @@ -419,6 +419,7 @@ struct gs_sampler_state { GLint address_v; GLint address_w; GLint max_anisotropy; + struct vec4 border_color; }; static inline void samplerstate_addref(gs_samplerstate_t *ss)