@@ -423,12 +423,7 @@ static bool update_texture_region(GLenum target, GLuint object, GLint level, GLi
423423
424424#endif
425425
426- static __forceinline auto get_index_buffer_offset (const GLvoid *indices) -> GLuint
427- {
428- return g_current_context->_current_ibo != 0 ? static_cast <uint32_t >(reinterpret_cast <uintptr_t >(indices) / reshade::opengl::get_index_type_size (g_current_context->_current_index_type )) : 0 ;
429- }
430-
431- static __forceinline void update_current_primitive_topology (GLenum mode, GLenum type)
426+ static void update_current_primitive_topology (GLenum mode, GLenum type)
432427{
433428 assert (g_current_context != nullptr );
434429 g_current_context->_current_index_type = type;
@@ -455,6 +450,11 @@ static __forceinline void update_current_primitive_topology(GLenum mode, GLenum
455450 }
456451}
457452
453+ static __forceinline auto get_index_buffer_offset (const GLvoid *indices) -> GLuint
454+ {
455+ return g_current_context->_current_ibo != 0 ? static_cast <uint32_t >(reinterpret_cast <uintptr_t >(indices) / reshade::opengl::get_index_type_size (g_current_context->_current_index_type )) : 0 ;
456+ }
457+
458458#endif
459459
460460#ifdef GL_VERSION_1_0
@@ -1517,15 +1517,15 @@ void APIENTRY glBindBuffer(GLenum target, GLuint buffer)
15171517void APIENTRY glDeleteProgram (GLuint program)
15181518{
15191519#if RESHADE_ADDON
1520- if (g_current_context)
1520+ if (g_current_context && program != 0 )
15211521 {
15221522 GLint status = GL_FALSE;
15231523 gl.GetProgramiv (program, GL_LINK_STATUS, &status);
15241524
15251525 // Only invoke 'destroy_pipeline' event for programs that had a corresponding 'init_pipeline' event invoked in 'glLinkProgram'
15261526 if (GL_FALSE != status)
15271527 {
1528- reshade::invoke_addon_event<reshade::addon_event::destroy_pipeline>(g_current_context, reshade::api::pipeline { program });
1528+ reshade::invoke_addon_event<reshade::addon_event::destroy_pipeline>(g_current_context, reshade::api::pipeline { ( static_cast < uint64_t >(GL_PROGRAM) << 40 ) | program });
15291529 }
15301530 }
15311531#endif
@@ -1540,7 +1540,7 @@ void APIENTRY glLinkProgram(GLuint program)
15401540 trampoline (program);
15411541
15421542#if RESHADE_ADDON
1543- if (g_current_context)
1543+ if (g_current_context && program != 0 )
15441544 {
15451545 // Only invoke 'init_pipeline' event for programs that were successfully compiled and linked
15461546 GLint status = GL_FALSE;
@@ -1606,7 +1606,7 @@ void APIENTRY glLinkProgram(GLuint program)
16061606 subobjects.push_back ({ subobject_type, 1 , &desc });
16071607 }
16081608
1609- reshade::invoke_addon_event<reshade::addon_event::init_pipeline>(g_current_context, reshade::opengl::global_pipeline_layout, static_cast <uint32_t >(subobjects.size ()), subobjects.data (), reshade::api::pipeline { program });
1609+ reshade::invoke_addon_event<reshade::addon_event::init_pipeline>(g_current_context, reshade::opengl::global_pipeline_layout, static_cast <uint32_t >(subobjects.size ()), subobjects.data (), reshade::api::pipeline { ( static_cast < uint64_t >(GL_PROGRAM) << 40 ) | program });
16101610 }
16111611 }
16121612#endif
@@ -1695,7 +1695,7 @@ void APIENTRY glUseProgram(GLuint program)
16951695#if RESHADE_ADDON && !RESHADE_ADDON_LITE
16961696 if (g_current_context)
16971697 {
1698- reshade::invoke_addon_event<reshade::addon_event::bind_pipeline>(g_current_context, reshade::api::pipeline_stage::all_shader_stages, reshade::api::pipeline { (static_cast <uint64_t >(GL_PROGRAM) << 40 ) | program });
1698+ reshade::invoke_addon_event<reshade::addon_event::bind_pipeline>(g_current_context, reshade::api::pipeline_stage::all_shader_stages, program != 0 ? reshade::api::pipeline { (static_cast <uint64_t >(GL_PROGRAM) << 40 ) | program } : reshade::api::pipeline { });
16991699 }
17001700#endif
17011701}
@@ -4155,7 +4155,8 @@ void APIENTRY glProgramStringARB(GLenum target, GLenum format, GLsizei length, c
41554155 assert (glGetProgramivARB != nullptr );
41564156 glGetProgramivARB (target, 0x8677 /* GL_PROGRAM_BINDING_ARB */ , reinterpret_cast <GLint *>(&program));
41574157
4158- reshade::invoke_addon_event<reshade::addon_event::init_pipeline>(g_current_context, reshade::opengl::global_pipeline_layout, 1 , &subobject, reshade::api::pipeline { program });
4158+ if (program != 0 )
4159+ reshade::invoke_addon_event<reshade::addon_event::init_pipeline>(g_current_context, reshade::opengl::global_pipeline_layout, 1 , &subobject, reshade::api::pipeline { (static_cast <uint64_t >(GL_PROGRAM) << 40 ) | program });
41594160 }
41604161 else
41614162#endif
@@ -4167,7 +4168,8 @@ void APIENTRY glDeleteProgramsARB(GLsizei n, const GLuint *programs)
41674168 if (g_current_context)
41684169 {
41694170 for (GLsizei i = 0 ; i < n; ++i)
4170- reshade::invoke_addon_event<reshade::addon_event::destroy_pipeline>(g_current_context, reshade::api::pipeline { programs[i] });
4171+ if (programs[i] != 0 )
4172+ reshade::invoke_addon_event<reshade::addon_event::destroy_pipeline>(g_current_context, reshade::api::pipeline { (static_cast <uint64_t >(GL_PROGRAM) << 40 ) | programs[i] });
41714173 }
41724174#endif
41734175
0 commit comments