diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index 1d48c0393d..ad37c9525c 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -124,7 +124,7 @@ set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "") #------------------------------------------------------------------------------- # Set some default compiler flags #------------------------------------------------------------------------------- -set(DEFAULT_WARNINGS "-Wno-write-strings -Wno-format -Wno-unused-parameter -Wno-unused-value -Wstrict-aliasing") +set(DEFAULT_WARNINGS "-Wno-write-strings -Wno-format -Wno-unused-parameter -Wno-unused-value -Wstrict-aliasing -Wno-unused-function") set(DEFAULT_GCC_FLAG "-m32 -msse -msse2 -march=i686 -pthread ${DEFAULT_WARNINGS}") set(DEFAULT_CPP_FLAG "${DEFAULT_GCC_FLAG} -Wno-invalid-offsetof") diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index ae5d809b46..0a43a81c94 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -168,6 +168,7 @@ bool GSDeviceOGL::Create(GSWnd* wnd) const GLubyte* s; s = glGetString(GL_VERSION); if (s == NULL) return false; + fprintf(stderr, "Supported Opengl version: %s\n", s); GLuint dot = 0; while (s[dot] != '\0' && s[dot] != '.') dot++; diff --git a/plugins/zzogl-pg-cg/opengl/GSDump.cpp b/plugins/zzogl-pg-cg/opengl/GSDump.cpp index 1da9a63fd1..ea6ee23fa7 100644 --- a/plugins/zzogl-pg-cg/opengl/GSDump.cpp +++ b/plugins/zzogl-pg-cg/opengl/GSDump.cpp @@ -58,13 +58,14 @@ void GSDump::Close() } } -void GSDump::Transfer(int index, const u8* mem, size_t size) +void GSDump::Transfer(int index, const u32* mem, size_t size, u32 real_size) { if(m_gs && size > 0) { fputc(0, m_gs); fputc(index, m_gs); fwrite(&size, 4, 1, m_gs); + fwrite(&real_size, 4, 1, m_gs); fwrite(mem, size, 1, m_gs); } } diff --git a/plugins/zzogl-pg-cg/opengl/GSDump.h b/plugins/zzogl-pg-cg/opengl/GSDump.h index 68c2a5c19b..4c518c5283 100644 --- a/plugins/zzogl-pg-cg/opengl/GSDump.h +++ b/plugins/zzogl-pg-cg/opengl/GSDump.h @@ -56,7 +56,7 @@ public: void Open(const string& fn, u32 crc, const freezeData& fd, u8* regs); void Close(); void ReadFIFO(u32 size); - void Transfer(int index, const u8* mem, size_t size); + void Transfer(int index, const u32* mem, size_t size, u32 real_size); void VSync(int field, bool last, u8* regs); operator bool() {return m_gs != NULL;} }; diff --git a/plugins/zzogl-pg-cg/opengl/GSmain.cpp b/plugins/zzogl-pg-cg/opengl/GSmain.cpp index 56f4ee7653..ec0c0e8fdf 100644 --- a/plugins/zzogl-pg-cg/opengl/GSmain.cpp +++ b/plugins/zzogl-pg-cg/opengl/GSmain.cpp @@ -399,7 +399,7 @@ static bool get_snapshot_filename(char *filename, char* path, const char* extens { snapshotnr++; - sprintf(filename, "%s/snap%03ld.%s", path, snapshotnr, extension); + sprintf(filename, "%s/snap%03d.%s", path, snapshotnr, extension); bmpfile = fopen(filename, "rb"); @@ -627,6 +627,7 @@ struct Packet { u8 type, param; u32 size, addr; + u32 real_size; vector buff; }; @@ -680,18 +681,20 @@ EXPORT_C_(void) GSReplay(char* lpszCmdLine) p->param = (u8)fgetc(fp); fread(&p->size, 4, 1, fp); + fread(&p->real_size, 4, 1, fp); switch(p->param) { case 0: - p->buff.resize(0x4000); - p->addr = 0x4000 - p->size; - fread(&p->buff[p->addr], p->size, 1, fp); + p->buff.resize(0x4000/4); + //p->addr = 0x4000 - p->size; + //fread(&p->buff[p->addr], p->size, 1, fp); + fread(&p->buff[0], p->size, 1, fp); break; case 1: case 2: case 3: - p->buff.resize(p->size); + p->buff.resize(p->size/4); fread(&p->buff[0], p->size, 1, fp); break; } @@ -712,7 +715,7 @@ EXPORT_C_(void) GSReplay(char* lpszCmdLine) case 3: - p->buff.resize(0x2000); + p->buff.resize(0x2000/4); fread(&p->buff[0], 0x2000, 1, fp); @@ -741,12 +744,14 @@ EXPORT_C_(void) GSReplay(char* lpszCmdLine) { case 0: + //fprintf(stderr, "TRANSFER %d size %d\n", p->param, p->real_size); switch(p->param) { - case 0: GSgifTransfer1(&p->buff[0], p->addr); break; - case 1: GSgifTransfer2(&p->buff[0], p->size / 16); break; - case 2: GSgifTransfer3(&p->buff[0], p->size / 16); break; - case 3: GSgifTransfer(&p->buff[0], p->size / 16); break; + //case 0: GSgifTransfer1((u32*)&p->buff[0], p->addr); break; + case 0: _GSgifTransfer<0>(&p->buff[0], p->real_size); break; + case 1: GSgifTransfer2((u32*)&p->buff[0], p->real_size); break; + case 2: GSgifTransfer3((u32*)&p->buff[0], p->real_size); break; + case 3: GSgifTransfer((u32*)&p->buff[0], p->real_size); break; } break; @@ -775,8 +780,8 @@ EXPORT_C_(void) GSReplay(char* lpszCmdLine) } } unsigned long end = timeGetTime(); - fprintf(stderr, "The %d frames of the scene was render on %dms\n", frame_number, end - start); - fprintf(stderr, "A means of %fms by frame\n", (float)(end - start)/(float)frame_number); + fprintf(stderr, "The %ld frames of the scene was render on %ldms\n", frame_number, end - start); + fprintf(stderr, "A means of %fms by frame (limit 16ms/f)\n", (float)(end - start)/(float)frame_number); sleep(1); finished--; diff --git a/plugins/zzogl-pg-cg/opengl/GifTransfer.cpp b/plugins/zzogl-pg-cg/opengl/GifTransfer.cpp index f8be40629b..f55561cda0 100644 --- a/plugins/zzogl-pg-cg/opengl/GifTransfer.cpp +++ b/plugins/zzogl-pg-cg/opengl/GifTransfer.cpp @@ -76,6 +76,8 @@ template void _GSgifTransfer(const u32 *pMem, u32 size) #ifdef _DEBUG gifTransferLog(index, pMem, size); + const u32* start = pMem; + u32 size_arg = size; g_dump.Transfer(index, (const u8*)pMem, size); #endif @@ -218,6 +220,10 @@ template void _GSgifTransfer(const u32 *pMem, u32 size) } } +#ifdef _DEBUG + g_dump.Transfer(index, start, pMem - start, size_arg); +#endif + // This is the case when not all data was readed from one try: VU1 has too much data. // So we should redo reading from the start. if (index == 0) diff --git a/plugins/zzogl-pg/opengl/GSDump.cpp b/plugins/zzogl-pg/opengl/GSDump.cpp index 1da9a63fd1..ea6ee23fa7 100644 --- a/plugins/zzogl-pg/opengl/GSDump.cpp +++ b/plugins/zzogl-pg/opengl/GSDump.cpp @@ -58,13 +58,14 @@ void GSDump::Close() } } -void GSDump::Transfer(int index, const u8* mem, size_t size) +void GSDump::Transfer(int index, const u32* mem, size_t size, u32 real_size) { if(m_gs && size > 0) { fputc(0, m_gs); fputc(index, m_gs); fwrite(&size, 4, 1, m_gs); + fwrite(&real_size, 4, 1, m_gs); fwrite(mem, size, 1, m_gs); } } diff --git a/plugins/zzogl-pg/opengl/GSDump.h b/plugins/zzogl-pg/opengl/GSDump.h index 68c2a5c19b..4c518c5283 100644 --- a/plugins/zzogl-pg/opengl/GSDump.h +++ b/plugins/zzogl-pg/opengl/GSDump.h @@ -56,7 +56,7 @@ public: void Open(const string& fn, u32 crc, const freezeData& fd, u8* regs); void Close(); void ReadFIFO(u32 size); - void Transfer(int index, const u8* mem, size_t size); + void Transfer(int index, const u32* mem, size_t size, u32 real_size); void VSync(int field, bool last, u8* regs); operator bool() {return m_gs != NULL;} }; diff --git a/plugins/zzogl-pg/opengl/GSmain.cpp b/plugins/zzogl-pg/opengl/GSmain.cpp index 09390a990e..d52ebac4dc 100644 --- a/plugins/zzogl-pg/opengl/GSmain.cpp +++ b/plugins/zzogl-pg/opengl/GSmain.cpp @@ -403,7 +403,7 @@ static bool get_snapshot_filename(char *filename, char* path, const char* extens { snapshotnr++; - sprintf(filename, "%s/snap%03ld.%s", path, snapshotnr, extension); + sprintf(filename, "%s/snap%03d.%s", path, snapshotnr, extension); bmpfile = fopen(filename, "rb"); @@ -641,6 +641,7 @@ struct Packet { u8 type, param; u32 size, addr; + u32 real_size; vector buff; }; @@ -694,18 +695,20 @@ EXPORT_C_(void) GSReplay(char* lpszCmdLine) p->param = (u8)fgetc(fp); fread(&p->size, 4, 1, fp); + fread(&p->real_size, 4, 1, fp); switch(p->param) { case 0: - p->buff.resize(0x4000); - p->addr = 0x4000 - p->size; - fread(&p->buff[p->addr], p->size, 1, fp); + p->buff.resize(0x4000/4); + //p->addr = 0x4000 - p->size; + //fread(&p->buff[p->addr], p->size, 1, fp); + fread(&p->buff[0], p->size, 1, fp); break; case 1: case 2: case 3: - p->buff.resize(p->size); + p->buff.resize(p->size/4); fread(&p->buff[0], p->size, 1, fp); break; } @@ -726,7 +729,7 @@ EXPORT_C_(void) GSReplay(char* lpszCmdLine) case 3: - p->buff.resize(0x2000); + p->buff.resize(0x2000/4); fread(&p->buff[0], 0x2000, 1, fp); @@ -755,12 +758,14 @@ EXPORT_C_(void) GSReplay(char* lpszCmdLine) { case 0: + //fprintf(stderr, "TRANSFER %d size %d\n", p->param, p->real_size); switch(p->param) { - case 0: GSgifTransfer1(&p->buff[0], p->addr); break; - case 1: GSgifTransfer2(&p->buff[0], p->size / 16); break; - case 2: GSgifTransfer3(&p->buff[0], p->size / 16); break; - case 3: GSgifTransfer(&p->buff[0], p->size / 16); break; + //case 0: GSgifTransfer1((u32*)&p->buff[0], p->addr); break; + case 0: _GSgifTransfer<0>(&p->buff[0], p->real_size); break; + case 1: GSgifTransfer2((u32*)&p->buff[0], p->real_size); break; + case 2: GSgifTransfer3((u32*)&p->buff[0], p->real_size); break; + case 3: GSgifTransfer((u32*)&p->buff[0], p->real_size); break; } break; @@ -789,8 +794,8 @@ EXPORT_C_(void) GSReplay(char* lpszCmdLine) } } unsigned long end = timeGetTime(); - fprintf(stderr, "The %d frames of the scene was render on %dms\n", frame_number, end - start); - fprintf(stderr, "A means of %fms by frame\n", (float)(end - start)/(float)frame_number); + fprintf(stderr, "The %ld frames of the scene was render on %ldms\n", frame_number, end - start); + fprintf(stderr, "A means of %fms by frame (limit 16ms/f)\n", (float)(end - start)/(float)frame_number); sleep(1); finished--; diff --git a/plugins/zzogl-pg/opengl/GifTransfer.cpp b/plugins/zzogl-pg/opengl/GifTransfer.cpp index 7c42c9a48e..21beff80fd 100644 --- a/plugins/zzogl-pg/opengl/GifTransfer.cpp +++ b/plugins/zzogl-pg/opengl/GifTransfer.cpp @@ -76,6 +76,8 @@ template void _GSgifTransfer(const u32 *pMem, u32 size) #ifdef _DEBUG gifTransferLog(index, pMem, size); + const u32* start = pMem; + u32 size_arg = size; g_dump.Transfer(index, (const u8*)pMem, size); #endif @@ -222,6 +224,10 @@ template void _GSgifTransfer(const u32 *pMem, u32 size) } } +#ifdef _DEBUG + g_dump.Transfer(index, start, pMem - start, size_arg); +#endif + // This is the case when not all data was readed from one try: VU1 has too much data. // So we should redo reading from the start. if (index == 0) diff --git a/plugins/zzogl-pg/opengl/ps2hw_gl4.glsl b/plugins/zzogl-pg/opengl/ps2hw_gl4.glsl index 8b520505d3..9c12b47ec0 100644 --- a/plugins/zzogl-pg/opengl/ps2hw_gl4.glsl +++ b/plugins/zzogl-pg/opengl/ps2hw_gl4.glsl @@ -57,12 +57,6 @@ #define TEX_DECL vec4 #endif -#ifdef WRITE_DEPTH -#define DOZWRITE(x) x -#else -#define DOZWRITE(x) -#endif - // NVidia CG-data types #define half2 vec2 #define half3 vec3 @@ -602,38 +596,34 @@ half4 ps2FinalColor(half4 col) half4 ps2FinalColor(half4 col) { return col * g_fOneColor.xxxy + g_fOneColor.zzzw; - //return vec4(1.0f,0.0f,1.0f, 0.8f); } #endif + #ifdef FRAGMENT_SHADER // This is code only for FRAGMENTS (pixel shader) +#ifdef WRITE_DEPTH +void write_depth_target(vec4 z) +{ + FragData1 = z; +} +#else +void write_depth_target(vec4 z) { } +#endif + void RegularPS() { // whenever outputting depth, make sure to mult by 255/256 and 1 FragData0 = ps2FinalColor(PSin.color); - DOZWRITE(FragData1 = PSin.z;) + write_depth_target(PSin.z); } -#ifdef WRITE_DEPTH - #define DECL_TEXPS(num, bit) \ void Texture##num##bit##PS() \ { \ FragData0 = ps2FinalColor(ps2CalcShade(ps2shade##num##bit(PSin.tex), PSin.color)); \ - FragData1 = PSin.z; \ + write_depth_target(PSin.z); \ } -#else - -#define DECL_TEXPS(num, bit) \ -void Texture##num##bit##PS() \ -{ \ - FragData0 = ps2FinalColor(ps2CalcShade(ps2shade##num##bit(PSin.tex), PSin.color)); \ -} - -#endif - - #define DECL_TEXPS_(num) \ DECL_TEXPS(num, _32) \ DECL_TEXPS(num, _tex32) \ @@ -653,32 +643,18 @@ void RegularFogPS() { c.xyz = mix(g_fFogColor.xyz, PSin.color.xyz, vec3(PSin.fog)); c.w = PSin.color.w; FragData0 = ps2FinalColor(c); - DOZWRITE(FragData1 = PSin.z;) + write_depth_target(PSin.z); } -#ifdef WRITE_DEPTH - #define DECL_TEXFOGPS(num, bit) \ void TextureFog##num##bit##PS() \ { \ half4 c = ps2CalcShade(ps2shade##num##bit(PSin.tex), PSin.color); \ c.xyz = mix(g_fFogColor.xyz, c.xyz, vec3(PSin.fog)); \ FragData0 = ps2FinalColor(c); \ - FragData1 = PSin.z; \ + write_depth_target(PSin.z); \ } -#else - -#define DECL_TEXFOGPS(num, bit) \ -void TextureFog##num##bit##PS() \ -{ \ - half4 c = ps2CalcShade(ps2shade##num##bit(PSin.tex), PSin.color); \ - c.xyz = mix(g_fFogColor.xyz, c.xyz, vec3(PSin.fog)); \ - FragData0 = ps2FinalColor(c); \ -} - -#endif - #define DECL_TEXFOGPS_(num) \ DECL_TEXFOGPS(num, _32) \ DECL_TEXFOGPS(num, _tex32) \ @@ -876,70 +852,78 @@ void Convert32to16PS() { #ifdef VERTEX_SHADER -float4 OutPosition() { +void SetColor() { + VSout.color = Color; +} + +void SetTex() { +#ifdef PERSPECTIVE_CORRECT_TEX + VSout.tex.xyz = TexCoord.xyz; +#else + VSout.tex.xy = TexCoord.xy/TexCoord.z; +#endif +} + +void SetZ() { +#ifdef WRITE_DEPTH + VSout.z = SecondaryColor * g_fZBias.x + g_fZBias.y; + VSout.z.w = g_fc0.y; +#endif +} + +float SetPosition() { float4 position; position.xy = vec2(Vert.xy) * g_fPosXY.xy + g_fPosXY.zw; + // FIXME: the factor in normal mode seem bogus. They don't have same order than in log mode. Or I failed to understand the logic + //// normal mode. + // -> dot(g_fZ, SecondaryColor.zyxw)) => reconstruct a float from normalized char. The float range from 0 to 1 + // position.z = dot(g_fZ, SecondaryColor.zyxw); + //// logz mode + // -> dot(g_fZ, SecondaryColor.zyxw)) => reconstruct a float from normalized char. The float range from 0 to 2**32 + // position.z = log(g_fc0.y + dot(g_fZ, SecondaryColor.zyxw)) * g_fZNorm.x + // position.z = log(1 + Z_INT) * 0.999f / (32 * log(2.0)) = log2(1 + Z_INT) * 0.999f / 32 + // log2(...) will range from 0 to 32 position.z = (log(g_fc0.y + dot(g_fZ, SecondaryColor.zyxw)) * g_fZNorm.x + g_fZNorm.y) * g_fZMin.y + dot(g_fZ, SecondaryColor.zyxw) * g_fZMin.x ; position.w = g_fc0.y; - return position; + + gl_Position = position; + + // For fog + return position.z; +} + +void SetFog(float z) { + VSout.fog = z * g_fBilinear.w; } // just smooth shadering void RegularVS() { - float4 position = OutPosition(); - gl_Position = position; - - VSout.color = Color; - - DOZWRITE(VSout.z = SecondaryColor * g_fZBias.x + g_fZBias.y;) - DOZWRITE(VSout.z.w = g_fc0.y;) + float z = SetPosition(); + SetColor(); + SetZ(); } // diffuse texture mapping void TextureVS() { - float4 position = OutPosition(); - gl_Position = position; - - VSout.color = Color; - -#ifdef PERSPECTIVE_CORRECT_TEX - VSout.tex.xyz = TexCoord.xyz; -#else - VSout.tex.xy = TexCoord.xy/TexCoord.z; -#endif - - DOZWRITE(VSout.z = SecondaryColor * g_fZBias.x + g_fZBias.y;) - DOZWRITE(VSout.z.w = g_fc0.y;) + float z = SetPosition(); + SetColor(); + SetTex(); + SetZ(); } void RegularFogVS() { - float4 position = OutPosition(); - gl_Position = position; - - VSout.color = Color; - - VSout.fog = position.z * g_fBilinear.w; - - DOZWRITE(VSout.z = SecondaryColor * g_fZBias.x + g_fZBias.y;) - DOZWRITE(VSout.z.w = g_fc0.y;) + float z = SetPosition(); + SetColor(); + SetZ(); + SetFog(z); } void TextureFogVS() { - float4 position = OutPosition(); - gl_Position = position; - - VSout.color = Color; - -#ifdef PERSPECTIVE_CORRECT_TEX - VSout.tex.xyz = TexCoord.xyz; -#else - VSout.tex.xy = TexCoord.xy/TexCoord.z; -#endif - - VSout.fog = position.z * g_fBilinear.w; - - DOZWRITE(VSout.z = SecondaryColor * g_fZBias.x + g_fZBias.y;) - DOZWRITE(VSout.z.w = g_fc0.y;) + float z = SetPosition(); + SetColor(); + SetTex(); + SetZ(); + SetFog(z); } void BitBltVS() {