2010-04-25 00:31:27 +00:00
/*
2009-02-09 21:15:56 +00:00
* Copyright ( C ) 2007 - 2009 Gabest
* http : //www.gabest.org
*
* This Program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 2 , or ( at your option )
* any later version .
2010-04-25 00:31:27 +00:00
*
2009-02-09 21:15:56 +00:00
* This Program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
2010-04-25 00:31:27 +00:00
*
2009-02-09 21:15:56 +00:00
* You should have received a copy of the GNU General Public License
* along with GNU Make ; see the file COPYING . If not , write to
2012-09-09 18:16:11 +00:00
* the Free Software Foundation , Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 , USA USA .
2009-02-09 21:15:56 +00:00
* http : //www.gnu.org/copyleft/gpl.html
*
*/
2011-02-19 03:36:30 +00:00
# include "stdafx.h"
2009-02-09 21:15:56 +00:00
# include "GSRenderer.h"
2016-05-01 09:43:18 +00:00
# if defined(__unix__)
2013-06-16 08:43:50 +00:00
# include <X11/keysym.h>
# endif
2009-05-22 01:22:52 +00:00
2015-10-25 20:44:20 +00:00
const unsigned int s_interlace_nb = 8 ;
const unsigned int s_post_shader_nb = 5 ;
const unsigned int s_aspect_ratio_nb = 3 ;
2016-10-14 17:22:38 +00:00
const unsigned int s_mipmap_nb = 3 ;
2015-10-25 20:44:20 +00:00
2012-01-19 04:53:36 +00:00
GSRenderer : : GSRenderer ( )
2013-06-28 17:32:37 +00:00
: m_shader ( 0 )
2012-01-06 07:20:37 +00:00
, m_shift_key ( false )
, m_control_key ( false )
2015-09-11 10:19:49 +00:00
, m_texture_shuffle ( false )
2016-07-07 19:29:23 +00:00
, m_real_size ( 0 , 0 )
2017-02-22 21:02:34 +00:00
, m_wnd ( )
2013-06-28 17:32:37 +00:00
, m_dev ( NULL )
2009-05-22 01:22:52 +00:00
{
2010-12-03 03:04:55 +00:00
m_GStitleInfoBuffer [ 0 ] = 0 ;
2016-05-24 19:52:06 +00:00
m_interlace = theApp . GetConfigI ( " interlace " ) % s_interlace_nb ;
m_aspectratio = theApp . GetConfigI ( " AspectRatio " ) % s_aspect_ratio_nb ;
m_shader = theApp . GetConfigI ( " TVShader " ) % s_post_shader_nb ;
2017-05-21 20:14:34 +00:00
m_vsync = theApp . GetConfigI ( " vsync " ) ;
2016-05-24 19:52:06 +00:00
m_aa1 = theApp . GetConfigB ( " aa1 " ) ;
m_fxaa = theApp . GetConfigB ( " fxaa " ) ;
m_shaderfx = theApp . GetConfigB ( " shaderfx " ) ;
m_shadeboost = theApp . GetConfigB ( " ShadeBoost " ) ;
2009-05-22 01:22:52 +00:00
}
GSRenderer : : ~ GSRenderer ( )
{
2010-05-23 17:26:37 +00:00
/*if(m_dev)
2009-07-04 22:54:57 +00:00
{
2010-05-23 17:26:37 +00:00
m_dev - > Reset ( 1 , 1 , GSDevice : : Windowed ) ;
} */
delete m_dev ;
2009-05-22 01:22:52 +00:00
}
2009-09-17 07:40:38 +00:00
bool GSRenderer : : CreateDevice ( GSDevice * dev )
{
ASSERT ( dev ) ;
ASSERT ( ! m_dev ) ;
2009-05-22 01:22:52 +00:00
2013-01-04 11:41:51 +00:00
if ( ! dev - > Create ( m_wnd ) )
2009-05-22 01:22:52 +00:00
{
return false ;
}
2009-09-17 07:40:38 +00:00
m_dev = dev ;
2017-05-21 19:58:42 +00:00
m_dev - > SetVSync ( m_vsync ) ;
2009-05-22 01:22:52 +00:00
return true ;
}
2011-02-19 03:36:30 +00:00
void GSRenderer : : ResetDevice ( )
{
if ( m_dev ) m_dev - > Reset ( 1 , 1 ) ;
}
2009-05-22 01:22:52 +00:00
bool GSRenderer : : Merge ( int field )
{
bool en [ 2 ] ;
GSVector4i fr [ 2 ] ;
2015-08-04 01:34:46 +00:00
GSVector4i dr [ 2 ] ;
2009-05-22 01:22:52 +00:00
2016-06-25 17:27:30 +00:00
GSVector2i display_baseline = { INT_MAX , INT_MAX } ;
GSVector2i frame_baseline = { INT_MAX , INT_MAX } ;
2009-05-22 01:22:52 +00:00
for ( int i = 0 ; i < 2 ; i + + )
{
en [ i ] = IsEnabled ( i ) ;
if ( en [ i ] )
{
fr [ i ] = GetFrameRect ( i ) ;
2015-08-04 01:34:46 +00:00
dr [ i ] = GetDisplayRect ( i ) ;
2009-05-22 01:22:52 +00:00
2016-06-25 17:27:30 +00:00
display_baseline . x = min ( dr [ i ] . left , display_baseline . x ) ;
display_baseline . y = min ( dr [ i ] . top , display_baseline . y ) ;
frame_baseline . x = min ( fr [ i ] . left , frame_baseline . x ) ;
frame_baseline . y = min ( fr [ i ] . top , frame_baseline . y ) ;
2009-05-22 01:22:52 +00:00
2015-08-04 01:34:46 +00:00
//printf("[%d]: %d %d %d %d, %d %d %d %d\n", i, fr[i].x,fr[i].y,fr[i].z,fr[i].w , dr[i].x,dr[i].y,dr[i].z,dr[i].w);
2009-05-22 01:22:52 +00:00
}
}
if ( ! en [ 0 ] & & ! en [ 1 ] )
{
return false ;
}
2016-10-25 18:29:38 +00:00
GL_PUSH ( " Renderer Merge %d (0: enabled %d 0x%x, 1: enabled %d 0x%x) " , s_n , en [ 0 ] , m_regs - > DISP [ 0 ] . DISPFB . Block ( ) , en [ 1 ] , m_regs - > DISP [ 1 ] . DISPFB . Block ( ) ) ;
2015-05-15 13:12:49 +00:00
2009-05-22 01:22:52 +00:00
// try to avoid fullscreen blur, could be nice on tv but on a monitor it's like double vision, hurts my eyes (persona 4, guitar hero)
//
// NOTE: probably the technique explained in graphtip.pdf (Antialiasing by Supersampling / 4. Reading Odd/Even Scan Lines Separately with the PCRTC then Blending)
2010-04-25 00:31:27 +00:00
bool samesrc =
en [ 0 ] & & en [ 1 ] & &
m_regs - > DISP [ 0 ] . DISPFB . FBP = = m_regs - > DISP [ 1 ] . DISPFB . FBP & &
m_regs - > DISP [ 0 ] . DISPFB . FBW = = m_regs - > DISP [ 1 ] . DISPFB . FBW & &
2009-05-22 01:22:52 +00:00
m_regs - > DISP [ 0 ] . DISPFB . PSM = = m_regs - > DISP [ 1 ] . DISPFB . PSM ;
2009-11-10 13:05:56 +00:00
if ( samesrc /*&& m_regs->PMODE.SLBG == 0 && m_regs->PMODE.MMOD == 1 && m_regs->PMODE.ALP == 0x80*/ )
2009-05-22 01:22:52 +00:00
{
2016-11-24 21:03:19 +00:00
// persona 4:
//
// fr[0] = 0 0 640 448
// fr[1] = 0 1 640 448
// dr[0] = 159 50 779 498
// dr[1] = 159 50 779 497
//
// second image shifted up by 1 pixel and blended over itself
//
// god of war:
//
// fr[0] = 0 1 512 448
// fr[1] = 0 0 512 448
// dr[0] = 127 50 639 497
// dr[1] = 127 50 639 498
//
// same just the first image shifted
//
// These kinds of cases are now fixed by the more generic frame_diff code below, as the code here was too specific and has become obsolete.
// NOTE: Persona 4 and God Of War are not rare exceptions, many games have the same(or very similar) offsets.
int topDiff = fr [ 0 ] . top - fr [ 1 ] . top ;
if ( dr [ 0 ] . eq ( dr [ 1 ] ) & & ( fr [ 0 ] . eq ( fr [ 1 ] + GSVector4i ( 0 , topDiff , 0 , topDiff ) ) | | fr [ 1 ] . eq ( fr [ 0 ] + GSVector4i ( 0 , topDiff , 0 , topDiff ) ) ) )
2009-05-22 01:22:52 +00:00
{
// dq5:
//
// fr[0] = 0 1 512 445
// fr[1] = 0 0 512 444
2015-08-04 01:34:46 +00:00
// dr[0] = 127 50 639 494
// dr[1] = 127 50 639 494
2009-05-22 01:22:52 +00:00
int top = min ( fr [ 0 ] . top , fr [ 1 ] . top ) ;
int bottom = min ( fr [ 0 ] . bottom , fr [ 1 ] . bottom ) ;
fr [ 0 ] . top = fr [ 1 ] . top = top ;
fr [ 0 ] . bottom = fr [ 1 ] . bottom = bottom ;
}
}
GSVector2i fs ( 0 , 0 ) ;
GSVector2i ds ( 0 , 0 ) ;
2016-10-09 11:20:31 +00:00
GSTexture * tex [ 3 ] = { NULL , NULL , NULL } ;
int y_offset [ 3 ] = { 0 , 0 , 0 } ;
2009-05-22 01:22:52 +00:00
2016-09-27 16:59:06 +00:00
s_n + + ;
2016-10-09 12:46:55 +00:00
bool feedback_merge = m_regs - > EXTWRITE . WRITE = = 1 ;
if ( samesrc & & fr [ 0 ] . bottom = = fr [ 1 ] . bottom & & ! feedback_merge )
2009-05-22 01:22:52 +00:00
{
2016-03-19 11:37:25 +00:00
tex [ 0 ] = GetOutput ( 0 , y_offset [ 0 ] ) ;
tex [ 1 ] = tex [ 0 ] ; // saves one texture fetch
y_offset [ 1 ] = y_offset [ 0 ] ;
2009-05-22 01:22:52 +00:00
}
else
{
2016-03-19 11:37:25 +00:00
if ( en [ 0 ] ) tex [ 0 ] = GetOutput ( 0 , y_offset [ 0 ] ) ;
if ( en [ 1 ] ) tex [ 1 ] = GetOutput ( 1 , y_offset [ 1 ] ) ;
2016-10-09 12:46:55 +00:00
if ( feedback_merge ) tex [ 2 ] = GetFeedbackOutput ( ) ;
2009-05-22 01:22:52 +00:00
}
GSVector4 src [ 2 ] ;
2016-03-19 11:37:25 +00:00
GSVector4 src_hw [ 2 ] ;
2009-05-22 01:22:52 +00:00
GSVector4 dst [ 2 ] ;
for ( int i = 0 ; i < 2 ; i + + )
{
if ( ! en [ i ] | | ! tex [ i ] ) continue ;
GSVector4i r = fr [ i ] ;
2009-08-02 23:07:30 +00:00
GSVector4 scale = GSVector4 ( tex [ i ] - > GetScale ( ) ) . xyxy ( ) ;
2009-05-22 01:22:52 +00:00
src [ i ] = GSVector4 ( r ) * scale / GSVector4 ( tex [ i ] - > GetSize ( ) ) . xyxy ( ) ;
2016-03-19 11:37:25 +00:00
src_hw [ i ] = ( GSVector4 ( r ) + GSVector4 ( 0 , y_offset [ i ] , 0 , y_offset [ i ] ) ) * scale / GSVector4 ( tex [ i ] - > GetSize ( ) ) . xyxy ( ) ;
2010-04-25 00:31:27 +00:00
2016-10-13 09:25:48 +00:00
GSVector2 off ( 0 ) ;
2016-06-25 17:27:30 +00:00
GSVector2i display_diff ( dr [ i ] . left - display_baseline . x , dr [ i ] . top - display_baseline . y ) ;
GSVector2i frame_diff ( fr [ i ] . left - frame_baseline . x , fr [ i ] . top - frame_baseline . y ) ;
2010-04-25 00:31:27 +00:00
2016-04-26 21:51:01 +00:00
// Time Crisis 2/3 uses two side by side images when in split screen mode.
2016-06-16 07:52:53 +00:00
// Though ignore cases where baseline and display rectangle offsets only differ by 1 pixel, causes blurring and wrong resolution output on FFXII
2016-11-24 21:03:19 +00:00
if ( display_diff . x > 2 )
2016-06-16 07:52:53 +00:00
{
2016-06-25 17:27:30 +00:00
off . x = tex [ i ] - > GetScale ( ) . x * display_diff . x ;
}
// If the DX offset is too small then consider the status of frame memory offsets, prevents blurring on Tenchu: Fatal Shadows, Worms 3D
2016-11-24 21:03:19 +00:00
else if ( display_diff . x ! = frame_diff . x )
2016-06-25 17:27:30 +00:00
{
off . x = tex [ i ] - > GetScale ( ) . x * frame_diff . x ;
2016-06-16 07:52:53 +00:00
}
2016-04-26 21:51:01 +00:00
2016-11-24 21:03:19 +00:00
if ( display_diff . y > = 4 ) // Shouldn't this be >= 2?
2009-05-22 01:22:52 +00:00
{
2016-06-25 17:27:30 +00:00
off . y = tex [ i ] - > GetScale ( ) . y * display_diff . y ;
2009-05-22 01:22:52 +00:00
if ( m_regs - > SMODE2 . INT & & m_regs - > SMODE2 . FFMD )
{
2015-05-15 18:40:09 +00:00
off . y / = 2 ;
2009-05-22 01:22:52 +00:00
}
}
2016-11-24 21:03:19 +00:00
else if ( display_diff . y ! = frame_diff . y )
2016-06-25 17:27:30 +00:00
{
off . y = tex [ i ] - > GetScale ( ) . y * frame_diff . y ;
}
2009-05-22 01:22:52 +00:00
2015-05-15 18:40:09 +00:00
dst [ i ] = GSVector4 ( off ) . xyxy ( ) + scale * GSVector4 ( r . rsize ( ) ) ;
2009-05-22 01:22:52 +00:00
fs . x = max ( fs . x , ( int ) ( dst [ i ] . z + 0.5f ) ) ;
fs . y = max ( fs . y , ( int ) ( dst [ i ] . w + 0.5f ) ) ;
}
ds = fs ;
if ( m_regs - > SMODE2 . INT & & m_regs - > SMODE2 . FFMD )
{
ds . y * = 2 ;
}
2016-06-18 07:37:08 +00:00
m_real_size = ds ;
2009-05-22 01:22:52 +00:00
bool slbg = m_regs - > PMODE . SLBG ;
if ( tex [ 0 ] | | tex [ 1 ] )
{
2011-02-20 22:33:22 +00:00
if ( tex [ 0 ] = = tex [ 1 ] & & ! slbg & & ( src [ 0 ] = = src [ 1 ] & dst [ 0 ] = = dst [ 1 ] ) . alltrue ( ) )
{
// the two outputs are identical, skip drawing one of them (the one that is alpha blended)
tex [ 0 ] = NULL ;
}
2009-05-22 01:22:52 +00:00
GSVector4 c = GSVector4 ( ( int ) m_regs - > BGCOLOR . R , ( int ) m_regs - > BGCOLOR . G , ( int ) m_regs - > BGCOLOR . B , ( int ) m_regs - > PMODE . ALP ) / 255 ;
2016-10-09 11:20:31 +00:00
m_dev - > Merge ( tex , src_hw , dst , fs , m_regs - > PMODE , m_regs - > EXTBUF , c ) ;
2009-05-22 01:22:52 +00:00
if ( m_regs - > SMODE2 . INT & & m_interlace > 0 )
{
2016-06-25 17:27:30 +00:00
if ( m_interlace = = 7 & & m_regs - > SMODE2 . FFMD ) // Auto interlace enabled / Odd frame interlace setting
2012-04-25 08:46:51 +00:00
{
int field2 = 0 ;
int mode = 2 ;
m_dev - > Interlace ( ds , field ^ field2 , mode , tex [ 1 ] ? tex [ 1 ] - > GetScale ( ) . y : tex [ 0 ] - > GetScale ( ) . y ) ;
}
else
{
int field2 = 1 - ( ( m_interlace - 1 ) & 1 ) ;
int mode = ( m_interlace - 1 ) > > 1 ;
m_dev - > Interlace ( ds , field ^ field2 , mode , tex [ 1 ] ? tex [ 1 ] - > GetScale ( ) . y : tex [ 0 ] - > GetScale ( ) . y ) ;
}
2009-05-22 01:22:52 +00:00
}
2011-07-25 11:16:01 +00:00
2012-02-29 00:29:29 +00:00
if ( m_shadeboost )
{
m_dev - > ShadeBoost ( ) ;
}
2016-06-25 17:27:30 +00:00
if ( m_shaderfx )
2014-01-17 10:17:24 +00:00
{
m_dev - > ExternalFX ( ) ;
}
2011-07-25 11:16:01 +00:00
if ( m_fxaa )
{
m_dev - > FXAA ( ) ;
}
2009-05-22 01:22:52 +00:00
}
return true ;
}
2016-06-18 07:37:08 +00:00
GSVector2i GSRenderer : : GetInternalResolution ( )
{
return m_real_size ;
}
2017-05-21 20:14:34 +00:00
void GSRenderer : : SetVSync ( int vsync )
2009-12-01 05:59:43 +00:00
{
2017-05-21 20:14:34 +00:00
m_vsync = vsync ;
2009-12-01 05:59:43 +00:00
2011-02-19 03:36:30 +00:00
if ( m_dev ) m_dev - > SetVSync ( m_vsync ) ;
}
2009-12-01 05:59:43 +00:00
2009-05-22 01:22:52 +00:00
void GSRenderer : : VSync ( int field )
{
2011-12-22 01:48:16 +00:00
GSPerfMonAutoTimer pmat ( & m_perfmon ) ;
2009-05-22 01:22:52 +00:00
m_perfmon . Put ( GSPerfMon : : Frame ) ;
Flush ( ) ;
2016-10-25 15:10:35 +00:00
if ( s_dump & & s_n > = s_saven )
2016-10-08 14:53:44 +00:00
{
m_regs - > Dump ( root_sw + format ( " %05d_f%lld_gs_reg.txt " , s_n , m_perfmon . GetFrame ( ) ) ) ;
}
2009-07-04 15:14:04 +00:00
if ( ! m_dev - > IsLost ( true ) )
{
if ( ! Merge ( field ? 1 : 0 ) )
{
return ;
}
}
else
{
ResetDevice ( ) ;
}
2009-05-22 01:22:52 +00:00
2012-01-18 11:47:31 +00:00
m_dev - > AgePool ( ) ;
2010-04-25 00:31:27 +00:00
// osd
2009-05-22 01:22:52 +00:00
Avih (of Firefox plugin "Smoothwheel" fame ;) ) worked on bringing back that extended GSdx information we lost in the merge to the new WX Gui.
Here's his changelog:
GSdx, PCSX2: Fixed broken GS info at the title bar
* If the plugin doesn't support the API, PCSX2 will display only the image mode (progressive/interlaced field/frame), NON i18n!
* If the plugin does support the API, PCSX2 will not display the image mode, and instead display the info from the plugin
* GSdx now properly sends title info: resolution, image mode, deinterlace mode (weave - bff, etc)
* To enable the full GSdx title info as it used to work before it got broken: uncomment //#define GSTITLEINFO_API_FORCE_VERBOSE at GS.h of GSdx.
NOTE: When using an older pcsx2.exe with newer GS plugin, the title would contain duplicate image mode info. All other combos work fine.
* PCSX2 still displays the performance info, etc in the title bar.
Thanks a bunch for bringing this information back, Avih! :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4070 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-12-02 22:48:56 +00:00
if ( ( m_perfmon . GetFrame ( ) & 0x1f ) = = 0 )
2009-05-22 01:22:52 +00:00
{
m_perfmon . Update ( ) ;
double fps = 1000.0f / m_perfmon . Get ( GSPerfMon : : Frame ) ;
Avih (of Firefox plugin "Smoothwheel" fame ;) ) worked on bringing back that extended GSdx information we lost in the merge to the new WX Gui.
Here's his changelog:
GSdx, PCSX2: Fixed broken GS info at the title bar
* If the plugin doesn't support the API, PCSX2 will display only the image mode (progressive/interlaced field/frame), NON i18n!
* If the plugin does support the API, PCSX2 will not display the image mode, and instead display the info from the plugin
* GSdx now properly sends title info: resolution, image mode, deinterlace mode (weave - bff, etc)
* To enable the full GSdx title info as it used to work before it got broken: uncomment //#define GSTITLEINFO_API_FORCE_VERBOSE at GS.h of GSdx.
NOTE: When using an older pcsx2.exe with newer GS plugin, the title would contain duplicate image mode info. All other combos work fine.
* PCSX2 still displays the performance info, etc in the title bar.
Thanks a bunch for bringing this information back, Avih! :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4070 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-12-02 22:48:56 +00:00
string s ;
# ifdef GSTITLEINFO_API_FORCE_VERBOSE
2016-06-25 17:27:30 +00:00
if ( 1 ) //force verbose reply
Avih (of Firefox plugin "Smoothwheel" fame ;) ) worked on bringing back that extended GSdx information we lost in the merge to the new WX Gui.
Here's his changelog:
GSdx, PCSX2: Fixed broken GS info at the title bar
* If the plugin doesn't support the API, PCSX2 will display only the image mode (progressive/interlaced field/frame), NON i18n!
* If the plugin does support the API, PCSX2 will not display the image mode, and instead display the info from the plugin
* GSdx now properly sends title info: resolution, image mode, deinterlace mode (weave - bff, etc)
* To enable the full GSdx title info as it used to work before it got broken: uncomment //#define GSTITLEINFO_API_FORCE_VERBOSE at GS.h of GSdx.
NOTE: When using an older pcsx2.exe with newer GS plugin, the title would contain duplicate image mode info. All other combos work fine.
* PCSX2 still displays the performance info, etc in the title bar.
Thanks a bunch for bringing this information back, Avih! :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4070 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-12-02 22:48:56 +00:00
# else
2016-06-25 17:27:30 +00:00
if ( m_wnd - > IsManaged ( ) )
Avih (of Firefox plugin "Smoothwheel" fame ;) ) worked on bringing back that extended GSdx information we lost in the merge to the new WX Gui.
Here's his changelog:
GSdx, PCSX2: Fixed broken GS info at the title bar
* If the plugin doesn't support the API, PCSX2 will display only the image mode (progressive/interlaced field/frame), NON i18n!
* If the plugin does support the API, PCSX2 will not display the image mode, and instead display the info from the plugin
* GSdx now properly sends title info: resolution, image mode, deinterlace mode (weave - bff, etc)
* To enable the full GSdx title info as it used to work before it got broken: uncomment //#define GSTITLEINFO_API_FORCE_VERBOSE at GS.h of GSdx.
NOTE: When using an older pcsx2.exe with newer GS plugin, the title would contain duplicate image mode info. All other combos work fine.
* PCSX2 still displays the performance info, etc in the title bar.
Thanks a bunch for bringing this information back, Avih! :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4070 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-12-02 22:48:56 +00:00
# endif
2011-02-24 23:46:26 +00:00
{
//GSdx owns the window's title, be verbose.
2010-12-03 03:04:55 +00:00
string s2 = m_regs - > SMODE2 . INT ? ( string ( " Interlaced " ) + ( m_regs - > SMODE2 . FFMD ? " (frame) " : " (field) " ) ) : " Progressive " ;
2011-02-24 23:46:26 +00:00
Avih (of Firefox plugin "Smoothwheel" fame ;) ) worked on bringing back that extended GSdx information we lost in the merge to the new WX Gui.
Here's his changelog:
GSdx, PCSX2: Fixed broken GS info at the title bar
* If the plugin doesn't support the API, PCSX2 will display only the image mode (progressive/interlaced field/frame), NON i18n!
* If the plugin does support the API, PCSX2 will not display the image mode, and instead display the info from the plugin
* GSdx now properly sends title info: resolution, image mode, deinterlace mode (weave - bff, etc)
* To enable the full GSdx title info as it used to work before it got broken: uncomment //#define GSTITLEINFO_API_FORCE_VERBOSE at GS.h of GSdx.
NOTE: When using an older pcsx2.exe with newer GS plugin, the title would contain duplicate image mode info. All other combos work fine.
* PCSX2 still displays the performance info, etc in the title bar.
Thanks a bunch for bringing this information back, Avih! :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4070 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-12-02 22:48:56 +00:00
s = format (
2015-04-24 15:13:56 +00:00
" %lld | %d x %d | %.2f fps (%d%%) | %s - %s | %s | %d S/%d P/%d D | %d%% CPU | %.2f | %.2f " ,
2016-02-12 00:34:02 +00:00
m_perfmon . GetFrame ( ) , GetInternalResolution ( ) . x , GetInternalResolution ( ) . y , fps , ( int ) ( 100.0 * fps / GetTvRefreshRate ( ) ) ,
Avih (of Firefox plugin "Smoothwheel" fame ;) ) worked on bringing back that extended GSdx information we lost in the merge to the new WX Gui.
Here's his changelog:
GSdx, PCSX2: Fixed broken GS info at the title bar
* If the plugin doesn't support the API, PCSX2 will display only the image mode (progressive/interlaced field/frame), NON i18n!
* If the plugin does support the API, PCSX2 will not display the image mode, and instead display the info from the plugin
* GSdx now properly sends title info: resolution, image mode, deinterlace mode (weave - bff, etc)
* To enable the full GSdx title info as it used to work before it got broken: uncomment //#define GSTITLEINFO_API_FORCE_VERBOSE at GS.h of GSdx.
NOTE: When using an older pcsx2.exe with newer GS plugin, the title would contain duplicate image mode info. All other combos work fine.
* PCSX2 still displays the performance info, etc in the title bar.
Thanks a bunch for bringing this information back, Avih! :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4070 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-12-02 22:48:56 +00:00
s2 . c_str ( ) ,
2011-02-19 03:36:30 +00:00
theApp . m_gs_interlace [ m_interlace ] . name . c_str ( ) ,
theApp . m_gs_aspectratio [ m_aspectratio ] . name . c_str ( ) ,
2012-01-18 11:47:31 +00:00
( int ) m_perfmon . Get ( GSPerfMon : : SyncPoint ) ,
2012-01-06 00:17:52 +00:00
( int ) m_perfmon . Get ( GSPerfMon : : Prim ) ,
Avih (of Firefox plugin "Smoothwheel" fame ;) ) worked on bringing back that extended GSdx information we lost in the merge to the new WX Gui.
Here's his changelog:
GSdx, PCSX2: Fixed broken GS info at the title bar
* If the plugin doesn't support the API, PCSX2 will display only the image mode (progressive/interlaced field/frame), NON i18n!
* If the plugin does support the API, PCSX2 will not display the image mode, and instead display the info from the plugin
* GSdx now properly sends title info: resolution, image mode, deinterlace mode (weave - bff, etc)
* To enable the full GSdx title info as it used to work before it got broken: uncomment //#define GSTITLEINFO_API_FORCE_VERBOSE at GS.h of GSdx.
NOTE: When using an older pcsx2.exe with newer GS plugin, the title would contain duplicate image mode info. All other combos work fine.
* PCSX2 still displays the performance info, etc in the title bar.
Thanks a bunch for bringing this information back, Avih! :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4070 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-12-02 22:48:56 +00:00
( int ) m_perfmon . Get ( GSPerfMon : : Draw ) ,
m_perfmon . CPU ( ) ,
m_perfmon . Get ( GSPerfMon : : Swizzle ) / 1024 ,
m_perfmon . Get ( GSPerfMon : : Unswizzle ) / 1024
) ;
double fillrate = m_perfmon . Get ( GSPerfMon : : Fillrate ) ;
if ( fillrate > 0 )
{
s + = format ( " | %.2f mpps " , fps * fillrate / ( 1024 * 1024 ) ) ;
2012-01-08 21:02:42 +00:00
int sum = 0 ;
for ( int i = 0 ; i < 16 ; i + + )
{
sum + = m_perfmon . CPU ( GSPerfMon : : WorkerDraw0 + i ) ;
}
s + = format ( " | %d%% CPU " , sum ) ;
}
Avih (of Firefox plugin "Smoothwheel" fame ;) ) worked on bringing back that extended GSdx information we lost in the merge to the new WX Gui.
Here's his changelog:
GSdx, PCSX2: Fixed broken GS info at the title bar
* If the plugin doesn't support the API, PCSX2 will display only the image mode (progressive/interlaced field/frame), NON i18n!
* If the plugin does support the API, PCSX2 will not display the image mode, and instead display the info from the plugin
* GSdx now properly sends title info: resolution, image mode, deinterlace mode (weave - bff, etc)
* To enable the full GSdx title info as it used to work before it got broken: uncomment //#define GSTITLEINFO_API_FORCE_VERBOSE at GS.h of GSdx.
NOTE: When using an older pcsx2.exe with newer GS plugin, the title would contain duplicate image mode info. All other combos work fine.
* PCSX2 still displays the performance info, etc in the title bar.
Thanks a bunch for bringing this information back, Avih! :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4070 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-12-02 22:48:56 +00:00
}
else
2010-12-03 03:04:55 +00:00
{
2011-02-19 03:36:30 +00:00
// Satisfy PCSX2's request for title info: minimal verbosity due to more external title text
2009-05-22 01:22:52 +00:00
2016-02-12 00:34:02 +00:00
s = format ( " %dx%d | %s " , GetInternalResolution ( ) . x , GetInternalResolution ( ) . y , theApp . m_gs_interlace [ m_interlace ] . name . c_str ( ) ) ;
2011-02-19 03:36:30 +00:00
}
Avih (of Firefox plugin "Smoothwheel" fame ;) ) worked on bringing back that extended GSdx information we lost in the merge to the new WX Gui.
Here's his changelog:
GSdx, PCSX2: Fixed broken GS info at the title bar
* If the plugin doesn't support the API, PCSX2 will display only the image mode (progressive/interlaced field/frame), NON i18n!
* If the plugin does support the API, PCSX2 will not display the image mode, and instead display the info from the plugin
* GSdx now properly sends title info: resolution, image mode, deinterlace mode (weave - bff, etc)
* To enable the full GSdx title info as it used to work before it got broken: uncomment //#define GSTITLEINFO_API_FORCE_VERBOSE at GS.h of GSdx.
NOTE: When using an older pcsx2.exe with newer GS plugin, the title would contain duplicate image mode info. All other combos work fine.
* PCSX2 still displays the performance info, etc in the title bar.
Thanks a bunch for bringing this information back, Avih! :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4070 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-12-02 22:48:56 +00:00
2009-05-22 01:22:52 +00:00
if ( m_capture . IsCapturing ( ) )
{
2009-06-03 12:09:04 +00:00
s + = " | Recording... " ;
2009-05-22 01:22:52 +00:00
}
2013-01-04 11:41:51 +00:00
if ( m_wnd - > IsManaged ( ) )
Avih (of Firefox plugin "Smoothwheel" fame ;) ) worked on bringing back that extended GSdx information we lost in the merge to the new WX Gui.
Here's his changelog:
GSdx, PCSX2: Fixed broken GS info at the title bar
* If the plugin doesn't support the API, PCSX2 will display only the image mode (progressive/interlaced field/frame), NON i18n!
* If the plugin does support the API, PCSX2 will not display the image mode, and instead display the info from the plugin
* GSdx now properly sends title info: resolution, image mode, deinterlace mode (weave - bff, etc)
* To enable the full GSdx title info as it used to work before it got broken: uncomment //#define GSTITLEINFO_API_FORCE_VERBOSE at GS.h of GSdx.
NOTE: When using an older pcsx2.exe with newer GS plugin, the title would contain duplicate image mode info. All other combos work fine.
* PCSX2 still displays the performance info, etc in the title bar.
Thanks a bunch for bringing this information back, Avih! :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4070 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-12-02 22:48:56 +00:00
{
2013-01-04 11:41:51 +00:00
m_wnd - > SetWindowText ( s . c_str ( ) ) ;
Avih (of Firefox plugin "Smoothwheel" fame ;) ) worked on bringing back that extended GSdx information we lost in the merge to the new WX Gui.
Here's his changelog:
GSdx, PCSX2: Fixed broken GS info at the title bar
* If the plugin doesn't support the API, PCSX2 will display only the image mode (progressive/interlaced field/frame), NON i18n!
* If the plugin does support the API, PCSX2 will not display the image mode, and instead display the info from the plugin
* GSdx now properly sends title info: resolution, image mode, deinterlace mode (weave - bff, etc)
* To enable the full GSdx title info as it used to work before it got broken: uncomment //#define GSTITLEINFO_API_FORCE_VERBOSE at GS.h of GSdx.
NOTE: When using an older pcsx2.exe with newer GS plugin, the title would contain duplicate image mode info. All other combos work fine.
* PCSX2 still displays the performance info, etc in the title bar.
Thanks a bunch for bringing this information back, Avih! :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4070 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-12-02 22:48:56 +00:00
}
else
{
2010-12-03 03:04:55 +00:00
// note: do not use TryEnterCriticalSection. It is unnecessary code complication in
// an area that absolutely does not matter (even if it were 100 times slower, it wouldn't
// be noticeable). Besides, these locks are extremely short -- overhead of conditional
// is way more expensive than just waiting for the CriticalSection in 1 of 10,000,000 tries. --air
2015-03-03 17:29:21 +00:00
std : : lock_guard < std : : mutex > lock ( m_pGSsetTitle_Crit ) ;
Avih (of Firefox plugin "Smoothwheel" fame ;) ) worked on bringing back that extended GSdx information we lost in the merge to the new WX Gui.
Here's his changelog:
GSdx, PCSX2: Fixed broken GS info at the title bar
* If the plugin doesn't support the API, PCSX2 will display only the image mode (progressive/interlaced field/frame), NON i18n!
* If the plugin does support the API, PCSX2 will not display the image mode, and instead display the info from the plugin
* GSdx now properly sends title info: resolution, image mode, deinterlace mode (weave - bff, etc)
* To enable the full GSdx title info as it used to work before it got broken: uncomment //#define GSTITLEINFO_API_FORCE_VERBOSE at GS.h of GSdx.
NOTE: When using an older pcsx2.exe with newer GS plugin, the title would contain duplicate image mode info. All other combos work fine.
* PCSX2 still displays the performance info, etc in the title bar.
Thanks a bunch for bringing this information back, Avih! :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4070 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-12-02 22:48:56 +00:00
2011-02-07 01:59:05 +00:00
strncpy ( m_GStitleInfoBuffer , s . c_str ( ) , countof ( m_GStitleInfoBuffer ) - 1 ) ;
Avih (of Firefox plugin "Smoothwheel" fame ;) ) worked on bringing back that extended GSdx information we lost in the merge to the new WX Gui.
Here's his changelog:
GSdx, PCSX2: Fixed broken GS info at the title bar
* If the plugin doesn't support the API, PCSX2 will display only the image mode (progressive/interlaced field/frame), NON i18n!
* If the plugin does support the API, PCSX2 will not display the image mode, and instead display the info from the plugin
* GSdx now properly sends title info: resolution, image mode, deinterlace mode (weave - bff, etc)
* To enable the full GSdx title info as it used to work before it got broken: uncomment //#define GSTITLEINFO_API_FORCE_VERBOSE at GS.h of GSdx.
NOTE: When using an older pcsx2.exe with newer GS plugin, the title would contain duplicate image mode info. All other combos work fine.
* PCSX2 still displays the performance info, etc in the title bar.
Thanks a bunch for bringing this information back, Avih! :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4070 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-12-02 22:48:56 +00:00
2011-02-19 03:36:30 +00:00
m_GStitleInfoBuffer [ sizeof ( m_GStitleInfoBuffer ) - 1 ] = 0 ; // make sure null terminated even if text overflows
Avih (of Firefox plugin "Smoothwheel" fame ;) ) worked on bringing back that extended GSdx information we lost in the merge to the new WX Gui.
Here's his changelog:
GSdx, PCSX2: Fixed broken GS info at the title bar
* If the plugin doesn't support the API, PCSX2 will display only the image mode (progressive/interlaced field/frame), NON i18n!
* If the plugin does support the API, PCSX2 will not display the image mode, and instead display the info from the plugin
* GSdx now properly sends title info: resolution, image mode, deinterlace mode (weave - bff, etc)
* To enable the full GSdx title info as it used to work before it got broken: uncomment //#define GSTITLEINFO_API_FORCE_VERBOSE at GS.h of GSdx.
NOTE: When using an older pcsx2.exe with newer GS plugin, the title would contain duplicate image mode info. All other combos work fine.
* PCSX2 still displays the performance info, etc in the title bar.
Thanks a bunch for bringing this information back, Avih! :)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4070 96395faa-99c1-11dd-bbfe-3dabce05a288
2010-12-02 22:48:56 +00:00
}
2010-01-28 02:53:10 +00:00
}
else
{
// [TODO]
// We don't have window title rights, or the window has no title,
// so let's use actual OSD!
2009-05-22 01:22:52 +00:00
}
if ( m_frameskip )
{
return ;
}
// present
2016-09-18 20:40:51 +00:00
#if 0
// This will scale the OSD to the PS2's output resolution.
// Will be affected by 2x, 4x, etc scaling.
m_dev - > m_osd . m_real_size = m_real_size
# elif 0
// This will scale the OSD to the window's size.
// Will maintiain the font size no matter what size the window is.
GSVector4i window_size = m_wnd - > GetClientRect ( ) ;
m_dev - > m_osd . m_real_size . x = window_size . v [ 2 ] ;
m_dev - > m_osd . m_real_size . y = window_size . v [ 3 ] ;
# else
// This will scale the OSD to the native resolution.
// Will size font relative to the window's size.
// TODO this should probably be done with native calls
m_dev - > m_osd . m_real_size . x = 1024 ;
m_dev - > m_osd . m_real_size . y = 768 ;
# endif
2013-01-04 11:41:51 +00:00
m_dev - > Present ( m_wnd - > GetClientRect ( ) . fit ( m_aspectratio ) , m_shader ) ;
2009-05-22 01:22:52 +00:00
// snapshot
if ( ! m_snapshot . empty ( ) )
{
2017-04-30 19:00:23 +00:00
if ( ! m_dump & & m_shift_key )
2009-05-22 01:22:52 +00:00
{
2017-04-30 19:00:23 +00:00
GSFreezeData fd = { 0 , nullptr } ;
2009-05-22 01:22:52 +00:00
Freeze ( & fd , true ) ;
fd . data = new uint8 [ fd . size ] ;
Freeze ( & fd , false ) ;
2017-04-30 19:00:23 +00:00
if ( m_control_key )
m_dump = std : : unique_ptr < GSDumpBase > ( new GSDump ( m_snapshot , m_crc , fd , m_regs ) ) ;
else
m_dump = std : : unique_ptr < GSDumpBase > ( new GSDumpXz ( m_snapshot , m_crc , fd , m_regs ) ) ;
2009-05-22 01:22:52 +00:00
delete [ ] fd . data ;
}
if ( GSTexture * t = m_dev - > GetCurrent ( ) )
{
2016-08-20 12:05:53 +00:00
t - > Save ( m_snapshot + " .bmp " ) ;
2009-05-22 01:22:52 +00:00
}
m_snapshot . clear ( ) ;
}
2017-04-30 19:00:23 +00:00
else if ( m_dump )
2009-05-22 01:22:52 +00:00
{
2017-04-30 19:00:23 +00:00
if ( m_dump - > VSync ( field , ! m_control_key , m_regs ) )
m_dump . reset ( ) ;
2009-05-22 01:22:52 +00:00
}
// capture
if ( m_capture . IsCapturing ( ) )
{
if ( GSTexture * current = m_dev - > GetCurrent ( ) )
{
GSVector2i size = m_capture . GetSize ( ) ;
if ( GSTexture * offscreen = m_dev - > CopyOffscreen ( current , GSVector4 ( 0 , 0 , 1 , 1 ) , size . x , size . y ) )
{
2009-06-12 19:09:17 +00:00
GSTexture : : GSMap m ;
2009-05-22 01:22:52 +00:00
2009-06-12 19:09:17 +00:00
if ( offscreen - > Map ( m ) )
2009-05-22 01:22:52 +00:00
{
2009-08-16 16:45:26 +00:00
m_capture . DeliverFrame ( m . bits , m . pitch , ! m_dev - > IsRBSwapped ( ) ) ;
2009-05-22 01:22:52 +00:00
offscreen - > Unmap ( ) ;
}
m_dev - > Recycle ( offscreen ) ;
}
}
}
}
2009-06-03 12:09:04 +00:00
bool GSRenderer : : MakeSnapshot ( const string & path )
{
if ( m_snapshot . empty ( ) )
{
2017-01-14 13:55:19 +00:00
time_t cur_time = time ( nullptr ) ;
static time_t prev_snap ;
// The variable 'n' is used for labelling the screenshots when multiple screenshots are taken in
// a single second, we'll start using this variable for naming when a second screenshot request is detected
// at the same time as the first one. Hence, we're initially setting this counter to 2 to imply that
// the captured image is the 2nd image captured at this specific time.
static int n = 2 ;
char local_time [ 16 ] ;
if ( strftime ( local_time , sizeof ( local_time ) , " %Y%m%d%H%M%S " , localtime ( & cur_time ) ) )
2009-06-03 12:09:04 +00:00
{
2017-01-14 13:55:19 +00:00
if ( cur_time = = prev_snap )
{
m_snapshot = format ( " %s_%s_(%d) " , path . c_str ( ) , local_time , n + + ) ;
}
else
{
n = 2 ;
m_snapshot = format ( " %s_%s " , path . c_str ( ) , local_time ) ;
}
prev_snap = cur_time ;
2009-06-03 12:09:04 +00:00
}
}
return true ;
}
2009-12-30 13:29:24 +00:00
2011-08-30 07:11:36 +00:00
bool GSRenderer : : BeginCapture ( )
2010-06-24 20:25:33 +00:00
{
2015-09-21 01:42:21 +00:00
GSVector4i disp = m_wnd - > GetClientRect ( ) . fit ( m_aspectratio ) ;
float aspect = ( float ) disp . width ( ) / max ( 1 , disp . height ( ) ) ;
return m_capture . BeginCapture ( GetTvRefreshRate ( ) , GetInternalResolution ( ) , aspect ) ;
2010-06-24 20:25:33 +00:00
}
void GSRenderer : : EndCapture ( )
{
m_capture . EndCapture ( ) ;
}
void GSRenderer : : KeyEvent ( GSKeyEventData * e )
2009-05-22 01:22:52 +00:00
{
2017-04-30 19:00:23 +00:00
# ifdef _WIN32
m_shift_key = ! ! ( : : GetAsyncKeyState ( VK_SHIFT ) & 0x8000 ) ;
m_control_key = ! ! ( : : GetAsyncKeyState ( VK_CONTROL ) & 0x8000 ) ;
# else
switch ( e - > key )
{
case XK_Shift_L :
case XK_Shift_R :
m_shift_key = ( e - > type = = KEYPRESS ) ;
return ;
case XK_Control_L :
case XK_Control_R :
m_control_key = ( e - > type = = KEYPRESS ) ;
return ;
}
# endif
2009-05-22 01:22:52 +00:00
if ( e - > type = = KEYPRESS )
{
2016-10-14 17:18:11 +00:00
int step = m_shift_key ? - 1 : 1 ;
2017-04-30 19:00:23 +00:00
# if defined(__unix__)
2016-10-14 17:18:11 +00:00
# define VK_F5 XK_F5
# define VK_F6 XK_F6
# define VK_F7 XK_F7
# define VK_DELETE XK_Delete
# define VK_INSERT XK_Insert
# define VK_PRIOR XK_Prior
# define VK_HOME XK_Home
# endif
2009-05-22 01:22:52 +00:00
switch ( e - > key )
{
case VK_F5 :
2015-10-25 20:44:20 +00:00
m_interlace = ( m_interlace + s_interlace_nb + step ) % s_interlace_nb ;
2011-04-05 11:30:07 +00:00
printf ( " GSdx: Set deinterlace mode to %d (%s). \n " , ( int ) m_interlace , theApp . m_gs_interlace . at ( m_interlace ) . name . c_str ( ) ) ;
2009-05-22 01:22:52 +00:00
return ;
case VK_F6 :
2013-01-04 11:41:51 +00:00
if ( m_wnd - > IsManaged ( ) )
2015-10-25 20:44:20 +00:00
m_aspectratio = ( m_aspectratio + s_aspect_ratio_nb + step ) % s_aspect_ratio_nb ;
2009-05-22 01:22:52 +00:00
return ;
case VK_F7 :
2015-10-25 20:44:20 +00:00
m_shader = ( m_shader + s_post_shader_nb + step ) % s_post_shader_nb ;
2014-02-02 20:40:28 +00:00
printf ( " GSdx: Set shader to: %d. \n " , ( int ) m_shader ) ;
2009-05-22 01:22:52 +00:00
return ;
case VK_DELETE :
m_aa1 = ! m_aa1 ;
2015-11-03 14:42:41 +00:00
printf ( " GSdx: (Software) Edge anti-aliasing is now %s. \n " , m_aa1 ? " enabled " : " disabled " ) ;
2009-05-22 01:22:52 +00:00
return ;
2011-03-12 22:10:58 +00:00
case VK_INSERT :
2016-10-14 17:22:38 +00:00
m_mipmap = ( m_mipmap + s_mipmap_nb + step ) % s_mipmap_nb ;
printf ( " GSdx: Mipmapping is now %s. \n " , theApp . m_gs_hack . at ( m_mipmap ) . name . c_str ( ) ) ;
2011-03-12 22:10:58 +00:00
return ;
2011-07-25 11:16:01 +00:00
case VK_PRIOR :
m_fxaa = ! m_fxaa ;
2014-01-17 10:17:24 +00:00
printf ( " GSdx: FXAA anti-aliasing is now %s. \n " , m_fxaa ? " enabled " : " disabled " ) ;
return ;
case VK_HOME :
m_shaderfx = ! m_shaderfx ;
printf ( " GSdx: External post-processing is now %s. \n " , m_shaderfx ? " enabled " : " disabled " ) ;
2011-07-25 11:16:01 +00:00
return ;
2009-05-22 01:22:52 +00:00
}
2011-02-19 03:36:30 +00:00
2012-01-06 07:20:37 +00:00
}
2009-05-22 01:22:52 +00:00
}
2016-05-05 14:43:02 +00:00
void GSRenderer : : PurgePool ( )
{
m_dev - > PurgePool ( ) ;
}