Skip to content

Commit

Permalink
GS: Migrate to glad
Browse files Browse the repository at this point in the history
  • Loading branch information
stenzek authored and refractionpcsx2 committed Oct 30, 2021
1 parent ca2a75d commit 5848efe
Show file tree
Hide file tree
Showing 18 changed files with 16 additions and 23,195 deletions.
5,956 changes: 0 additions & 5,956 deletions 3rdparty/GL/glcorearb.h

This file was deleted.

12,864 changes: 0 additions & 12,864 deletions 3rdparty/GL/glext.h

This file was deleted.

845 changes: 0 additions & 845 deletions 3rdparty/GL/wglext.h

This file was deleted.

1 change: 1 addition & 0 deletions pcsx2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1447,6 +1447,7 @@ endif()

target_link_libraries(PCSX2_FLAGS INTERFACE
common
glad
fmt::fmt
yaml-cpp
chdr-static
Expand Down
12 changes: 0 additions & 12 deletions pcsx2/GS/GS.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,13 @@
#endif

#include "Renderers/OpenGL/GLLoader.h"
#include "Renderers/OpenGL/PFN_GLLOADER_HPP.h"

#ifdef _WIN32

// Note use GL/glcorearb.h on the future
// Requirements:
// * Update GSWndWGL::GetProcAddress to query 1.0 and 1.1 symbols
// * define all ENABLE_GL_VERSION_1_*
#include <GL/wglext.h>

#define DIRECTORY_SEPARATOR '\\'

#else

// Note use GL/glcorearb.h on the future
// Requirements:
// * Drop GLX that still include gl.h...
// EGL/OGL status on AMD GPU pro driver is unknown
// * define all ENABLE_GL_VERSION_1_*
#include <sys/stat.h> // mkdir

#define DIRECTORY_SEPARATOR '/'
Expand Down
15 changes: 0 additions & 15 deletions pcsx2/GS/Renderers/OpenGL/GLLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,6 @@
#include "GLLoader.h"
#include "GS.h"

#ifdef __APPLE__
# undef glScissorIndexed
# undef glViewportIndexedf
PFNGLSCISSORINDEXEDPROC gs_glScissorIndexed = glScissorIndexed;
PFNGLVIEWPORTINDEXEDFPROC gs_glViewportIndexedf = glViewportIndexedf;
# define glScissorIndexed gs_glScissorIndexed
# define glViewportIndexedf gs_glViewportIndexedf
#endif
#ifdef __unix__
PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate = NULL;
#endif
PFNGLTEXTUREPAGECOMMITMENTEXTPROC glTexturePageCommitmentEXT = NULL;

#include "PFN_GLLOADER_CPP.h"

namespace GLExtension
{

Expand Down
114 changes: 1 addition & 113 deletions pcsx2/GS/Renderers/OpenGL/GLLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,124 +15,12 @@

#pragma once

#ifdef __APPLE__
#define GL_SILENCE_DEPRECATION
#include <OpenGL/gl3.h>
#else
#include <GL/gl.h>
#include <GL/glext.h>
#endif

#define GL_TEX_LEVEL_0 (0)
#define GL_TEX_LEVEL_1 (1)
#define GL_FB_DEFAULT (0)
#define GL_BUFFER_0 (0)

#ifndef GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR
#define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008
#endif

/*************************************************************
* Extra define not provided in glcorearb.h
* Currently they are included in the legacy glext.h but the plan
* is to move to core only OpenGL
************************************************************/

// Extension not in core profile. It will become irrelevant with sparse texture
#ifndef GL_TEXTURE_FREE_MEMORY_ATI
#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC
#endif
#ifndef GL_NVX_gpu_memory_info
#define GL_NVX_gpu_memory_info 1
#define GL_GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX 0x9047
#define GL_GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX 0x9048
#define GL_GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX 0x9049
#define GL_GPU_MEMORY_INFO_EVICTION_COUNT_NVX 0x904A
#define GL_GPU_MEMORY_INFO_EVICTED_MEMORY_NVX 0x904B
#endif /* GL_NVX_gpu_memory_info */

// Added in GL4.6. Code should be updated but driver support...
#ifndef GL_TEXTURE_MAX_ANISOTROPY_EXT
#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
#endif

// ********************** End of the extra header ******************* //

// #define ENABLE_GL_ARB_ES3_2_compatibility 1
// #define ENABLE_GL_ARB_bindless_texture 1
// #define ENABLE_GL_ARB_cl_event 1
// #define ENABLE_GL_ARB_compute_variable_group_size 1
// #define ENABLE_GL_ARB_debug_output 1
// #define ENABLE_GL_ARB_draw_buffers_blend 1
// #define ENABLE_GL_ARB_draw_instanced 1
// #define ENABLE_GL_ARB_geometry_shader4 1
// #define ENABLE_GL_ARB_gl_spirv 1
// #define ENABLE_GL_ARB_gpu_shader_int64 1
// #define ENABLE_GL_ARB_indirect_parameters 1
// #define ENABLE_GL_ARB_instanced_arrays 1
// #define ENABLE_GL_ARB_parallel_shader_compile 1
// #define ENABLE_GL_ARB_robustness 1
// #define ENABLE_GL_ARB_sample_locations 1
// #define ENABLE_GL_ARB_sample_shading 1
// #define ENABLE_GL_ARB_shading_language_include 1
// #define ENABLE_GL_ARB_sparse_buffer 1
#define ENABLE_GL_ARB_sparse_texture 1
// #define ENABLE_GL_ARB_texture_buffer_object 1
// #define ENABLE_GL_KHR_blend_equation_advanced 1
// #define ENABLE_GL_KHR_parallel_shader_compile 1

// Dark age of openGL. GL_10 and GL_11 are provided by opengl32.dll on windows.
// Linux is a royal mess
//
// #define ENABLE_GL_VERSION_1_0 1
// #define ENABLE_GL_VERSION_1_1 1
#ifdef _WIN32
#define ENABLE_GL_VERSION_1_2 1
#define ENABLE_GL_VERSION_1_3 1
#define ENABLE_GL_VERSION_1_4 1
#endif

#ifndef __APPLE__ // macOS provides up to GL 4.1
#define ENABLE_GL_VERSION_1_5 1
#define ENABLE_GL_VERSION_2_0 1
#define ENABLE_GL_VERSION_2_1 1
#define ENABLE_GL_VERSION_3_0 1
#define ENABLE_GL_VERSION_3_1 1
#define ENABLE_GL_VERSION_3_2 1
#define ENABLE_GL_VERSION_3_3 1
#define ENABLE_GL_VERSION_4_0 1
#define ENABLE_GL_VERSION_4_1 1
#endif
#define ENABLE_GL_VERSION_4_2 1
#define ENABLE_GL_VERSION_4_3 1
#define ENABLE_GL_VERSION_4_4 1
#define ENABLE_GL_VERSION_4_5 1
// #define ENABLE_GL_VERSION_4_6 1

// FIX compilation issue with Mesa 10
#include "glext_extra.h"

// Believe me or not, they forgot to add the interaction with DSA...
#ifndef GL_EXT_direct_state_access
typedef void(APIENTRYP PFNGLTEXTUREPAGECOMMITMENTEXTPROC)(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLboolean commit);
#endif

#ifdef __APPLE__
// Apple uses weakly-linked dylibs to provide GL symbols
// This means that it's possible for a symbol to be null, but not writable by us
extern PFNGLSCISSORINDEXEDPROC gs_glScissorIndexed;
extern PFNGLVIEWPORTINDEXEDFPROC gs_glViewportIndexedf;
# define glScissorIndexed gs_glScissorIndexed
# define glViewportIndexedf gs_glViewportIndexedf
#endif

// It should be done by ENABLE_GL_VERSION_1_4 but it conflicts with the old gl.h
#ifdef __unix__
extern PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate;
#endif
extern PFNGLTEXTUREPAGECOMMITMENTEXTPROC glTexturePageCommitmentEXT;

#include "PFN_GLLOADER_HPP.h"
#include "glad.h"

namespace GLExtension
{
Expand Down
Loading

0 comments on commit 5848efe

Please sign in to comment.