2013-10-01 00:29:40 -07:00
|
|
|
/******************************************************************************
|
|
|
|
Copyright (C) 2013 by Hugh Bailey <obs.jim@gmail.com>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2013-12-02 21:24:38 -08:00
|
|
|
the Free Software Foundation, either version 2 of the License, or
|
2013-10-01 00:29:40 -07:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
******************************************************************************/
|
|
|
|
|
2013-10-14 04:21:15 -07:00
|
|
|
#pragma once
|
2013-10-01 00:29:40 -07:00
|
|
|
|
2013-11-26 22:07:27 -08:00
|
|
|
#include <util/darray.h>
|
2014-03-16 18:26:46 -07:00
|
|
|
#include <util/threading.h>
|
2013-11-26 22:07:27 -08:00
|
|
|
#include <graphics/graphics.h>
|
2014-03-29 17:19:31 -07:00
|
|
|
#include <graphics/device-exports.h>
|
2013-11-26 22:07:27 -08:00
|
|
|
#include <graphics/matrix4.h>
|
2014-01-06 15:51:45 -08:00
|
|
|
|
2014-04-14 14:28:07 -07:00
|
|
|
#include <glad/glad.h>
|
2014-01-06 15:51:45 -08:00
|
|
|
|
2013-10-04 08:55:33 -07:00
|
|
|
#include "gl-helpers.h"
|
2013-10-02 00:59:06 -07:00
|
|
|
|
|
|
|
struct gl_platform;
|
2013-10-02 19:50:33 -07:00
|
|
|
struct gl_windowinfo;
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
enum copy_type { COPY_TYPE_ARB, COPY_TYPE_NV, COPY_TYPE_FBO_BLIT };
|
2013-10-10 17:39:56 -07:00
|
|
|
|
2018-08-29 14:40:00 -07:00
|
|
|
static inline GLenum convert_gs_format(enum gs_color_format format)
|
2013-10-04 08:55:33 -07:00
|
|
|
{
|
|
|
|
switch (format) {
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_A8:
|
|
|
|
return GL_RED;
|
|
|
|
case GS_R8:
|
|
|
|
return GL_RED;
|
|
|
|
case GS_RGBA:
|
|
|
|
return GL_RGBA;
|
|
|
|
case GS_BGRX:
|
|
|
|
return GL_BGRA;
|
|
|
|
case GS_BGRA:
|
|
|
|
return GL_BGRA;
|
|
|
|
case GS_R10G10B10A2:
|
|
|
|
return GL_RGBA;
|
|
|
|
case GS_RGBA16:
|
|
|
|
return GL_RGBA;
|
|
|
|
case GS_R16:
|
|
|
|
return GL_RED;
|
|
|
|
case GS_RGBA16F:
|
|
|
|
return GL_RGBA;
|
|
|
|
case GS_RGBA32F:
|
|
|
|
return GL_RGBA;
|
|
|
|
case GS_RG16F:
|
|
|
|
return GL_RG;
|
|
|
|
case GS_RG32F:
|
|
|
|
return GL_RG;
|
|
|
|
case GS_R8G8:
|
|
|
|
return GL_RG;
|
|
|
|
case GS_R16F:
|
|
|
|
return GL_RED;
|
|
|
|
case GS_R32F:
|
|
|
|
return GL_RED;
|
|
|
|
case GS_DXT1:
|
|
|
|
return GL_RGB;
|
|
|
|
case GS_DXT3:
|
|
|
|
return GL_RGBA;
|
|
|
|
case GS_DXT5:
|
|
|
|
return GL_RGBA;
|
libobs: Add dormant SRGB format support
GS_RGBA, GS_BGRX, and GS_BGRA now use TYPELESS DXGI formats, so we can
alias them between UNORM and UNORM_SRGB as necessary. GS_RGBA_UNORM,
GS_BGRX_UNORM, and GS_BGRA_UNORM have been added to support straight
UNORM types, which Windows requires for sharing textures from D3D9 and
OpenGL. The D3D path aliases via views, and GL aliases via
GL_EXT_texture_sRGB_decode/GL_FRAMEBUFFER_SRGB.
A significant amount of code has changed in the D3D/GL backends, but the
concepts are simple. On the D3D side, we need separate SRVs and RTVs to
support nonlinear/linear reads and writes. On the GL side, we need to
set the proper GL parameters to emulate the same.
Add gs_enable_framebuffer_srgb/gs_framebuffer_srgb_enabled to set/get
the framebuffer as SRGB or not.
Add gs_linear_srgb_active/gs_set_linear_srgb to instruct sources that
they should render as SRGB. Legacy sources can ignore this setting
without regression.
Update obs_source_draw to use linear SRGB as needed.
Update render_filter_tex to use linear SRGB as needed.
Add gs_effect_set_texture_srgb next to gs_effect_set_texture to set
texture with SRGB view instead.
Add SRGB helpers for vec4 struct.
Create GDI-compatible textures without SRGB support. Doesn't seem to
work with SRGB formats.
2021-01-19 15:00:51 -08:00
|
|
|
case GS_RGBA_UNORM:
|
|
|
|
return GL_RGBA;
|
|
|
|
case GS_BGRX_UNORM:
|
|
|
|
return GL_BGRA;
|
|
|
|
case GS_BGRA_UNORM:
|
|
|
|
return GL_BGRA;
|
2022-01-25 02:50:30 -08:00
|
|
|
case GS_RG16:
|
|
|
|
return GL_RG;
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_UNKNOWN:
|
|
|
|
return 0;
|
2013-10-04 08:55:33 -07:00
|
|
|
}
|
2013-10-24 01:29:06 -07:00
|
|
|
|
|
|
|
return 0;
|
2013-10-04 08:55:33 -07:00
|
|
|
}
|
|
|
|
|
2018-08-29 14:40:00 -07:00
|
|
|
static inline GLenum convert_gs_internal_format(enum gs_color_format format)
|
2013-10-04 08:55:33 -07:00
|
|
|
{
|
|
|
|
switch (format) {
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_A8:
|
|
|
|
return GL_R8; /* NOTE: use GL_TEXTURE_SWIZZLE_x */
|
|
|
|
case GS_R8:
|
|
|
|
return GL_R8;
|
|
|
|
case GS_RGBA:
|
libobs: Add dormant SRGB format support
GS_RGBA, GS_BGRX, and GS_BGRA now use TYPELESS DXGI formats, so we can
alias them between UNORM and UNORM_SRGB as necessary. GS_RGBA_UNORM,
GS_BGRX_UNORM, and GS_BGRA_UNORM have been added to support straight
UNORM types, which Windows requires for sharing textures from D3D9 and
OpenGL. The D3D path aliases via views, and GL aliases via
GL_EXT_texture_sRGB_decode/GL_FRAMEBUFFER_SRGB.
A significant amount of code has changed in the D3D/GL backends, but the
concepts are simple. On the D3D side, we need separate SRVs and RTVs to
support nonlinear/linear reads and writes. On the GL side, we need to
set the proper GL parameters to emulate the same.
Add gs_enable_framebuffer_srgb/gs_framebuffer_srgb_enabled to set/get
the framebuffer as SRGB or not.
Add gs_linear_srgb_active/gs_set_linear_srgb to instruct sources that
they should render as SRGB. Legacy sources can ignore this setting
without regression.
Update obs_source_draw to use linear SRGB as needed.
Update render_filter_tex to use linear SRGB as needed.
Add gs_effect_set_texture_srgb next to gs_effect_set_texture to set
texture with SRGB view instead.
Add SRGB helpers for vec4 struct.
Create GDI-compatible textures without SRGB support. Doesn't seem to
work with SRGB formats.
2021-01-19 15:00:51 -08:00
|
|
|
return GL_SRGB8_ALPHA8;
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_BGRX:
|
libobs: Add dormant SRGB format support
GS_RGBA, GS_BGRX, and GS_BGRA now use TYPELESS DXGI formats, so we can
alias them between UNORM and UNORM_SRGB as necessary. GS_RGBA_UNORM,
GS_BGRX_UNORM, and GS_BGRA_UNORM have been added to support straight
UNORM types, which Windows requires for sharing textures from D3D9 and
OpenGL. The D3D path aliases via views, and GL aliases via
GL_EXT_texture_sRGB_decode/GL_FRAMEBUFFER_SRGB.
A significant amount of code has changed in the D3D/GL backends, but the
concepts are simple. On the D3D side, we need separate SRVs and RTVs to
support nonlinear/linear reads and writes. On the GL side, we need to
set the proper GL parameters to emulate the same.
Add gs_enable_framebuffer_srgb/gs_framebuffer_srgb_enabled to set/get
the framebuffer as SRGB or not.
Add gs_linear_srgb_active/gs_set_linear_srgb to instruct sources that
they should render as SRGB. Legacy sources can ignore this setting
without regression.
Update obs_source_draw to use linear SRGB as needed.
Update render_filter_tex to use linear SRGB as needed.
Add gs_effect_set_texture_srgb next to gs_effect_set_texture to set
texture with SRGB view instead.
Add SRGB helpers for vec4 struct.
Create GDI-compatible textures without SRGB support. Doesn't seem to
work with SRGB formats.
2021-01-19 15:00:51 -08:00
|
|
|
return GL_SRGB8;
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_BGRA:
|
libobs: Add dormant SRGB format support
GS_RGBA, GS_BGRX, and GS_BGRA now use TYPELESS DXGI formats, so we can
alias them between UNORM and UNORM_SRGB as necessary. GS_RGBA_UNORM,
GS_BGRX_UNORM, and GS_BGRA_UNORM have been added to support straight
UNORM types, which Windows requires for sharing textures from D3D9 and
OpenGL. The D3D path aliases via views, and GL aliases via
GL_EXT_texture_sRGB_decode/GL_FRAMEBUFFER_SRGB.
A significant amount of code has changed in the D3D/GL backends, but the
concepts are simple. On the D3D side, we need separate SRVs and RTVs to
support nonlinear/linear reads and writes. On the GL side, we need to
set the proper GL parameters to emulate the same.
Add gs_enable_framebuffer_srgb/gs_framebuffer_srgb_enabled to set/get
the framebuffer as SRGB or not.
Add gs_linear_srgb_active/gs_set_linear_srgb to instruct sources that
they should render as SRGB. Legacy sources can ignore this setting
without regression.
Update obs_source_draw to use linear SRGB as needed.
Update render_filter_tex to use linear SRGB as needed.
Add gs_effect_set_texture_srgb next to gs_effect_set_texture to set
texture with SRGB view instead.
Add SRGB helpers for vec4 struct.
Create GDI-compatible textures without SRGB support. Doesn't seem to
work with SRGB formats.
2021-01-19 15:00:51 -08:00
|
|
|
return GL_SRGB8_ALPHA8;
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_R10G10B10A2:
|
|
|
|
return GL_RGB10_A2;
|
|
|
|
case GS_RGBA16:
|
|
|
|
return GL_RGBA16;
|
|
|
|
case GS_R16:
|
|
|
|
return GL_R16;
|
|
|
|
case GS_RGBA16F:
|
|
|
|
return GL_RGBA16F;
|
|
|
|
case GS_RGBA32F:
|
|
|
|
return GL_RGBA32F;
|
|
|
|
case GS_RG16F:
|
|
|
|
return GL_RG16F;
|
|
|
|
case GS_RG32F:
|
|
|
|
return GL_RG32F;
|
|
|
|
case GS_R8G8:
|
2019-07-23 08:29:54 -07:00
|
|
|
return GL_RG8;
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_R16F:
|
|
|
|
return GL_R16F;
|
|
|
|
case GS_R32F:
|
|
|
|
return GL_R32F;
|
|
|
|
case GS_DXT1:
|
|
|
|
return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
|
|
|
|
case GS_DXT3:
|
|
|
|
return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
|
|
|
|
case GS_DXT5:
|
|
|
|
return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
|
libobs: Add dormant SRGB format support
GS_RGBA, GS_BGRX, and GS_BGRA now use TYPELESS DXGI formats, so we can
alias them between UNORM and UNORM_SRGB as necessary. GS_RGBA_UNORM,
GS_BGRX_UNORM, and GS_BGRA_UNORM have been added to support straight
UNORM types, which Windows requires for sharing textures from D3D9 and
OpenGL. The D3D path aliases via views, and GL aliases via
GL_EXT_texture_sRGB_decode/GL_FRAMEBUFFER_SRGB.
A significant amount of code has changed in the D3D/GL backends, but the
concepts are simple. On the D3D side, we need separate SRVs and RTVs to
support nonlinear/linear reads and writes. On the GL side, we need to
set the proper GL parameters to emulate the same.
Add gs_enable_framebuffer_srgb/gs_framebuffer_srgb_enabled to set/get
the framebuffer as SRGB or not.
Add gs_linear_srgb_active/gs_set_linear_srgb to instruct sources that
they should render as SRGB. Legacy sources can ignore this setting
without regression.
Update obs_source_draw to use linear SRGB as needed.
Update render_filter_tex to use linear SRGB as needed.
Add gs_effect_set_texture_srgb next to gs_effect_set_texture to set
texture with SRGB view instead.
Add SRGB helpers for vec4 struct.
Create GDI-compatible textures without SRGB support. Doesn't seem to
work with SRGB formats.
2021-01-19 15:00:51 -08:00
|
|
|
case GS_RGBA_UNORM:
|
|
|
|
return GL_RGBA;
|
|
|
|
case GS_BGRX_UNORM:
|
|
|
|
return GL_RGB;
|
|
|
|
case GS_BGRA_UNORM:
|
|
|
|
return GL_RGBA;
|
2022-01-25 02:50:30 -08:00
|
|
|
case GS_RG16:
|
|
|
|
return GL_RG16;
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_UNKNOWN:
|
|
|
|
return 0;
|
2013-10-04 08:55:33 -07:00
|
|
|
}
|
2013-10-24 01:29:06 -07:00
|
|
|
|
|
|
|
return 0;
|
2013-10-04 08:55:33 -07:00
|
|
|
}
|
|
|
|
|
2013-10-16 23:31:18 -07:00
|
|
|
static inline GLenum get_gl_format_type(enum gs_color_format format)
|
2013-10-10 17:39:56 -07:00
|
|
|
{
|
|
|
|
switch (format) {
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_A8:
|
|
|
|
return GL_UNSIGNED_BYTE;
|
|
|
|
case GS_R8:
|
|
|
|
return GL_UNSIGNED_BYTE;
|
|
|
|
case GS_RGBA:
|
|
|
|
return GL_UNSIGNED_BYTE;
|
|
|
|
case GS_BGRX:
|
|
|
|
return GL_UNSIGNED_BYTE;
|
|
|
|
case GS_BGRA:
|
|
|
|
return GL_UNSIGNED_BYTE;
|
|
|
|
case GS_R10G10B10A2:
|
2021-07-11 04:38:16 -07:00
|
|
|
return GL_UNSIGNED_INT_2_10_10_10_REV;
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_RGBA16:
|
|
|
|
return GL_UNSIGNED_SHORT;
|
|
|
|
case GS_R16:
|
|
|
|
return GL_UNSIGNED_SHORT;
|
|
|
|
case GS_RGBA16F:
|
2020-01-03 23:42:53 -08:00
|
|
|
return GL_HALF_FLOAT;
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_RGBA32F:
|
|
|
|
return GL_FLOAT;
|
|
|
|
case GS_RG16F:
|
2020-01-03 23:42:53 -08:00
|
|
|
return GL_HALF_FLOAT;
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_RG32F:
|
|
|
|
return GL_FLOAT;
|
|
|
|
case GS_R8G8:
|
2019-07-23 08:29:54 -07:00
|
|
|
return GL_UNSIGNED_BYTE;
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_R16F:
|
2020-01-03 23:42:53 -08:00
|
|
|
return GL_HALF_FLOAT;
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_R32F:
|
|
|
|
return GL_FLOAT;
|
|
|
|
case GS_DXT1:
|
|
|
|
return GL_UNSIGNED_BYTE;
|
|
|
|
case GS_DXT3:
|
|
|
|
return GL_UNSIGNED_BYTE;
|
|
|
|
case GS_DXT5:
|
|
|
|
return GL_UNSIGNED_BYTE;
|
libobs: Add dormant SRGB format support
GS_RGBA, GS_BGRX, and GS_BGRA now use TYPELESS DXGI formats, so we can
alias them between UNORM and UNORM_SRGB as necessary. GS_RGBA_UNORM,
GS_BGRX_UNORM, and GS_BGRA_UNORM have been added to support straight
UNORM types, which Windows requires for sharing textures from D3D9 and
OpenGL. The D3D path aliases via views, and GL aliases via
GL_EXT_texture_sRGB_decode/GL_FRAMEBUFFER_SRGB.
A significant amount of code has changed in the D3D/GL backends, but the
concepts are simple. On the D3D side, we need separate SRVs and RTVs to
support nonlinear/linear reads and writes. On the GL side, we need to
set the proper GL parameters to emulate the same.
Add gs_enable_framebuffer_srgb/gs_framebuffer_srgb_enabled to set/get
the framebuffer as SRGB or not.
Add gs_linear_srgb_active/gs_set_linear_srgb to instruct sources that
they should render as SRGB. Legacy sources can ignore this setting
without regression.
Update obs_source_draw to use linear SRGB as needed.
Update render_filter_tex to use linear SRGB as needed.
Add gs_effect_set_texture_srgb next to gs_effect_set_texture to set
texture with SRGB view instead.
Add SRGB helpers for vec4 struct.
Create GDI-compatible textures without SRGB support. Doesn't seem to
work with SRGB formats.
2021-01-19 15:00:51 -08:00
|
|
|
case GS_RGBA_UNORM:
|
|
|
|
return GL_UNSIGNED_BYTE;
|
|
|
|
case GS_BGRX_UNORM:
|
|
|
|
return GL_UNSIGNED_BYTE;
|
|
|
|
case GS_BGRA_UNORM:
|
|
|
|
return GL_UNSIGNED_BYTE;
|
2022-01-25 02:50:30 -08:00
|
|
|
case GS_RG16:
|
|
|
|
return GL_UNSIGNED_SHORT;
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_UNKNOWN:
|
|
|
|
return 0;
|
2013-10-10 17:39:56 -07:00
|
|
|
}
|
2013-10-24 01:29:06 -07:00
|
|
|
|
|
|
|
return GL_UNSIGNED_BYTE;
|
2013-10-10 17:39:56 -07:00
|
|
|
}
|
|
|
|
|
2013-10-10 12:37:03 -07:00
|
|
|
static inline GLenum convert_zstencil_format(enum gs_zstencil_format format)
|
2013-10-04 08:55:33 -07:00
|
|
|
{
|
|
|
|
switch (format) {
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_Z16:
|
|
|
|
return GL_DEPTH_COMPONENT16;
|
|
|
|
case GS_Z24_S8:
|
|
|
|
return GL_DEPTH24_STENCIL8;
|
|
|
|
case GS_Z32F:
|
|
|
|
return GL_DEPTH_COMPONENT32F;
|
|
|
|
case GS_Z32F_S8X24:
|
|
|
|
return GL_DEPTH32F_STENCIL8;
|
|
|
|
case GS_ZS_NONE:
|
|
|
|
return 0;
|
2013-10-04 08:55:33 -07:00
|
|
|
}
|
2013-10-24 01:29:06 -07:00
|
|
|
|
|
|
|
return 0;
|
2013-10-04 08:55:33 -07:00
|
|
|
}
|
|
|
|
|
2013-10-12 20:18:05 -07:00
|
|
|
static inline GLenum convert_gs_depth_test(enum gs_depth_test test)
|
|
|
|
{
|
|
|
|
switch (test) {
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_NEVER:
|
|
|
|
return GL_NEVER;
|
|
|
|
case GS_LESS:
|
|
|
|
return GL_LESS;
|
|
|
|
case GS_LEQUAL:
|
|
|
|
return GL_LEQUAL;
|
|
|
|
case GS_EQUAL:
|
|
|
|
return GL_EQUAL;
|
|
|
|
case GS_GEQUAL:
|
|
|
|
return GL_GEQUAL;
|
|
|
|
case GS_GREATER:
|
|
|
|
return GL_GREATER;
|
|
|
|
case GS_NOTEQUAL:
|
|
|
|
return GL_NOTEQUAL;
|
|
|
|
case GS_ALWAYS:
|
|
|
|
return GL_ALWAYS;
|
2013-10-12 20:18:05 -07:00
|
|
|
}
|
2013-10-24 01:29:06 -07:00
|
|
|
|
|
|
|
return GL_NEVER;
|
2013-10-12 20:18:05 -07:00
|
|
|
}
|
|
|
|
|
2014-08-07 23:42:07 -07:00
|
|
|
static inline GLenum convert_gs_stencil_op(enum gs_stencil_op_type op)
|
2013-10-12 20:18:05 -07:00
|
|
|
{
|
|
|
|
switch (op) {
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_KEEP:
|
|
|
|
return GL_KEEP;
|
|
|
|
case GS_ZERO:
|
|
|
|
return GL_ZERO;
|
|
|
|
case GS_REPLACE:
|
|
|
|
return GL_REPLACE;
|
|
|
|
case GS_INCR:
|
|
|
|
return GL_INCR;
|
|
|
|
case GS_DECR:
|
|
|
|
return GL_DECR;
|
|
|
|
case GS_INVERT:
|
|
|
|
return GL_INVERT;
|
2013-10-12 20:18:05 -07:00
|
|
|
}
|
2013-10-24 01:29:06 -07:00
|
|
|
|
|
|
|
return GL_KEEP;
|
2013-10-12 20:18:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline GLenum convert_gs_stencil_side(enum gs_stencil_side side)
|
|
|
|
{
|
|
|
|
switch (side) {
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_STENCIL_FRONT:
|
|
|
|
return GL_FRONT;
|
|
|
|
case GS_STENCIL_BACK:
|
|
|
|
return GL_BACK;
|
|
|
|
case GS_STENCIL_BOTH:
|
|
|
|
return GL_FRONT_AND_BACK;
|
2013-10-12 20:18:05 -07:00
|
|
|
}
|
2013-10-24 01:29:06 -07:00
|
|
|
|
|
|
|
return GL_FRONT;
|
2013-10-12 20:18:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline GLenum convert_gs_blend_type(enum gs_blend_type type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_BLEND_ZERO:
|
|
|
|
return GL_ZERO;
|
|
|
|
case GS_BLEND_ONE:
|
|
|
|
return GL_ONE;
|
|
|
|
case GS_BLEND_SRCCOLOR:
|
|
|
|
return GL_SRC_COLOR;
|
|
|
|
case GS_BLEND_INVSRCCOLOR:
|
|
|
|
return GL_ONE_MINUS_SRC_COLOR;
|
|
|
|
case GS_BLEND_SRCALPHA:
|
|
|
|
return GL_SRC_ALPHA;
|
|
|
|
case GS_BLEND_INVSRCALPHA:
|
|
|
|
return GL_ONE_MINUS_SRC_ALPHA;
|
|
|
|
case GS_BLEND_DSTCOLOR:
|
|
|
|
return GL_DST_COLOR;
|
|
|
|
case GS_BLEND_INVDSTCOLOR:
|
|
|
|
return GL_ONE_MINUS_DST_COLOR;
|
|
|
|
case GS_BLEND_DSTALPHA:
|
|
|
|
return GL_DST_ALPHA;
|
|
|
|
case GS_BLEND_INVDSTALPHA:
|
|
|
|
return GL_ONE_MINUS_DST_ALPHA;
|
|
|
|
case GS_BLEND_SRCALPHASAT:
|
|
|
|
return GL_SRC_ALPHA_SATURATE;
|
2013-10-12 20:18:05 -07:00
|
|
|
}
|
2013-10-24 01:29:06 -07:00
|
|
|
|
|
|
|
return GL_ONE;
|
2013-10-12 20:18:05 -07:00
|
|
|
}
|
|
|
|
|
2021-10-24 08:18:58 -07:00
|
|
|
static inline GLenum convert_gs_blend_op_type(enum gs_blend_op_type type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case GS_BLEND_OP_ADD:
|
|
|
|
return GL_FUNC_ADD;
|
|
|
|
case GS_BLEND_OP_SUBTRACT:
|
|
|
|
return GL_FUNC_SUBTRACT;
|
|
|
|
case GS_BLEND_OP_REVERSE_SUBTRACT:
|
|
|
|
return GL_FUNC_REVERSE_SUBTRACT;
|
|
|
|
case GS_BLEND_OP_MIN:
|
|
|
|
return GL_MIN;
|
|
|
|
case GS_BLEND_OP_MAX:
|
|
|
|
return GL_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GL_FUNC_ADD;
|
|
|
|
}
|
|
|
|
|
2014-08-07 23:42:07 -07:00
|
|
|
static inline GLenum convert_shader_type(enum gs_shader_type type)
|
2013-10-09 15:48:16 -07:00
|
|
|
{
|
|
|
|
switch (type) {
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_SHADER_VERTEX:
|
|
|
|
return GL_VERTEX_SHADER;
|
|
|
|
case GS_SHADER_PIXEL:
|
|
|
|
return GL_FRAGMENT_SHADER;
|
2013-10-09 15:48:16 -07:00
|
|
|
}
|
2013-10-24 01:29:06 -07:00
|
|
|
|
|
|
|
return GL_VERTEX_SHADER;
|
2013-10-09 15:48:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void convert_filter(enum gs_sample_filter filter,
|
2019-06-22 22:13:45 -07:00
|
|
|
GLint *min_filter, GLint *mag_filter)
|
2013-10-09 15:48:16 -07:00
|
|
|
{
|
|
|
|
switch (filter) {
|
|
|
|
case GS_FILTER_POINT:
|
|
|
|
*min_filter = GL_NEAREST_MIPMAP_NEAREST;
|
|
|
|
*mag_filter = GL_NEAREST;
|
2013-10-24 01:29:06 -07:00
|
|
|
return;
|
2013-10-09 15:48:16 -07:00
|
|
|
case GS_FILTER_LINEAR:
|
|
|
|
*min_filter = GL_LINEAR_MIPMAP_LINEAR;
|
|
|
|
*mag_filter = GL_LINEAR;
|
2013-10-24 01:29:06 -07:00
|
|
|
return;
|
2013-10-09 15:48:16 -07:00
|
|
|
case GS_FILTER_MIN_MAG_POINT_MIP_LINEAR:
|
|
|
|
*min_filter = GL_NEAREST_MIPMAP_LINEAR;
|
|
|
|
*mag_filter = GL_NEAREST;
|
2013-10-24 01:29:06 -07:00
|
|
|
return;
|
2013-10-09 15:48:16 -07:00
|
|
|
case GS_FILTER_MIN_POINT_MAG_LINEAR_MIP_POINT:
|
|
|
|
*min_filter = GL_NEAREST_MIPMAP_NEAREST;
|
|
|
|
*mag_filter = GL_LINEAR;
|
2013-10-24 01:29:06 -07:00
|
|
|
return;
|
2013-10-09 15:48:16 -07:00
|
|
|
case GS_FILTER_MIN_POINT_MAG_MIP_LINEAR:
|
|
|
|
*min_filter = GL_NEAREST_MIPMAP_LINEAR;
|
|
|
|
*mag_filter = GL_LINEAR;
|
2013-10-24 01:29:06 -07:00
|
|
|
return;
|
2013-10-09 15:48:16 -07:00
|
|
|
case GS_FILTER_MIN_LINEAR_MAG_MIP_POINT:
|
|
|
|
*min_filter = GL_LINEAR_MIPMAP_NEAREST;
|
|
|
|
*mag_filter = GL_NEAREST;
|
2013-10-24 01:29:06 -07:00
|
|
|
return;
|
2013-10-09 15:48:16 -07:00
|
|
|
case GS_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR:
|
|
|
|
*min_filter = GL_LINEAR_MIPMAP_LINEAR;
|
|
|
|
*mag_filter = GL_NEAREST;
|
2013-10-24 01:29:06 -07:00
|
|
|
return;
|
2013-10-09 15:48:16 -07:00
|
|
|
case GS_FILTER_MIN_MAG_LINEAR_MIP_POINT:
|
|
|
|
*min_filter = GL_LINEAR_MIPMAP_NEAREST;
|
|
|
|
*mag_filter = GL_LINEAR;
|
2013-10-24 01:29:06 -07:00
|
|
|
return;
|
2013-10-16 23:31:18 -07:00
|
|
|
case GS_FILTER_ANISOTROPIC:
|
|
|
|
*min_filter = GL_LINEAR_MIPMAP_LINEAR;
|
|
|
|
*mag_filter = GL_LINEAR;
|
2013-10-24 01:29:06 -07:00
|
|
|
return;
|
2013-10-09 15:48:16 -07:00
|
|
|
}
|
2013-10-24 01:29:06 -07:00
|
|
|
|
|
|
|
*min_filter = GL_NEAREST_MIPMAP_NEAREST;
|
|
|
|
*mag_filter = GL_NEAREST;
|
2013-10-09 15:48:16 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline GLint convert_address_mode(enum gs_address_mode mode)
|
|
|
|
{
|
|
|
|
switch (mode) {
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_ADDRESS_WRAP:
|
|
|
|
return GL_REPEAT;
|
|
|
|
case GS_ADDRESS_CLAMP:
|
|
|
|
return GL_CLAMP_TO_EDGE;
|
|
|
|
case GS_ADDRESS_MIRROR:
|
|
|
|
return GL_MIRRORED_REPEAT;
|
|
|
|
case GS_ADDRESS_BORDER:
|
|
|
|
return GL_CLAMP_TO_BORDER;
|
|
|
|
case GS_ADDRESS_MIRRORONCE:
|
|
|
|
return GL_MIRROR_CLAMP_EXT;
|
2013-10-09 15:48:16 -07:00
|
|
|
}
|
2013-10-24 01:29:06 -07:00
|
|
|
|
|
|
|
return GL_REPEAT;
|
2013-10-09 15:48:16 -07:00
|
|
|
}
|
|
|
|
|
2013-10-12 20:18:05 -07:00
|
|
|
static inline GLenum convert_gs_topology(enum gs_draw_mode mode)
|
|
|
|
{
|
|
|
|
switch (mode) {
|
2019-06-22 22:13:45 -07:00
|
|
|
case GS_POINTS:
|
|
|
|
return GL_POINTS;
|
|
|
|
case GS_LINES:
|
|
|
|
return GL_LINES;
|
|
|
|
case GS_LINESTRIP:
|
|
|
|
return GL_LINE_STRIP;
|
|
|
|
case GS_TRIS:
|
|
|
|
return GL_TRIANGLES;
|
|
|
|
case GS_TRISTRIP:
|
|
|
|
return GL_TRIANGLE_STRIP;
|
2013-10-12 20:18:05 -07:00
|
|
|
}
|
2013-10-24 01:29:06 -07:00
|
|
|
|
|
|
|
return GL_POINTS;
|
2013-10-12 20:18:05 -07:00
|
|
|
}
|
|
|
|
|
2013-10-10 23:03:42 -07:00
|
|
|
extern void convert_sampler_info(struct gs_sampler_state *sampler,
|
2019-06-22 22:13:45 -07:00
|
|
|
const struct gs_sampler_info *info);
|
2013-10-09 15:48:16 -07:00
|
|
|
|
2013-10-10 23:03:42 -07:00
|
|
|
struct gs_sampler_state {
|
2019-06-22 22:13:45 -07:00
|
|
|
gs_device_t *device;
|
|
|
|
volatile long ref;
|
|
|
|
|
|
|
|
GLint min_filter;
|
|
|
|
GLint mag_filter;
|
|
|
|
GLint address_u;
|
|
|
|
GLint address_v;
|
|
|
|
GLint address_w;
|
|
|
|
GLint max_anisotropy;
|
2022-01-12 06:34:00 -08:00
|
|
|
struct vec4 border_color;
|
2013-10-09 15:48:16 -07:00
|
|
|
};
|
|
|
|
|
2014-09-25 17:44:05 -07:00
|
|
|
static inline void samplerstate_addref(gs_samplerstate_t *ss)
|
2013-10-12 12:35:38 -07:00
|
|
|
{
|
2014-03-16 18:26:46 -07:00
|
|
|
os_atomic_inc_long(&ss->ref);
|
2013-10-12 12:35:38 -07:00
|
|
|
}
|
|
|
|
|
2014-09-25 17:44:05 -07:00
|
|
|
static inline void samplerstate_release(gs_samplerstate_t *ss)
|
2013-10-12 12:35:38 -07:00
|
|
|
{
|
2014-03-16 18:26:46 -07:00
|
|
|
if (os_atomic_dec_long(&ss->ref) == 0)
|
2013-10-12 12:35:38 -07:00
|
|
|
bfree(ss);
|
|
|
|
}
|
|
|
|
|
2019-07-27 13:31:07 -07:00
|
|
|
struct gs_timer {
|
|
|
|
GLuint queries[2];
|
|
|
|
};
|
|
|
|
|
2014-08-07 23:42:07 -07:00
|
|
|
struct gs_shader_param {
|
|
|
|
enum gs_shader_param_type type;
|
2013-10-09 15:48:16 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
char *name;
|
|
|
|
gs_shader_t *shader;
|
|
|
|
gs_samplerstate_t *next_sampler;
|
|
|
|
GLint texture_id;
|
|
|
|
size_t sampler_id;
|
|
|
|
int array_count;
|
2013-10-10 12:37:03 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
struct gs_texture *texture;
|
libobs: Add dormant SRGB format support
GS_RGBA, GS_BGRX, and GS_BGRA now use TYPELESS DXGI formats, so we can
alias them between UNORM and UNORM_SRGB as necessary. GS_RGBA_UNORM,
GS_BGRX_UNORM, and GS_BGRA_UNORM have been added to support straight
UNORM types, which Windows requires for sharing textures from D3D9 and
OpenGL. The D3D path aliases via views, and GL aliases via
GL_EXT_texture_sRGB_decode/GL_FRAMEBUFFER_SRGB.
A significant amount of code has changed in the D3D/GL backends, but the
concepts are simple. On the D3D side, we need separate SRVs and RTVs to
support nonlinear/linear reads and writes. On the GL side, we need to
set the proper GL parameters to emulate the same.
Add gs_enable_framebuffer_srgb/gs_framebuffer_srgb_enabled to set/get
the framebuffer as SRGB or not.
Add gs_linear_srgb_active/gs_set_linear_srgb to instruct sources that
they should render as SRGB. Legacy sources can ignore this setting
without regression.
Update obs_source_draw to use linear SRGB as needed.
Update render_filter_tex to use linear SRGB as needed.
Add gs_effect_set_texture_srgb next to gs_effect_set_texture to set
texture with SRGB view instead.
Add SRGB helpers for vec4 struct.
Create GDI-compatible textures without SRGB support. Doesn't seem to
work with SRGB formats.
2021-01-19 15:00:51 -08:00
|
|
|
bool srgb;
|
2013-10-11 20:14:26 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
DARRAY(uint8_t) cur_value;
|
|
|
|
DARRAY(uint8_t) def_value;
|
|
|
|
bool changed;
|
2013-10-11 20:14:26 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
enum attrib_type {
|
|
|
|
ATTRIB_POSITION,
|
|
|
|
ATTRIB_NORMAL,
|
|
|
|
ATTRIB_TANGENT,
|
|
|
|
ATTRIB_COLOR,
|
|
|
|
ATTRIB_TEXCOORD,
|
|
|
|
ATTRIB_TARGET
|
|
|
|
};
|
|
|
|
|
|
|
|
struct shader_attrib {
|
2019-06-22 22:13:45 -07:00
|
|
|
char *name;
|
|
|
|
size_t index;
|
|
|
|
enum attrib_type type;
|
2013-10-09 15:48:16 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct gs_shader {
|
2019-06-22 22:13:45 -07:00
|
|
|
gs_device_t *device;
|
|
|
|
enum gs_shader_type type;
|
|
|
|
GLuint obj;
|
2013-10-09 15:48:16 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
struct gs_shader_param *viewproj;
|
|
|
|
struct gs_shader_param *world;
|
2013-10-09 15:48:16 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
DARRAY(struct shader_attrib) attribs;
|
2014-09-19 04:33:49 -07:00
|
|
|
DARRAY(struct gs_shader_param) params;
|
2019-06-22 22:13:45 -07:00
|
|
|
DARRAY(gs_samplerstate_t *) samplers;
|
2014-09-19 04:33:49 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct program_param {
|
2019-06-22 22:13:45 -07:00
|
|
|
GLint obj;
|
2014-09-19 04:33:49 -07:00
|
|
|
struct gs_shader_param *param;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gs_program {
|
2019-06-22 22:13:45 -07:00
|
|
|
gs_device_t *device;
|
|
|
|
GLuint obj;
|
|
|
|
struct gs_shader *vertex_shader;
|
|
|
|
struct gs_shader *pixel_shader;
|
2014-09-19 04:33:49 -07:00
|
|
|
|
|
|
|
DARRAY(struct program_param) params;
|
2019-06-22 22:13:45 -07:00
|
|
|
DARRAY(GLint) attribs;
|
2014-09-19 04:33:49 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
struct gs_program **prev_next;
|
|
|
|
struct gs_program *next;
|
2013-10-10 23:03:42 -07:00
|
|
|
};
|
|
|
|
|
2014-09-19 04:33:49 -07:00
|
|
|
extern struct gs_program *gs_program_create(struct gs_device *device);
|
|
|
|
extern void gs_program_destroy(struct gs_program *program);
|
|
|
|
extern void program_update_params(struct gs_program *shader);
|
2013-10-16 23:31:18 -07:00
|
|
|
|
2013-10-10 23:03:42 -07:00
|
|
|
struct gs_vertex_buffer {
|
2019-06-22 22:13:45 -07:00
|
|
|
GLuint vao;
|
|
|
|
GLuint vertex_buffer;
|
|
|
|
GLuint normal_buffer;
|
|
|
|
GLuint tangent_buffer;
|
|
|
|
GLuint color_buffer;
|
|
|
|
DARRAY(GLuint) uv_buffers;
|
|
|
|
DARRAY(size_t) uv_sizes;
|
|
|
|
|
|
|
|
gs_device_t *device;
|
|
|
|
size_t num;
|
|
|
|
bool dynamic;
|
|
|
|
struct gs_vb_data *data;
|
2013-10-09 15:48:16 -07:00
|
|
|
};
|
|
|
|
|
2014-09-19 04:33:49 -07:00
|
|
|
extern bool load_vb_buffers(struct gs_program *program,
|
2019-06-22 22:13:45 -07:00
|
|
|
struct gs_vertex_buffer *vb,
|
|
|
|
struct gs_index_buffer *ib);
|
2013-10-12 12:35:38 -07:00
|
|
|
|
2013-10-11 13:00:39 -07:00
|
|
|
struct gs_index_buffer {
|
2019-06-22 22:13:45 -07:00
|
|
|
GLuint buffer;
|
|
|
|
enum gs_index_type type;
|
|
|
|
GLuint gl_type;
|
|
|
|
|
|
|
|
gs_device_t *device;
|
|
|
|
void *data;
|
|
|
|
size_t num;
|
|
|
|
size_t width;
|
|
|
|
size_t size;
|
|
|
|
bool dynamic;
|
2013-10-11 13:00:39 -07:00
|
|
|
};
|
|
|
|
|
2013-10-04 08:55:33 -07:00
|
|
|
struct gs_texture {
|
2019-06-22 22:13:45 -07:00
|
|
|
gs_device_t *device;
|
2013-10-04 08:55:33 -07:00
|
|
|
enum gs_texture_type type;
|
|
|
|
enum gs_color_format format;
|
2019-06-22 22:13:45 -07:00
|
|
|
GLenum gl_format;
|
|
|
|
GLenum gl_target;
|
|
|
|
GLenum gl_internal_format;
|
|
|
|
GLenum gl_type;
|
|
|
|
GLuint texture;
|
|
|
|
uint32_t levels;
|
|
|
|
bool is_dynamic;
|
|
|
|
bool is_render_target;
|
|
|
|
bool is_dummy;
|
|
|
|
bool gen_mipmaps;
|
|
|
|
|
|
|
|
gs_samplerstate_t *cur_sampler;
|
|
|
|
struct fbo_info *fbo;
|
2013-10-04 08:55:33 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct gs_texture_2d {
|
2019-06-22 22:13:45 -07:00
|
|
|
struct gs_texture base;
|
2013-10-04 08:55:33 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
bool gen_mipmaps;
|
|
|
|
GLuint unpack_buffer;
|
2013-10-04 08:55:33 -07:00
|
|
|
};
|
|
|
|
|
2019-12-15 11:36:24 -08:00
|
|
|
struct gs_texture_3d {
|
|
|
|
struct gs_texture base;
|
|
|
|
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
uint32_t depth;
|
|
|
|
bool gen_mipmaps;
|
|
|
|
GLuint unpack_buffer;
|
|
|
|
};
|
|
|
|
|
2013-10-04 08:55:33 -07:00
|
|
|
struct gs_texture_cube {
|
2019-06-22 22:13:45 -07:00
|
|
|
struct gs_texture base;
|
2013-10-04 08:55:33 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
uint32_t size;
|
2013-10-04 08:55:33 -07:00
|
|
|
};
|
|
|
|
|
2013-10-10 17:39:56 -07:00
|
|
|
struct gs_stage_surface {
|
2019-06-22 22:13:45 -07:00
|
|
|
gs_device_t *device;
|
2014-02-14 14:13:36 -08:00
|
|
|
|
2013-10-10 17:39:56 -07:00
|
|
|
enum gs_color_format format;
|
2019-06-22 22:13:45 -07:00
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
|
|
|
|
uint32_t bytes_per_pixel;
|
|
|
|
GLenum gl_format;
|
|
|
|
GLint gl_internal_format;
|
|
|
|
GLenum gl_type;
|
|
|
|
GLuint pack_buffer;
|
2013-10-10 17:39:56 -07:00
|
|
|
};
|
|
|
|
|
2013-10-10 12:37:03 -07:00
|
|
|
struct gs_zstencil_buffer {
|
2019-06-22 22:13:45 -07:00
|
|
|
gs_device_t *device;
|
|
|
|
GLuint buffer;
|
|
|
|
GLuint attachment;
|
|
|
|
GLenum format;
|
2013-10-10 12:37:03 -07:00
|
|
|
};
|
|
|
|
|
2013-10-02 19:50:33 -07:00
|
|
|
struct gs_swap_chain {
|
2019-06-22 22:13:45 -07:00
|
|
|
gs_device_t *device;
|
2013-10-03 06:17:43 -07:00
|
|
|
struct gl_windowinfo *wi;
|
2019-06-22 22:13:45 -07:00
|
|
|
struct gs_init_data info;
|
2013-10-02 19:50:33 -07:00
|
|
|
};
|
2013-10-02 00:59:06 -07:00
|
|
|
|
2013-10-12 16:28:10 -07:00
|
|
|
struct fbo_info {
|
2019-06-22 22:13:45 -07:00
|
|
|
GLuint fbo;
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
2013-10-12 16:28:10 -07:00
|
|
|
enum gs_color_format format;
|
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
gs_texture_t *cur_render_target;
|
|
|
|
int cur_render_side;
|
|
|
|
gs_zstencil_t *cur_zstencil_buffer;
|
2013-10-12 16:28:10 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline void fbo_info_destroy(struct fbo_info *fbo)
|
|
|
|
{
|
2013-10-16 23:31:18 -07:00
|
|
|
if (fbo) {
|
|
|
|
glDeleteFramebuffers(1, &fbo->fbo);
|
|
|
|
gl_success("glDeleteFramebuffers");
|
|
|
|
|
|
|
|
bfree(fbo);
|
|
|
|
}
|
2013-10-12 16:28:10 -07:00
|
|
|
}
|
|
|
|
|
2013-10-02 00:59:06 -07:00
|
|
|
struct gs_device {
|
2019-06-22 22:13:45 -07:00
|
|
|
struct gl_platform *plat;
|
|
|
|
enum copy_type copy_type;
|
2013-10-02 19:50:33 -07:00
|
|
|
|
2019-06-24 21:13:04 -07:00
|
|
|
GLuint empty_vao;
|
2020-12-15 01:24:30 -08:00
|
|
|
gs_samplerstate_t *raw_load_sampler;
|
2019-06-24 21:13:04 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
gs_texture_t *cur_render_target;
|
|
|
|
gs_zstencil_t *cur_zstencil_buffer;
|
|
|
|
int cur_render_side;
|
|
|
|
gs_texture_t *cur_textures[GS_MAX_TEXTURES];
|
|
|
|
gs_samplerstate_t *cur_samplers[GS_MAX_TEXTURES];
|
|
|
|
gs_vertbuffer_t *cur_vertex_buffer;
|
|
|
|
gs_indexbuffer_t *cur_index_buffer;
|
|
|
|
gs_shader_t *cur_vertex_shader;
|
|
|
|
gs_shader_t *cur_pixel_shader;
|
|
|
|
gs_swapchain_t *cur_swap;
|
|
|
|
struct gs_program *cur_program;
|
2022-02-07 23:14:26 -08:00
|
|
|
enum gs_color_space cur_color_space;
|
2014-09-19 04:33:49 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
struct gs_program *first_program;
|
2013-10-12 12:35:38 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
enum gs_cull_mode cur_cull_mode;
|
|
|
|
struct gs_rect cur_viewport;
|
2013-10-12 20:18:05 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
struct matrix4 cur_proj;
|
|
|
|
struct matrix4 cur_view;
|
|
|
|
struct matrix4 cur_viewproj;
|
2013-10-12 20:18:05 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
DARRAY(struct matrix4) proj_stack;
|
2013-10-12 20:18:05 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
struct fbo_info *cur_fbo;
|
2013-10-02 00:59:06 -07:00
|
|
|
};
|
2013-10-01 00:29:40 -07:00
|
|
|
|
2018-08-31 14:07:00 -07:00
|
|
|
extern struct fbo_info *get_fbo(gs_texture_t *tex, uint32_t width,
|
2019-06-22 22:13:45 -07:00
|
|
|
uint32_t height);
|
2014-02-09 10:37:22 -08:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
extern void gl_update(gs_device_t *device);
|
libobs-opengl: OpenGL thread-safety on Mac
Attempt to fix threading issues that cause OBS to force-crash when
compiled with latest Xcode. There are two places where the new SDK
introduces a force-crash because operations are not happening on the
main thread: when we modify the context view to switch swap chains, and
when we resize a swap chain.
Instead of using just one context for all rendering, we create an
additional context for each swap chain, set each view once on
initialization, and switch contexts only in present to blit the final
framebuffer. This is an extra copy, but it's pretty hairy to optimize
away, and it's not worth potential regressions just to speed up Mac.
For resizing, we schedule the update code to run on the main thread from
the render thread. Ideally, we wouldn't have to round trip the logic
from main thread to graphics thread and back, but I don't think we want
to hack up the interface for this, especially since OpenGL will give way
to Metal soon enough.
2019-12-25 22:25:38 -08:00
|
|
|
extern void gl_clear_context(gs_device_t *device);
|
2013-12-31 02:09:28 -08:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
extern struct gl_platform *gl_platform_create(gs_device_t *device,
|
|
|
|
uint32_t adapter);
|
|
|
|
extern void gl_platform_destroy(struct gl_platform *platform);
|
2013-10-02 19:50:33 -07:00
|
|
|
|
2014-04-24 21:10:07 -07:00
|
|
|
extern bool gl_platform_init_swapchain(struct gs_swap_chain *swap);
|
|
|
|
extern void gl_platform_cleanup_swapchain(struct gs_swap_chain *swap);
|
2014-04-12 04:33:47 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
extern struct gl_windowinfo *
|
|
|
|
gl_windowinfo_create(const struct gs_init_data *info);
|
|
|
|
extern void gl_windowinfo_destroy(struct gl_windowinfo *wi);
|
2013-10-16 23:31:18 -07:00
|
|
|
|
2019-06-22 22:13:45 -07:00
|
|
|
extern void gl_getclientsize(const struct gs_swap_chain *swap, uint32_t *width,
|
|
|
|
uint32_t *height);
|