gsdx-ogl-wnd:

* Fix shader alpha issue. Hoppefully fix lots of glitches.
* Use glBufferSubData to upload data into the constant buffer instead of map/unmap. More fps :)
* Fix wrong api setup on EGL
* Be more portable on glsl2h


git-svn-id: http://pcsx2.googlecode.com/svn/branches/gsdx-ogl-wnd@5650 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gregory.hainaut 2013-06-07 19:16:27 +00:00
parent efcb015361
commit 65b5a376ed
8 changed files with 26 additions and 17 deletions

View File

@ -2,9 +2,10 @@
use strict; use strict;
use warnings; use warnings;
use File::Spec;
my @res = qw/convert interlace merge shadeboost tfx/; my @res = qw/convert interlace merge shadeboost tfx/;
my $path = "plugins/GSdx/res"; my $path = File::Spec->catdir("plugins", "GSdx", "res");
foreach my $r (@res) { foreach my $r (@res) {
glsl2h($path, $r); glsl2h($path, $r);
@ -14,8 +15,10 @@ sub glsl2h {
my $path = shift; my $path = shift;
my $glsl = shift; my $glsl = shift;
open(my $GLSL, "<$path/${glsl}.glsl"); my $in = File::Spec->catfile($path, "${glsl}.glsl");
open(my $H, ">$path/${glsl}.h"); my $out = File::Spec->catfile($path, "${glsl}.h");
open(my $GLSL, "<$in") or die;
open(my $H, ">$out") or die;
my $header = <<EOS; my $header = <<EOS;
/* /*

View File

@ -18,7 +18,6 @@ set(CommonFlags
-Wunused-variable -Wunused-variable
-std=c++0x -std=c++0x
-fno-strict-aliasing -fno-strict-aliasing
#-DENABLE_OGL_DEBUG # FIXME remove me when code is ready
) )
set(OptimizationFlags set(OptimizationFlags
@ -28,7 +27,7 @@ set(OptimizationFlags
# Debug - Build # Debug - Build
if(CMAKE_BUILD_TYPE STREQUAL Debug) if(CMAKE_BUILD_TYPE STREQUAL Debug)
add_definitions(${CommonFlags} -DENABLE_OGL_DEBUG -g -Wall) add_definitions(${CommonFlags} -D_DEBUG -g -Wall)
endif(CMAKE_BUILD_TYPE STREQUAL Debug) endif(CMAKE_BUILD_TYPE STREQUAL Debug)
# Devel - Build # Devel - Build

View File

@ -85,6 +85,7 @@ PFNGLUSEPROGRAMSTAGESPROC gl_UseProgramStages = NULL;
PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer = NULL; PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer = NULL;
PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer = NULL; PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer = NULL;
PFNGLTEXSTORAGE2DPROC gl_TexStorage2D = NULL; PFNGLTEXSTORAGE2DPROC gl_TexStorage2D = NULL;
PFNGLBUFFERSUBDATAPROC gl_BufferSubData = NULL;
// NO GL4.1 // NO GL4.1
PFNGLUSEPROGRAMPROC gl_UseProgram = NULL; PFNGLUSEPROGRAMPROC gl_UseProgram = NULL;
PFNGLGETSHADERINFOLOGPROC gl_GetShaderInfoLog = NULL; PFNGLGETSHADERINFOLOGPROC gl_GetShaderInfoLog = NULL;
@ -207,6 +208,7 @@ namespace GLLoader {
GL_LOADFN(gl_VertexAttribIPointer, glVertexAttribIPointer); GL_LOADFN(gl_VertexAttribIPointer, glVertexAttribIPointer);
GL_LOADFN(gl_VertexAttribPointer, glVertexAttribPointer); GL_LOADFN(gl_VertexAttribPointer, glVertexAttribPointer);
GL_LOADFN(gl_TexStorage2D, glTexStorage2D); GL_LOADFN(gl_TexStorage2D, glTexStorage2D);
GL_LOADFN(gl_BufferSubData, glBufferSubData);
// NO GL4.1 // NO GL4.1
GL_LOADFN(gl_UseProgram, glUseProgram); GL_LOADFN(gl_UseProgram, glUseProgram);
GL_LOADFN(gl_GetShaderInfoLog, glGetShaderInfoLog); GL_LOADFN(gl_GetShaderInfoLog, glGetShaderInfoLog);

View File

@ -111,6 +111,7 @@ extern PFNGLUSEPROGRAMSTAGESPROC gl_UseProgramStages;
extern PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer; extern PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer;
extern PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer; extern PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer;
extern PFNGLTEXSTORAGE2DPROC gl_TexStorage2D; extern PFNGLTEXSTORAGE2DPROC gl_TexStorage2D;
extern PFNGLBUFFERSUBDATAPROC gl_BufferSubData;
// NO GL4.1 // NO GL4.1
extern PFNGLUSEPROGRAMPROC gl_UseProgram; extern PFNGLUSEPROGRAMPROC gl_UseProgram;
extern PFNGLGETSHADERINFOLOGPROC gl_GetShaderInfoLog; extern PFNGLGETSHADERINFOLOGPROC gl_GetShaderInfoLog;

View File

@ -55,10 +55,10 @@ public:
void upload(const void* src) void upload(const void* src)
{ {
uint32 flags = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT; // glMapBufferRange allow to set various parameter but the call is
uint8* dst = (uint8*) gl_MapBufferRange(target, 0, size, flags); // synchronous whereas glBufferSubData could be asynchronous.
memcpy(dst, src, size); // TODO: investigate the extension ARB_invalidate_subdata
gl_UnmapBuffer(target); gl_BufferSubData(target, 0, size, src);
} }
~GSUniformBufferOGL() { ~GSUniformBufferOGL() {

View File

@ -103,6 +103,10 @@ bool GSWndEGL::CreateContext(int major, int minor)
void GSWndEGL::AttachContext() void GSWndEGL::AttachContext()
{ {
if (!IsContextAttached()) { if (!IsContextAttached()) {
// The setting of the API is local to a thread. This function
// can be called from 2 threads.
eglBindAPI(EGL_OPENGL_API);
//fprintf(stderr, "Attach the context\n"); //fprintf(stderr, "Attach the context\n");
eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext); eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
m_ctx_attached = true; m_ctx_attached = true;

View File

@ -526,14 +526,14 @@ vec4 sample_color(vec2 st, float q)
if((PS_FMT & ~FMT_PAL) == FMT_24) if((PS_FMT & ~FMT_PAL) == FMT_24)
{ {
// FIXME GLSL any only support bvec so try to mix it with notEqual // FIXME GLSL any only support bvec so try to mix it with notEqual
bvec3 rgb_check = notEqual( t.rgb, vec3(0.0f, 0.0f, 0.0f) ); bvec3 rgb_check = notEqual( c[i].rgb, vec3(0.0f, 0.0f, 0.0f) );
t.a = ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f; c[i].a = ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;
} }
else if((PS_FMT & ~FMT_PAL) == FMT_16) else if((PS_FMT & ~FMT_PAL) == FMT_16)
{ {
// FIXME GLSL any only support bvec so try to mix it with notEqual // FIXME GLSL any only support bvec so try to mix it with notEqual
bvec3 rgb_check = notEqual( t.rgb, vec3(0.0f, 0.0f, 0.0f) ); bvec3 rgb_check = notEqual( c[i].rgb, vec3(0.0f, 0.0f, 0.0f) );
t.a = t.a >= 0.5 ? TA.y : ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f; c[i].a = c[i].a >= 0.5 ? TA.y : ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;
} }
} }

View File

@ -554,14 +554,14 @@ static const char* tfx_glsl =
" if((PS_FMT & ~FMT_PAL) == FMT_24)\n" " if((PS_FMT & ~FMT_PAL) == FMT_24)\n"
" {\n" " {\n"
" // FIXME GLSL any only support bvec so try to mix it with notEqual\n" " // FIXME GLSL any only support bvec so try to mix it with notEqual\n"
" bvec3 rgb_check = notEqual( t.rgb, vec3(0.0f, 0.0f, 0.0f) );\n" " bvec3 rgb_check = notEqual( c[i].rgb, vec3(0.0f, 0.0f, 0.0f) );\n"
" t.a = ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;\n" " c[i].a = ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;\n"
" }\n" " }\n"
" else if((PS_FMT & ~FMT_PAL) == FMT_16)\n" " else if((PS_FMT & ~FMT_PAL) == FMT_16)\n"
" {\n" " {\n"
" // FIXME GLSL any only support bvec so try to mix it with notEqual\n" " // FIXME GLSL any only support bvec so try to mix it with notEqual\n"
" bvec3 rgb_check = notEqual( t.rgb, vec3(0.0f, 0.0f, 0.0f) );\n" " bvec3 rgb_check = notEqual( c[i].rgb, vec3(0.0f, 0.0f, 0.0f) );\n"
" t.a = t.a >= 0.5 ? TA.y : ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;\n" " c[i].a = c[i].a >= 0.5 ? TA.y : ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;\n"
" }\n" " }\n"
" }\n" " }\n"
"\n" "\n"