libobs-opengl: Require OpenGL 3.3 instead of 3.2

There don't appear to be any GPUs that support 3.2, but not 3.3. GLSL
330 maps to HLSL Shader Model 4, so this will theoretically make shaders
programs less likely to diverge, particularly for behavior around NaNs.
This commit is contained in:
jpark37 2019-09-12 21:28:26 -07:00
parent 05888fc3aa
commit 6eca70a529
4 changed files with 43 additions and 43 deletions

View File

@ -692,7 +692,7 @@ static bool gl_shader_buildstring(struct gl_shader_parser *glsp)
return false;
}
dstr_copy(&glsp->gl_string, "#version 150\n\n");
dstr_copy(&glsp->gl_string, "#version 330\n\n");
dstr_cat(&glsp->gl_string, "const bool obs_glsl_compile = true;\n\n");
gl_write_params(glsp);
gl_write_inputs(glsp, main_func);

View File

@ -130,23 +130,15 @@ static void gl_enable_debug() {}
static bool gl_init_extensions(struct gs_device *device)
{
if (!GLAD_GL_VERSION_2_1) {
blog(LOG_ERROR, "obs-studio requires OpenGL version 2.1 or "
"higher.");
if (!GLAD_GL_VERSION_3_3) {
blog(LOG_ERROR,
"obs-studio requires OpenGL version 3.3 or higher.");
return false;
}
gl_enable_debug();
if (!GLAD_GL_VERSION_3_0 && !GLAD_GL_ARB_framebuffer_object) {
blog(LOG_ERROR, "OpenGL extension ARB_framebuffer_object "
"is required.");
return false;
}
if (GLAD_GL_VERSION_3_2 || GLAD_GL_ARB_seamless_cube_map) {
gl_enable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
}
gl_enable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
if (GLAD_GL_VERSION_4_3 || GLAD_GL_ARB_copy_image)
device->copy_type = COPY_TYPE_ARB;
@ -182,8 +174,11 @@ void convert_sampler_info(struct gs_sampler_state *sampler,
sampler->max_anisotropy = info->max_anisotropy;
max_anisotropy_max = 1;
glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &max_anisotropy_max);
gl_success("glGetIntegerv(GL_MAX_TEXTURE_ANISOTROPY_MAX)");
if (GLAD_GL_EXT_texture_filter_anisotropic) {
glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT,
&max_anisotropy_max);
gl_success("glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT)");
}
if (1 <= sampler->max_anisotropy &&
sampler->max_anisotropy <= max_anisotropy_max)
@ -475,9 +470,12 @@ 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 (!gl_tex_param_i(tex->gl_target, GL_TEXTURE_MAX_ANISOTROPY_EXT,
ss->max_anisotropy))
success = false;
if (GLAD_GL_EXT_texture_filter_anisotropic) {
if (!gl_tex_param_i(tex->gl_target,
GL_TEXTURE_MAX_ANISOTROPY_EXT,
ss->max_anisotropy))
success = false;
}
apply_swizzle(tex);

View File

@ -154,35 +154,37 @@ static inline HGLRC gl_init_basic_context(HDC hdc)
return hglrc;
}
static const int attribs[] = {
#ifdef _DEBUG
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB,
#endif
WGL_CONTEXT_PROFILE_MASK_ARB, WGL_CONTEXT_CORE_PROFILE_BIT_ARB, 0, 0};
static inline HGLRC gl_init_context(HDC hdc)
{
static const int attribs[] = {
#ifdef _DEBUG
if (GLAD_WGL_ARB_create_context) {
HGLRC hglrc = wglCreateContextAttribsARB(hdc, 0, attribs);
if (!hglrc) {
blog(LOG_ERROR,
"wglCreateContextAttribsARB failed, "
"%lu",
GetLastError());
return NULL;
}
if (!wgl_make_current(hdc, hglrc)) {
wglDeleteContext(hglrc);
return NULL;
}
return hglrc;
}
WGL_CONTEXT_FLAGS_ARB,
WGL_CONTEXT_DEBUG_BIT_ARB,
#endif
WGL_CONTEXT_PROFILE_MASK_ARB,
WGL_CONTEXT_CORE_PROFILE_BIT_ARB,
WGL_CONTEXT_MAJOR_VERSION_ARB,
3,
WGL_CONTEXT_MINOR_VERSION_ARB,
3,
0,
0};
return gl_init_basic_context(hdc);
HGLRC hglrc = wglCreateContextAttribsARB(hdc, 0, attribs);
if (!hglrc) {
blog(LOG_ERROR,
"wglCreateContextAttribsARB failed, "
"%lu",
GetLastError());
return NULL;
}
if (!wgl_make_current(hdc, hglrc)) {
wglDeleteContext(hglrc);
return NULL;
}
return hglrc;
}
static bool gl_dummy_context_init(struct dummy_context *dummy)

View File

@ -50,7 +50,7 @@ static const int ctx_attribs[] = {
GLX_CONTEXT_MAJOR_VERSION_ARB,
3,
GLX_CONTEXT_MINOR_VERSION_ARB,
2,
3,
None,
};