gsdx ogl: As Intel is too cheap to provide GL_ARB_direct_state_access on theirs expensive iGPUs

Add a "slower" emulation of the extension...

Hopefully it will allow to start openGL on haswell (maybe broadwell) and later.
This commit is contained in:
Gregory Hainaut 2017-02-17 17:44:26 +01:00
parent 26993380b1
commit cdb71101a1
4 changed files with 127 additions and 25 deletions

View File

@ -168,6 +168,14 @@ PFNGLCLIPCONTROLPROC glClipControl = NUL
PFNGLTEXTUREBARRIERPROC glTextureBarrier = NULL; PFNGLTEXTUREBARRIERPROC glTextureBarrier = NULL;
PFNGLGETTEXTURESUBIMAGEPROC glGetTextureSubImage = NULL; PFNGLGETTEXTURESUBIMAGEPROC glGetTextureSubImage = NULL;
#ifdef _WIN32
PFNGLACTIVETEXTUREPROC gl_ActiveTexture = NULL;
PFNGLTEXSTORAGE2DPROC glTexStorage2D = NULL;
PFNGLGENPROGRAMPIPELINESPROC glGenProgramPipelines = NULL;
PFNGLGENSAMPLERSPROC glGenSamplers = NULL;
PFNGLGENERATEMIPMAPPROC glGenerateMipmap = NULL;
#endif
namespace ReplaceGL { namespace ReplaceGL {
void APIENTRY ScissorIndexed(GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height) void APIENTRY ScissorIndexed(GLuint index, GLint left, GLint bottom, GLsizei width, GLsizei height)
{ {
@ -185,6 +193,75 @@ namespace ReplaceGL {
} }
#ifdef _WIN32
namespace Emulate_DSA {
// Texture entry point
void APIENTRY BindTextureUnit(GLuint unit, GLuint texture) {
gl_ActiveTexture(GL_TEXTURE0 + unit);
glBindTexture(GL_TEXTURE_2D, texture);
}
void APIENTRY CreateTexture(GLenum target, GLsizei n, GLuint *textures) {
glGenTextures(1, textures);
}
void APIENTRY TextureStorage(GLuint texture, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height) {
BindTextureUnit(7, texture);
glTexStorage2D(GL_TEXTURE_2D, levels, internalformat, width, height);
}
void APIENTRY TextureSubImage(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *pixels) {
BindTextureUnit(7, texture);
glTexSubImage2D(GL_TEXTURE_2D, level, xoffset, yoffset, width, height, format, type, pixels);
}
void APIENTRY CopyTextureSubImage(GLuint texture, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
BindTextureUnit(7, texture);
glCopyTexSubImage2D(GL_TEXTURE_2D, level, xoffset, yoffset, x, y, width, height);
}
void APIENTRY GetTexureImage(GLuint texture, GLint level, GLenum format, GLenum type, GLsizei bufSize, void *pixels) {
BindTextureUnit(7, texture);
glGetTexImage(GL_TEXTURE_2D, level, format, type, pixels);
}
void APIENTRY TextureParameteri (GLuint texture, GLenum pname, GLint param) {
BindTextureUnit(7, texture);
glTexParameteri(GL_TEXTURE_2D, pname, param);
}
void APIENTRY GenerateTextureMipmap(GLuint texture) {
BindTextureUnit(7, texture);
glGenerateMipmap(GL_TEXTURE_2D);
}
// Misc entry point
// (only purpose is to have a consistent API otherwise it is useless)
void APIENTRY CreateProgramPipelines(GLsizei n, GLuint *pipelines) {
glGenProgramPipelines(n, pipelines);
}
void APIENTRY CreateSamplers(GLsizei n, GLuint *samplers) {
glGenSamplers(n, samplers);
}
// Replace function pointer to emulate DSA behavior
void Init() {
fprintf(stderr, "DSA is not supported. Expect slower performance\n");
glBindTextureUnit = BindTextureUnit;
glCreateTextures = CreateTexture;
glTextureStorage2D = TextureStorage;
glTextureSubImage2D = TextureSubImage;
glCopyTextureSubImage2D = CopyTextureSubImage;
glGetTextureImage = GetTexureImage;
glTextureParameteri = TextureParameteri;
glCreateProgramPipelines = CreateProgramPipelines;
glCreateSamplers = CreateSamplers;
}
}
#endif
namespace GLLoader { namespace GLLoader {
bool legacy_fglrx_buggy_driver = false; bool legacy_fglrx_buggy_driver = false;
@ -353,7 +430,7 @@ namespace GLLoader {
status &= status_and_override(found_GL_ARB_clear_texture,"GL_ARB_clear_texture"); status &= status_and_override(found_GL_ARB_clear_texture,"GL_ARB_clear_texture");
// GL4.5 // GL4.5
status &= status_and_override(found_GL_ARB_clip_control, "GL_ARB_clip_control", true); status &= status_and_override(found_GL_ARB_clip_control, "GL_ARB_clip_control", true);
status &= status_and_override(found_GL_ARB_direct_state_access, "GL_ARB_direct_state_access", true); status &= status_and_override(found_GL_ARB_direct_state_access, "GL_ARB_direct_state_access");
// Mandatory for the advance HW renderer effect. Unfortunately Mesa LLVMPIPE/SWR renderers doesn't support this extension. // Mandatory for the advance HW renderer effect. Unfortunately Mesa LLVMPIPE/SWR renderers doesn't support this extension.
// Rendering might be corrupted but it could be good enough for test/virtual machine. // Rendering might be corrupted but it could be good enough for test/virtual machine.
status &= status_and_override(found_GL_ARB_texture_barrier, "GL_ARB_texture_barrier"); status &= status_and_override(found_GL_ARB_texture_barrier, "GL_ARB_texture_barrier");
@ -379,6 +456,13 @@ namespace GLLoader {
glTextureBarrier = ReplaceGL::TextureBarrier; glTextureBarrier = ReplaceGL::TextureBarrier;
} }
#ifdef _WIN32
// Thanks you Intel to not provide support of basic feature on your iGPU
if (!found_GL_ARB_direct_state_access) {
Emulate_DSA::Init();
}
#endif
fprintf(stdout, "\n"); fprintf(stdout, "\n");
return status; return status;

View File

@ -346,6 +346,15 @@ extern PFNGLCLIPCONTROLPROC glClipControl;
extern PFNGLTEXTUREBARRIERPROC glTextureBarrier; extern PFNGLTEXTUREBARRIERPROC glTextureBarrier;
extern PFNGLGETTEXTURESUBIMAGEPROC glGetTextureSubImage; extern PFNGLGETTEXTURESUBIMAGEPROC glGetTextureSubImage;
#ifdef _WIN32
extern PFNGLACTIVETEXTUREPROC gl_ActiveTexture;
extern PFNGLTEXSTORAGE2DPROC glTexStorage2D;
extern PFNGLGENPROGRAMPIPELINESPROC glGenProgramPipelines;
extern PFNGLGENSAMPLERSPROC glGenSamplers;
extern PFNGLGENERATEMIPMAPPROC glGenerateMipmap;
#endif
namespace GLLoader { namespace GLLoader {
bool check_gl_version(int major, int minor); bool check_gl_version(int major, int minor);
void init_gl_function(); void init_gl_function();

View File

@ -136,33 +136,33 @@ void GSWndGL::PopulateGlFunction()
GL_EXT_LOAD(glBufferStorage); GL_EXT_LOAD(glBufferStorage);
// GL4.5 // GL4.5
GL_EXT_LOAD(glCreateTextures); GL_EXT_LOAD_OPT(glCreateTextures);
GL_EXT_LOAD(glTextureStorage2D); GL_EXT_LOAD_OPT(glTextureStorage2D);
GL_EXT_LOAD(glTextureSubImage2D); GL_EXT_LOAD_OPT(glTextureSubImage2D);
GL_EXT_LOAD(glCopyTextureSubImage2D); GL_EXT_LOAD_OPT(glCopyTextureSubImage2D);
GL_EXT_LOAD(glBindTextureUnit); GL_EXT_LOAD_OPT(glBindTextureUnit);
GL_EXT_LOAD(glGetTextureImage); GL_EXT_LOAD_OPT(glGetTextureImage);
GL_EXT_LOAD(glTextureParameteri); GL_EXT_LOAD_OPT(glTextureParameteri);
GL_EXT_LOAD(glGenerateTextureMipmap); GL_EXT_LOAD_OPT(glGenerateTextureMipmap);
GL_EXT_LOAD(glCreateFramebuffers); GL_EXT_LOAD_OPT(glCreateFramebuffers);
GL_EXT_LOAD(glClearNamedFramebufferfv); GL_EXT_LOAD_OPT(glClearNamedFramebufferfv);
GL_EXT_LOAD(glClearNamedFramebufferuiv); GL_EXT_LOAD_OPT(glClearNamedFramebufferuiv);
GL_EXT_LOAD(glClearNamedFramebufferiv); GL_EXT_LOAD_OPT(glClearNamedFramebufferiv);
GL_EXT_LOAD(glNamedFramebufferTexture); GL_EXT_LOAD_OPT(glNamedFramebufferTexture);
GL_EXT_LOAD(glNamedFramebufferDrawBuffers); GL_EXT_LOAD_OPT(glNamedFramebufferDrawBuffers);
GL_EXT_LOAD(glNamedFramebufferReadBuffer); GL_EXT_LOAD_OPT(glNamedFramebufferReadBuffer);
GL_EXT_LOAD_OPT(glNamedFramebufferParameteri); GL_EXT_LOAD_OPT(glNamedFramebufferParameteri);
GL_EXT_LOAD(glCheckNamedFramebufferStatus); GL_EXT_LOAD_OPT(glCheckNamedFramebufferStatus);
GL_EXT_LOAD(glCreateBuffers); GL_EXT_LOAD_OPT(glCreateBuffers);
GL_EXT_LOAD(glNamedBufferStorage); GL_EXT_LOAD_OPT(glNamedBufferStorage);
GL_EXT_LOAD(glNamedBufferData); GL_EXT_LOAD_OPT(glNamedBufferData);
GL_EXT_LOAD(glNamedBufferSubData); GL_EXT_LOAD_OPT(glNamedBufferSubData);
GL_EXT_LOAD(glMapNamedBuffer); GL_EXT_LOAD_OPT(glMapNamedBuffer);
GL_EXT_LOAD(glMapNamedBufferRange); GL_EXT_LOAD_OPT(glMapNamedBufferRange);
GL_EXT_LOAD(glUnmapNamedBuffer); GL_EXT_LOAD_OPT(glUnmapNamedBuffer);
GL_EXT_LOAD(glFlushMappedNamedBufferRange); GL_EXT_LOAD_OPT(glFlushMappedNamedBufferRange);
GL_EXT_LOAD(glCreateSamplers); GL_EXT_LOAD(glCreateSamplers);
GL_EXT_LOAD(glCreateProgramPipelines); GL_EXT_LOAD(glCreateProgramPipelines);
@ -170,4 +170,12 @@ void GSWndGL::PopulateGlFunction()
GL_EXT_LOAD(glClipControl); GL_EXT_LOAD(glClipControl);
GL_EXT_LOAD(glTextureBarrier); GL_EXT_LOAD(glTextureBarrier);
GL_EXT_LOAD_OPT(glGetTextureSubImage); GL_EXT_LOAD_OPT(glGetTextureSubImage);
#ifdef _WIN32
*(void**)&(gl_ActiveTexture) = GetProcAddress("glActiveTexture");
GL_EXT_LOAD(glTexStorage2D);
GL_EXT_LOAD(glGenSamplers);
GL_EXT_LOAD(glGenProgramPipelines);
GL_EXT_LOAD(glGenerateMipmap);
#endif
} }

View File

@ -329,6 +329,7 @@ void GSdxApp::Init()
m_default_configuration["osd_max_log_messages"] = "3"; m_default_configuration["osd_max_log_messages"] = "3";
m_default_configuration["override_geometry_shader"] = "-1"; m_default_configuration["override_geometry_shader"] = "-1";
m_default_configuration["override_GL_ARB_clear_texture"] = "-1"; m_default_configuration["override_GL_ARB_clear_texture"] = "-1";
m_default_configuration["override_GL_ARB_direct_state_access"] = "-1";
m_default_configuration["override_GL_ARB_draw_buffers_blend"] = "-1"; m_default_configuration["override_GL_ARB_draw_buffers_blend"] = "-1";
m_default_configuration["override_GL_ARB_get_texture_sub_image"] = "-1"; m_default_configuration["override_GL_ARB_get_texture_sub_image"] = "-1";
m_default_configuration["override_GL_ARB_gpu_shader5"] = "-1"; m_default_configuration["override_GL_ARB_gpu_shader5"] = "-1";