mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-24 14:00:03 +00:00
Merge pull request #8894 from unknownbrackets/core-profile
Clean up a few more core profile things
This commit is contained in:
commit
540e86b340
@ -15,14 +15,6 @@
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#if !defined(USING_GLES2)
|
||||
// SDL 1.2 on Apple does not have support for OpenGL 3 and hence needs
|
||||
// special treatment in the shader generator.
|
||||
#if defined(__APPLE__)
|
||||
#define FORCE_OPENGL_2_0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
|
||||
@ -116,32 +108,31 @@ bool GenerateFragmentShader(const ShaderID &id, char *buffer) {
|
||||
|
||||
WRITE(p, "precision lowp float;\n");
|
||||
} else {
|
||||
// TODO: Handle this in VersionGEThan?
|
||||
#if !defined(FORCE_OPENGL_2_0)
|
||||
if (gl_extensions.VersionGEThan(3, 3, 0)) {
|
||||
fragColor0 = "fragColor0";
|
||||
texture = "texture";
|
||||
glslES30 = true;
|
||||
bitwiseOps = true;
|
||||
texelFetch = "texelFetch";
|
||||
WRITE(p, "#version 330\n");
|
||||
} else if (gl_extensions.VersionGEThan(3, 0, 0)) {
|
||||
fragColor0 = "fragColor0";
|
||||
bitwiseOps = true;
|
||||
texelFetch = "texelFetch";
|
||||
WRITE(p, "#version 130\n");
|
||||
if (gl_extensions.EXT_gpu_shader4) {
|
||||
WRITE(p, "#extension GL_EXT_gpu_shader4 : enable\n");
|
||||
}
|
||||
} else {
|
||||
WRITE(p, "#version 110\n");
|
||||
if (gl_extensions.EXT_gpu_shader4) {
|
||||
WRITE(p, "#extension GL_EXT_gpu_shader4 : enable\n");
|
||||
if (!gl_extensions.ForceGL2 || gl_extensions.IsCoreContext) {
|
||||
if (gl_extensions.VersionGEThan(3, 3, 0)) {
|
||||
fragColor0 = "fragColor0";
|
||||
texture = "texture";
|
||||
glslES30 = true;
|
||||
bitwiseOps = true;
|
||||
texelFetch = "texelFetch2D";
|
||||
texelFetch = "texelFetch";
|
||||
WRITE(p, "#version 330\n");
|
||||
} else if (gl_extensions.VersionGEThan(3, 0, 0)) {
|
||||
fragColor0 = "fragColor0";
|
||||
bitwiseOps = true;
|
||||
texelFetch = "texelFetch";
|
||||
WRITE(p, "#version 130\n");
|
||||
if (gl_extensions.EXT_gpu_shader4) {
|
||||
WRITE(p, "#extension GL_EXT_gpu_shader4 : enable\n");
|
||||
}
|
||||
} else {
|
||||
WRITE(p, "#version 110\n");
|
||||
if (gl_extensions.EXT_gpu_shader4) {
|
||||
WRITE(p, "#extension GL_EXT_gpu_shader4 : enable\n");
|
||||
bitwiseOps = true;
|
||||
texelFetch = "texelFetch2D";
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// We remove these everywhere - GL4, GL3, Mac-forced-GL2, etc.
|
||||
WRITE(p, "#define lowp\n");
|
||||
@ -149,7 +140,7 @@ bool GenerateFragmentShader(const ShaderID &id, char *buffer) {
|
||||
WRITE(p, "#define highp\n");
|
||||
}
|
||||
|
||||
if (glslES30) {
|
||||
if (glslES30 || gl_extensions.IsCoreContext) {
|
||||
varying = "in";
|
||||
}
|
||||
|
||||
|
@ -34,12 +34,6 @@
|
||||
#include "GPU/Common/ShaderId.h"
|
||||
#include "GPU/Common/VertexDecoderCommon.h"
|
||||
|
||||
// SDL 1.2 on Apple does not have support for OpenGL 3 and hence needs
|
||||
// special treatment in the shader generator.
|
||||
#ifdef __APPLE__
|
||||
#define FORCE_OPENGL_2_0
|
||||
#endif
|
||||
|
||||
#undef WRITE
|
||||
|
||||
#define WRITE p+=sprintf
|
||||
@ -128,18 +122,16 @@ void GenerateVertexShader(const ShaderID &id, char *buffer) {
|
||||
highpFog = (gl_extensions.bugs & BUG_PVR_SHADER_PRECISION_BAD) ? true : false;
|
||||
highpTexcoord = highpFog;
|
||||
} else {
|
||||
// TODO: Handle this in VersionGEThan?
|
||||
|
||||
#if !defined(FORCE_OPENGL_2_0)
|
||||
if (gl_extensions.VersionGEThan(3, 3, 0)) {
|
||||
glslES30 = true;
|
||||
WRITE(p, "#version 330\n");
|
||||
} else if (gl_extensions.VersionGEThan(3, 0, 0)) {
|
||||
WRITE(p, "#version 130\n");
|
||||
} else {
|
||||
WRITE(p, "#version 110\n");
|
||||
if (!gl_extensions.ForceGL2 || gl_extensions.IsCoreContext) {
|
||||
if (gl_extensions.VersionGEThan(3, 3, 0)) {
|
||||
glslES30 = true;
|
||||
WRITE(p, "#version 330\n");
|
||||
} else if (gl_extensions.VersionGEThan(3, 0, 0)) {
|
||||
WRITE(p, "#version 130\n");
|
||||
} else {
|
||||
WRITE(p, "#version 110\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// We remove these everywhere - GL4, GL3, Mac-forced-GL2, etc.
|
||||
WRITE(p, "#define lowp\n");
|
||||
@ -147,7 +139,7 @@ void GenerateVertexShader(const ShaderID &id, char *buffer) {
|
||||
WRITE(p, "#define highp\n");
|
||||
}
|
||||
|
||||
if (glslES30) {
|
||||
if (glslES30 || gl_extensions.IsCoreContext) {
|
||||
attribute = "in";
|
||||
varying = "out";
|
||||
boneWeightDecl = boneWeightInDecl;
|
||||
|
@ -15,14 +15,6 @@
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#if !defined(USING_GLES2)
|
||||
// SDL 1.2 on Apple does not have support for OpenGL 3 and hence needs
|
||||
// special treatment in the shader generator.
|
||||
#if defined(__APPLE__)
|
||||
#define FORCE_OPENGL_2_0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <cstdio>
|
||||
#include <sstream>
|
||||
|
||||
@ -475,4 +467,4 @@ bool GenerateVulkanGLSLFragmentShader(const ShaderID &id, char *buffer) {
|
||||
WRITE(p, "}\n");
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -50,12 +50,6 @@ static const char *vulkan_glsl_preamble =
|
||||
|
||||
|
||||
|
||||
// SDL 1.2 on Apple does not have support for OpenGL 3 and hence needs
|
||||
// special treatment in the shader generator.
|
||||
#ifdef __APPLE__
|
||||
#define FORCE_OPENGL_2_0
|
||||
#endif
|
||||
|
||||
#undef WRITE
|
||||
|
||||
#define WRITE p+=sprintf
|
||||
|
@ -251,10 +251,17 @@ bool WindowsGLContext::Init(HINSTANCE hInst, HWND window, std::string *error_mes
|
||||
ExitProcess(1);
|
||||
}
|
||||
|
||||
// Some core profile drivers elide certain extensions from GL_EXTENSIONS/etc.
|
||||
// glewExperimental allows us to force GLEW to search for the pointers anyway.
|
||||
if (gl_extensions.IsCoreContext)
|
||||
glewExperimental = true;
|
||||
if (GLEW_OK != glewInit()) {
|
||||
*error_message = "Failed to initialize GLEW.";
|
||||
return false;
|
||||
}
|
||||
// Unfortunately, glew will generate an invalid enum error, ignore.
|
||||
if (gl_extensions.IsCoreContext)
|
||||
glGetError();
|
||||
|
||||
CheckGLExtensions();
|
||||
|
||||
|
@ -587,10 +587,17 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
|
||||
#ifndef USING_GLES2
|
||||
// Some core profile drivers elide certain extensions from GL_EXTENSIONS/etc.
|
||||
// glewExperimental allows us to force GLEW to search for the pointers anyway.
|
||||
if (gl_extensions.IsCoreContext)
|
||||
glewExperimental = true;
|
||||
if (GLEW_OK != glewInit()) {
|
||||
printf("Failed to initialize glew!\n");
|
||||
return 1;
|
||||
}
|
||||
// Unfortunately, glew will generate an invalid enum error, ignore.
|
||||
if (gl_extensions.IsCoreContext)
|
||||
glGetError();
|
||||
|
||||
if (GLEW_VERSION_2_0) {
|
||||
printf("OpenGL 2.0 or higher.\n");
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "SDL_audio.h"
|
||||
#endif
|
||||
#include "QtMain.h"
|
||||
#include "gfx_es2/gpu_features.h"
|
||||
#include "math/math_util.h"
|
||||
|
||||
#include <string.h>
|
||||
@ -349,10 +350,17 @@ bool MainUI::event(QEvent *e)
|
||||
void MainUI::initializeGL()
|
||||
{
|
||||
#ifndef USING_GLES2
|
||||
glewInit();
|
||||
// Some core profile drivers elide certain extensions from GL_EXTENSIONS/etc.
|
||||
// glewExperimental allows us to force GLEW to search for the pointers anyway.
|
||||
if (gl_extensions.IsCoreContext)
|
||||
glewExperimental = true;
|
||||
glewInit();
|
||||
// Unfortunately, glew will generate an invalid enum error, ignore.
|
||||
if (gl_extensions.IsCoreContext)
|
||||
glGetError();
|
||||
#endif
|
||||
graphicsContext = new QtDummyGraphicsContext();
|
||||
NativeInitGraphics(graphicsContext);
|
||||
graphicsContext = new QtDummyGraphicsContext();
|
||||
NativeInitGraphics(graphicsContext);
|
||||
}
|
||||
|
||||
void MainUI::paintGL()
|
||||
|
@ -32,6 +32,9 @@ GLExtensions gl_extensions;
|
||||
std::string g_all_gl_extensions;
|
||||
std::string g_all_egl_extensions;
|
||||
|
||||
static bool extensionsDone = false;
|
||||
static bool useCoreContext = false;
|
||||
|
||||
bool GLExtensions::VersionGEThan(int major, int minor, int sub) {
|
||||
if (gl_extensions.ver[0] > major)
|
||||
return true;
|
||||
@ -73,11 +76,11 @@ void ProcessGPUFeatures() {
|
||||
|
||||
void CheckGLExtensions() {
|
||||
// Make sure to only do this once. It's okay to call CheckGLExtensions from wherever.
|
||||
static bool done = false;
|
||||
if (done)
|
||||
if (extensionsDone)
|
||||
return;
|
||||
done = true;
|
||||
extensionsDone = true;
|
||||
memset(&gl_extensions, 0, sizeof(gl_extensions));
|
||||
gl_extensions.IsCoreContext = useCoreContext;
|
||||
|
||||
#ifdef USING_GLES2
|
||||
gl_extensions.IsGLES = true;
|
||||
@ -371,9 +374,30 @@ void CheckGLExtensions() {
|
||||
gl_extensions.ARB_pixel_buffer_object = strstr(extString, "GL_ARB_pixel_buffer_object") != 0;
|
||||
gl_extensions.NV_pixel_buffer_object = strstr(extString, "GL_NV_pixel_buffer_object") != 0;
|
||||
|
||||
if (!gl_extensions.IsGLES && gl_extensions.IsCoreContext) {
|
||||
// These are required, and don't need to be specified by the driver (they aren't on Apple.)
|
||||
gl_extensions.ARB_vertex_array_object = true;
|
||||
gl_extensions.ARB_framebuffer_object = true;
|
||||
}
|
||||
#ifdef __APPLE__
|
||||
if (!gl_extensions.IsGLES && !gl_extensions.IsCoreContext) {
|
||||
// Apple doesn't allow OpenGL 3.x+ in compatibility contexts.
|
||||
gl_extensions.ForceGL2 = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
ProcessGPUFeatures();
|
||||
|
||||
int error = glGetError();
|
||||
if (error)
|
||||
ELOG("GL error in init: %i", error);
|
||||
}
|
||||
|
||||
void SetGLCoreContext(bool flag) {
|
||||
if (extensionsDone)
|
||||
FLOG("SetGLCoreContext() after CheckGLExtensions()");
|
||||
|
||||
useCoreContext = flag;
|
||||
// For convenience, it'll get reset later.
|
||||
gl_extensions.IsCoreContext = useCoreContext;
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ struct GLExtensions {
|
||||
bool IsGLES;
|
||||
bool IsCoreContext;
|
||||
bool GLES3; // true if the full OpenGL ES 3.0 is supported
|
||||
bool ForceGL2;
|
||||
|
||||
// OES
|
||||
bool OES_depth24;
|
||||
@ -103,3 +104,4 @@ extern std::string g_all_gl_extensions;
|
||||
extern std::string g_all_egl_extensions;
|
||||
|
||||
void CheckGLExtensions();
|
||||
void SetGLCoreContext(bool flag);
|
||||
|
Loading…
Reference in New Issue
Block a user