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

Glew to epoxy #1681

Closed
wants to merge 1 commit into from
Closed

Glew to epoxy #1681

wants to merge 1 commit into from

Conversation

sobkas
Copy link
Contributor

@sobkas sobkas commented May 25, 2024

Switch from ancient GLEW to libepoxy

@AMS21
Copy link
Contributor

AMS21 commented May 26, 2024

libepoxys last release is 2 years old so why not use the still actively developed glad library, which also supports Vulkan out of the box?

@sobkas
Copy link
Contributor Author

sobkas commented May 26, 2024

libepoxys last release is 2 years old so why not use the still actively developed glad library, which also supports Vulkan out of the box?

GLAD2 depends on generated code and this code is separated for each API.
So for each API there are files(*.c and *.h) that would be included into OpenXRay.
Epoxy needs only #include to be added.

@Xottab-DUTY
Copy link
Member

libepoxys last release is 2 years old so why not use the still actively developed glad library, which also supports Vulkan out of the box?

GLEW's last release is 3 years old :)

Though, there's a bad sign there: libepoxy doesn't have any fresh commits since the last release, while glew has.

@sobkas
Copy link
Contributor Author

sobkas commented May 26, 2024

libepoxys last release is 2 years old so why not use the still actively developed glad library, which also supports Vulkan out of the box?

GLEW's last release is 3 years old :)

Though, there's a bad sign there: libepoxy doesn't have any fresh commits since the last release, while glew has.

libepoxy is used by much more recent software, while glew usage is ancient.

Copy link
Member

@Xottab-DUTY Xottab-DUTY left a comment

Choose a reason for hiding this comment

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

Thanks!
I've left mostly code style and some other small improvement request!

Comment on lines +8 to 10
#include <epoxy/gl.h>
#include "xrEngine/XR_IOConsole.h"

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#include <epoxy/gl.h>
#include "xrEngine/XR_IOConsole.h"
#include "xrEngine/XR_IOConsole.h"
#include <epoxy/gl.h>

Comment on lines +85 to +86
mode.format = SDL_PIXELFORMAT_RGBA8888;
// Apply the pixel format to the device context
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
mode.format = SDL_PIXELFORMAT_RGBA8888;
// Apply the pixel format to the device context
mode.format = SDL_PIXELFORMAT_RGBA8888;
// Apply the pixel format to the device context

@@ -103,6 +104,7 @@ void CHW::CreateDevice(SDL_Window* hWnd)
const Uint32 flags = SDL_WINDOW_BORDERLESS | SDL_WINDOW_HIDDEN | SDL_WINDOW_OPENGL;

m_helper_window = SDL_CreateWindow("OpenXRay OpenGL helper window", 0, 0, 1, 1, flags);

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

Comment on lines +67 to +69
bool GLKHRdebugSupported;
bool GLARBtexturefloatSuppoted;
bool GLARBvertexattribbindingSupported;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
bool GLKHRdebugSupported;
bool GLARBtexturefloatSuppoted;
bool GLARBvertexattribbindingSupported;
bool DebugSupported;
bool TextureFloatSuppoted;
bool VertexAttribBindingSupported;

@@ -36,6 +36,7 @@ class glState
D3D_DEPTH_STENCIL_STATE m_pDepthStencilState;
D3D_BLEND_STATE m_pBlendState;
float m_uiMipLODBias;
bool GLEXTtexturefilteranisotropicSupported;
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 move it to HW with TextureFilterAnisotropicSupported name.
It's generally better to keep such stuff in one place, and also glState can be created on-demand during the game run – that means it would always call epoxy_has_gl_extension for each glState instance (there can be many of them) which is suboptimal.

@@ -162,14 +162,14 @@ void SetVertexDeclaration(const VertexElement* dxdecl)
});
}

void ConvertVertexDeclaration(const VertexElement* dxdecl, SDeclaration* decl)
void ConvertVertexDeclaration(const VertexElement* dxdecl, SDeclaration* decl, bool GLARBvertexattribbindingSupported)
Copy link
Member

Choose a reason for hiding this comment

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

This looks less good.
It's better to just use HW.GLARBvertexattribbindingSupported (after renaming it should be HW.VertexAttribBindingSupported) directly.

@@ -61,7 +61,7 @@ inline std::pair<char, GLuint> GLCompileShader(pcstr* buffer, size_t size, pcstr

const GLuint program = glCreateProgram();
R_ASSERT(program);
if (GLEW_VERSION_4_3)
if (epoxy_gl_version() >= 43)
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 check for HW.OpenGLVersion instead of calling external function.

Copy link
Member

Choose a reason for hiding this comment

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

Please, try to use this find module: https://github.com/WebKit/WebKit/blob/main/Source/cmake/FindEpoxy.cmake
It provides Epoxy::Epoxy CMake target which can be used.

@@ -396,6 +396,7 @@ target_include_directories(xrRender_GL
"${CMAKE_SOURCE_DIR}/Externals"
"${CMAKE_SOURCE_DIR}/Externals/gli"
"${CMAKE_SOURCE_DIR}/Externals/gli/external"
"${epoxy_INCLUDE_DIR}"
Copy link
Member

@Xottab-DUTY Xottab-DUTY May 26, 2024

Choose a reason for hiding this comment

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

Can be removed after switching to Epoxy::Epoxy (#1681 (comment)).

@@ -408,8 +409,7 @@ target_link_libraries(xrRender_GL
xrParticles
xrScriptEngine
xrImGui
OpenGL::GL
GLEW::GLEW
"${epoxy_LIBRARY}"
Copy link
Member

@Xottab-DUTY Xottab-DUTY May 26, 2024

Choose a reason for hiding this comment

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

Try to switch to Epoxy::Epoxy.

@AMS21
Copy link
Contributor

AMS21 commented May 27, 2024

libepoxys last release is 2 years old so why not use the still actively developed glad library, which also supports Vulkan out of the box?

GLEW's last release is 3 years old :)

Though, there's a bad sign there: libepoxy doesn't have any fresh commits since the last release, while glew has.

libepoxys last release is 2 years old so why not use the still actively developed glad library, which also supports Vulkan out of the box?

GLEW's last release is 3 years old :)

Though, there's a bad sign there: libepoxy doesn't have any fresh commits since the last release, while glew has.

Maybe I'm being missunderstood here I'm all for replacing the ancient GLEW library. My point was rather to maybe consider using the glad library I linked which latest release is about 1 Month old and still actively developed while also supporting all OpenGL extensions as well as Vulkan (which we might want to use in the future). Also glad directly parses the official OpenGL and Vulkan spec to generate it's glue code so even if the library is ever abandoned the parser should still be able to generate bindings for never versions of OpenGL and Vulkan (at least untill they make fundamental changes to the spec).

@Xottab-DUTY
Copy link
Member

Xottab-DUTY commented May 28, 2024

@AMS21 the @sobkas's concern is this:

GLAD2 depends on generated code and this code is separated for each API.
So for each API there are files(*.c and *.h) that would be included into OpenXRay.
Epoxy needs only #include to be added.

I also had a concern that if you select OpenGL 4.6, then you won't be able to use e.g. OpenGL 3.3 or OpenGL 2.0.
But I just checked the generated files and found that we were (or I was) wrong.

GLAD2 supports working with multiple APIs simultaneously. On it's website you just need to select maximal OpenGL version and any lower version would be included.
It also support header-only option.

@Xottab-DUTY Xottab-DUTY added Portability OpenGL External (3rd party) This issue is related to external component used by our project. and removed Infrastructure labels May 29, 2024
@Xottab-DUTY
Copy link
Member

Xottab-DUTY commented May 29, 2024

So main concern with libepoxy is that it's author hadn't been active for two years. No commits, not even PR merges, etc.
It also doesn't have simple global variables indicating if an extension is available. Honestly, they are pretty handy to use.

@Xottab-DUTY
Copy link
Member

Superseded with #1684.

@Xottab-DUTY Xottab-DUTY closed this Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
External (3rd party) This issue is related to external component used by our project. OpenGL Portability Renderer
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants