Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gl2shim for core/gles2+ contexts #1446

Closed
wants to merge 46 commits into from
Closed

gl2shim for core/gles2+ contexts #1446

wants to merge 46 commits into from

Conversation

mittorn
Copy link
Member

@mittorn mittorn commented Oct 13, 2023

Limited FFP emulation with streaming buffers for gles/core contexts
Please check on nvidia/amd/intel proprietary drivers before merging, maybe need change some feature detection/blacklisting logic

…gles context support (SLOW, still needs ffp for matrix operations)
…, wrap gles functions in gl2wrap when XASH_GLES enabled
…s generates GL Errors, but renders fine on mesa
@@ -812,8 +812,13 @@ qboolean VID_CreateWindow( int width, int height, window_mode_t window_mode )
{
if( !glw_state.initialized )
{
if( !GL_CreateContext( ))
return false;
while( !GL_CreateContext( ))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it. There is already function VID_CreateWindowWithSafeGL that iterates over safegl options.

Why there is a second loop?

@@ -1070,7 +1070,7 @@ static void GL_TextureImageRAW( gl_texture_t *tex, GLint side, GLint level, GLin
}
else if( tex->target == GL_TEXTURE_2D_MULTISAMPLE )
{
#if !defined( XASH_GLES ) && !defined( XASH_GL4ES )
#if !defined( XASH_GL_STATIC ) || (!defined( XASH_GLES ) && !defined( XASH_GL4ES ))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point for checking for XASH_GL_STATIC here? It doesn't seem to change anything for MSAA.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're updating macros, don't forget to update comments after #else and #endif

@@ -40,6 +40,9 @@ int VGL_ShimInit( void );
void VGL_ShimShutdown( void );
void VGL_ShimEndFrame( void );
#endif
#if !defined(XASH_GL_STATIC)
#include "gl2_shim/gl2_shim.h"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think #if !defined(XASH_GL_STATIC) really needed here. Including gl2shim header won't break anything.


static dllfunc_t shaderobjectsfuncs_gles[] =
{
{ "glDeleteShader" , (void **)&pglDeleteObjectARB },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use GL_CALL macro here, it's very easy to pass wrong pointer here. You can create a second macro that will include ARB postfix.


static dllfunc_t vaofuncs[] =
{
{ "glBindVertexArray" , (void **)&pglBindVertexArray },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use GL_CALL here.

// one or more functions are invalid, extension will be disabled
GL_SetExtension( r_ext, false );
// HACK: fix ARB names
char *str = Q_strstr(func->name, "ARB");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add spaces in parentheses.

GL_SetExtension( extid, true ); // required to be supported by wrapper
if(!GL_CheckExtension( "multitexture", multitexturefuncs, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 1.0) && glConfig.wrapper == GLES_WRAPPER_NONE )
#ifndef XASH_GL_STATIC
if( !GL_CheckExtension( "multitexture_es1", multitexturefuncs_es, "gl_arb_multitexture", GL_ARB_MULTITEXTURE, 1.0 ) )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just use && here instead of nested ifs?

break;
case GL_ARB_VERTEX_ARRAY_OBJECT_EXT:
if(!GL_CheckExtension( "GL_OES_vertex_array_object", vaofuncs, "gl_vertex_array_object", extid, 3.0 ))
!GL_CheckExtension( "GL_EXT_vertex_array_object", vaofuncs, "gl_vertex_array_object", extid, 3.0 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused NOT operator here.


// get our various GL strings
glConfig.vendor_string = (const char *)pglGetString( GL_VENDOR );
glConfig.renderer_string = (const char *)pglGetString( GL_RENDERER );
glConfig.version_string = (const char *)pglGetString( GL_VERSION );
glConfig.extensions_string = (const char *)pglGetString( GL_EXTENSIONS );

pglGetIntegerv(GL_MAJOR_VERSION, &major);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spaces in parentheses please.


pglGetIntegerv(GL_MAJOR_VERSION, &major);
pglGetIntegerv(GL_MINOR_VERSION, &minor);
if( !major && glConfig.version_string )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this even happen? O_o?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. GL_MAJOR_VERSION was intoduced in gl 3.0

#pragma once

// max verts in a single frame
#define GL2_MAX_VERTS 32768
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's pretty low for our frame.

net_graph for example, easily exceeds this

…ernary ops, remove singleline multiple assignments, use bitset macros
@mittorn
Copy link
Member Author

mittorn commented Oct 14, 2023 via email

@mittorn
Copy link
Member Author

mittorn commented Oct 14, 2023 via email

@mittorn
Copy link
Member Author

mittorn commented Oct 14, 2023 via email

@mittorn
Copy link
Member Author

mittorn commented Oct 14, 2023 via email

@mittorn
Copy link
Member Author

mittorn commented Oct 14, 2023 via email

@a1batross
Copy link
Member

Because it is not called when GL_CreateContext failed. It is only called when it failed create window, but does not work in case window created, but context not. It just runs engine without valid context and it crashes on bad gl function calls.

It's better to be moved out of the scope of this patchset then.

I do not want to have declaration of missing functtion present. It wont be present if gl2shim part not compiled at all (it have macro in source file), so why include this header?

It will be detected at the link time. I don't see a problem here.

gl changed function names

Yeah, we discussed this already. It's very unfortunate, so let's keep it as is then.

&& inside macro? I not sure if it would be better

I think this code is not an example of a good code. It's not very obvious at which level break statement goes. The absence of code blocks even make it so much worse, that you even made a mistake in the checks. Try to take both macro paths, the one with defined XASH_GL_STATIC and the one where it's not defined.

@mittorn
Copy link
Member Author

mittorn commented Oct 15, 2023 via email

@mittorn
Copy link
Member Author

mittorn commented Oct 15, 2023 via email

@a1batross
Copy link
Member

GitHub didn't close it automatically AGAIN.

Closing manually, merged.

@a1batross a1batross closed this Oct 16, 2023
@a1batross a1batross deleted the gl2shim-rebase branch October 16, 2023 03:48
@a1batross a1batross restored the gl2shim-rebase branch October 16, 2023 03:49
@a1batross a1batross deleted the gl2shim-rebase branch October 31, 2023 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants