Fixed huge performance issue in TV effects; CPU usage dropped from

26-27% to 11-12% on my test system.  This is from a baseline of 8-9%
for normal rendering, so the TV effects are now quite fast (only an
extra 2-4% CPU usage).


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2459 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2012-05-07 15:39:01 +00:00
parent 17d7b16be6
commit 090390b415
5 changed files with 51 additions and 55 deletions

View File

@ -133,13 +133,11 @@ void FBSurfaceTIA::update()
case FrameBufferGL::kBlarggNTSC:
{
#ifdef HAVE_GL_BGRA
#define BLIT16 blit_1555
myFB.myNTSCFilter.blit_1555
#else
#define BLIT16 blit_5551
myFB.myNTSCFilter.blit_5551
#endif
myFB.myNTSCFilter.BLIT16(currentFrame, width,
myTexture->w, height,
buffer, myTexture->pitch);
(currentFrame, width, height, buffer, myTexture->pitch);
break;
}
}

View File

@ -369,11 +369,13 @@ void FrameBufferGL::postFrameUpdate()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FrameBufferGL::enablePhosphor(bool enable, int blend)
{
myUsePhosphor = enable;
myPhosphorBlend = blend;
myFilterType = enable ? kPhosphor : kNone;
myRedrawEntireFrame = true;
if(myTiaSurface)
{
myUsePhosphor = enable;
myPhosphorBlend = blend;
myFilterType = enable ? kPhosphor : kNone;
myRedrawEntireFrame = true;
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -83,19 +83,19 @@ class NTSCFilter
// Perform Blargg filtering on input buffer, place results in
// output buffer
void blit_5551(uInt8* src_buf, long src_row_width,
int src_width, int src_height,
// In the current implementation, the source pitch is always the
// same as the actual width
void blit_5551(uInt8* src_buf, int src_width, int src_height,
uInt16* dest_buf, long dest_pitch)
{
atari_ntsc_blit_5551(&myFilter, src_buf, src_row_width,
atari_ntsc_blit_5551(&myFilter, src_buf, src_width,
src_width, src_height,
dest_buf, dest_pitch);
}
void blit_1555(uInt8* src_buf, long src_row_width,
int src_width, int src_height,
void blit_1555(uInt8* src_buf, int src_width, int src_height,
uInt16* dest_buf, long dest_pitch)
{
atari_ntsc_blit_1555(&myFilter, src_buf, src_row_width,
atari_ntsc_blit_1555(&myFilter, src_buf, src_width,
src_width, src_height,
dest_buf, dest_pitch);
}

View File

@ -92,7 +92,7 @@ void atari_ntsc_init( atari_ntsc_t* ntsc, atari_ntsc_setup_t const* setup )
float b = impl.to_float [*palette++];
float y, i, q = RGB_TO_YIQ( r, g, b, y, i );
// Generate kernel
int ir, ig, ib = YIQ_TO_RGB( y, i, q, impl.to_rgb, int, ir, ig );
atari_ntsc_rgb_t rgb = PACK_RGB( ir, ig, ib ); //(ib < 0x3E0 ? ib: 0x3E0)
@ -114,7 +114,7 @@ void atari_ntsc_blit_5551( atari_ntsc_t const* ntsc, atari_ntsc_in_t const* atar
while ( in_height-- )
{
atari_ntsc_in_t const* line_in = atari_in;
ATARI_NTSC_BEGIN_ROW( ntsc, atari_ntsc_black, ATARI_NTSC_ADJ_IN( line_in[0] ) );
ATARI_NTSC_BEGIN_ROW( ntsc, atari_ntsc_black, line_in[0] );
atari_ntsc_out_t* restrict line_out = (atari_ntsc_out_t*) rgb_out;
int n;
++line_in;
@ -122,16 +122,16 @@ void atari_ntsc_blit_5551( atari_ntsc_t const* ntsc, atari_ntsc_in_t const* atar
for ( n = chunk_count; n; --n )
{
/* order of input and output pixels must not be altered */
ATARI_NTSC_COLOR_IN( 0, ntsc, ATARI_NTSC_ADJ_IN( line_in[0] ) );
ATARI_NTSC_RGB_OUT_5551( 0, line_out [0] );
ATARI_NTSC_RGB_OUT_5551( 1, line_out [1] );
ATARI_NTSC_RGB_OUT_5551( 2, line_out [2] );
ATARI_NTSC_RGB_OUT_5551( 3, line_out [3] );
ATARI_NTSC_COLOR_IN( 0, ntsc, line_in[0] );
ATARI_NTSC_RGB_OUT_5551( 0, line_out[0] );
ATARI_NTSC_RGB_OUT_5551( 1, line_out[1] );
ATARI_NTSC_RGB_OUT_5551( 2, line_out[2] );
ATARI_NTSC_RGB_OUT_5551( 3, line_out[3] );
ATARI_NTSC_COLOR_IN( 1, ntsc, ATARI_NTSC_ADJ_IN( line_in[1] ) );
ATARI_NTSC_RGB_OUT_5551( 4, line_out [4] );
ATARI_NTSC_RGB_OUT_5551( 5, line_out [5] );
ATARI_NTSC_RGB_OUT_5551( 6, line_out [6] );
ATARI_NTSC_COLOR_IN( 1, ntsc, line_in[1] );
ATARI_NTSC_RGB_OUT_5551( 4, line_out[4] );
ATARI_NTSC_RGB_OUT_5551( 5, line_out[5] );
ATARI_NTSC_RGB_OUT_5551( 6, line_out[6] );
line_in += 2;
line_out += 7;
@ -139,15 +139,15 @@ void atari_ntsc_blit_5551( atari_ntsc_t const* ntsc, atari_ntsc_in_t const* atar
/* finish final pixels */
ATARI_NTSC_COLOR_IN( 0, ntsc, atari_ntsc_black );
ATARI_NTSC_RGB_OUT_5551( 0, line_out [0] );
ATARI_NTSC_RGB_OUT_5551( 1, line_out [1] );
ATARI_NTSC_RGB_OUT_5551( 2, line_out [2] );
ATARI_NTSC_RGB_OUT_5551( 3, line_out [3] );
ATARI_NTSC_RGB_OUT_5551( 0, line_out[0] );
ATARI_NTSC_RGB_OUT_5551( 1, line_out[1] );
ATARI_NTSC_RGB_OUT_5551( 2, line_out[2] );
ATARI_NTSC_RGB_OUT_5551( 3, line_out[3] );
ATARI_NTSC_COLOR_IN( 1, ntsc, atari_ntsc_black );
ATARI_NTSC_RGB_OUT_5551( 4, line_out [4] );
ATARI_NTSC_RGB_OUT_5551( 5, line_out [5] );
ATARI_NTSC_RGB_OUT_5551( 6, line_out [6] );
ATARI_NTSC_RGB_OUT_5551( 4, line_out[4] );
ATARI_NTSC_RGB_OUT_5551( 5, line_out[5] );
ATARI_NTSC_RGB_OUT_5551( 6, line_out[6] );
atari_in += in_row_width;
rgb_out = (char*) rgb_out + out_pitch;
@ -162,7 +162,7 @@ void atari_ntsc_blit_1555( atari_ntsc_t const* ntsc, atari_ntsc_in_t const* atar
while ( in_height-- )
{
atari_ntsc_in_t const* line_in = atari_in;
ATARI_NTSC_BEGIN_ROW( ntsc, atari_ntsc_black, ATARI_NTSC_ADJ_IN( line_in[0] ) );
ATARI_NTSC_BEGIN_ROW( ntsc, atari_ntsc_black, line_in[0] );
atari_ntsc_out_t* restrict line_out = (atari_ntsc_out_t*) rgb_out;
int n;
++line_in;
@ -170,16 +170,16 @@ void atari_ntsc_blit_1555( atari_ntsc_t const* ntsc, atari_ntsc_in_t const* atar
for ( n = chunk_count; n; --n )
{
/* order of input and output pixels must not be altered */
ATARI_NTSC_COLOR_IN( 0, ntsc, ATARI_NTSC_ADJ_IN( line_in[0] ) );
ATARI_NTSC_RGB_OUT_1555( 0, line_out [0] );
ATARI_NTSC_RGB_OUT_1555( 1, line_out [1] );
ATARI_NTSC_RGB_OUT_1555( 2, line_out [2] );
ATARI_NTSC_RGB_OUT_1555( 3, line_out [3] );
ATARI_NTSC_COLOR_IN( 0, ntsc, line_in[0] );
ATARI_NTSC_RGB_OUT_1555( 0, line_out[0] );
ATARI_NTSC_RGB_OUT_1555( 1, line_out[1] );
ATARI_NTSC_RGB_OUT_1555( 2, line_out[2] );
ATARI_NTSC_RGB_OUT_1555( 3, line_out[3] );
ATARI_NTSC_COLOR_IN( 1, ntsc, ATARI_NTSC_ADJ_IN( line_in[1] ) );
ATARI_NTSC_RGB_OUT_1555( 4, line_out [4] );
ATARI_NTSC_RGB_OUT_1555( 5, line_out [5] );
ATARI_NTSC_RGB_OUT_1555( 6, line_out [6] );
ATARI_NTSC_COLOR_IN( 1, ntsc, line_in[1] );
ATARI_NTSC_RGB_OUT_1555( 4, line_out[4] );
ATARI_NTSC_RGB_OUT_1555( 5, line_out[5] );
ATARI_NTSC_RGB_OUT_1555( 6, line_out[6] );
line_in += 2;
line_out += 7;
@ -187,15 +187,15 @@ void atari_ntsc_blit_1555( atari_ntsc_t const* ntsc, atari_ntsc_in_t const* atar
/* finish final pixels */
ATARI_NTSC_COLOR_IN( 0, ntsc, atari_ntsc_black );
ATARI_NTSC_RGB_OUT_1555( 0, line_out [0] );
ATARI_NTSC_RGB_OUT_1555( 1, line_out [1] );
ATARI_NTSC_RGB_OUT_1555( 2, line_out [2] );
ATARI_NTSC_RGB_OUT_1555( 3, line_out [3] );
ATARI_NTSC_RGB_OUT_1555( 0, line_out[0] );
ATARI_NTSC_RGB_OUT_1555( 1, line_out[1] );
ATARI_NTSC_RGB_OUT_1555( 2, line_out[2] );
ATARI_NTSC_RGB_OUT_1555( 3, line_out[3] );
ATARI_NTSC_COLOR_IN( 1, ntsc, atari_ntsc_black );
ATARI_NTSC_RGB_OUT_1555( 4, line_out [4] );
ATARI_NTSC_RGB_OUT_1555( 5, line_out [5] );
ATARI_NTSC_RGB_OUT_1555( 6, line_out [6] );
ATARI_NTSC_RGB_OUT_1555( 4, line_out[4] );
ATARI_NTSC_RGB_OUT_1555( 5, line_out[5] );
ATARI_NTSC_RGB_OUT_1555( 6, line_out[6] );
atari_in += in_row_width;
rgb_out = (char*) rgb_out + out_pitch;

View File

@ -30,10 +30,6 @@ typedef unsigned short atari_ntsc_out_t;
extern "C" {
#endif
/* Each raw pixel input value is passed through this. You might want to mask
the pixel index if you use the high bits as flags, etc. */
#define ATARI_NTSC_ADJ_IN( in ) in
/* Image parameters, ranging from -1.0 to 1.0. Actual internal values shown
in parenthesis and should remain fairly stable in future versions. */
typedef struct atari_ntsc_setup_t