-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed rain effect for PPC; added PPC Altivec graphic routines; added …
…SSE2 alpha-blend graphic routine
- Loading branch information
sonozaki
committed
Jun 21, 2009
1 parent
e9094b2
commit 7cdbb73
Showing
9 changed files
with
312 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* -*- C++ -*- | ||
* | ||
* graphics_altivec.cpp - graphics routines using PPC Altivec cpu functionality | ||
* | ||
* Copyright (c) 2009 Mion. All rights reserved. | ||
* | ||
* 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 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* 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. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*/ | ||
|
||
// Based upon routines provided by Roto | ||
|
||
#ifdef USE_PPC_GFX | ||
|
||
#include <altivec.h> | ||
#include <math.h> | ||
#ifndef M_PI | ||
#define M_PI 3.14159265358979323846 | ||
#endif | ||
|
||
#include "graphics_common.h" | ||
|
||
|
||
void imageFilterMean_Altivec(unsigned char *src1, unsigned char *src2, unsigned char *dst, int length) | ||
{ | ||
int n = length; | ||
|
||
// Compute first few values so we're on a 16-byte boundary in dst | ||
while( (((long)dst & 0xF) > 0) && (n > 0) ) { | ||
MEAN_PIXEL(); | ||
--n; ++dst; ++src1; ++src2; | ||
} | ||
|
||
// Do bulk of processing using Altivec (find the mean of 16 8-bit unsigned integers, with saturation) | ||
vector unsigned char rshft = vec_splat_u8(0x1); | ||
while(n >= 16) { | ||
vector unsigned char s1 = vec_ld(0,src1); | ||
s1 = vec_sr(s1, rshft); // shift right 1 | ||
vector unsigned char s2 = vec_ld(0,src2); | ||
s2 = vec_sr(s2, rshft); // shift right 1 | ||
vector unsigned char r = vec_adds(s1, s2); | ||
vec_st(r,0,dst); | ||
|
||
n -= 16; src1 += 16; src2 += 16; dst += 16; | ||
} | ||
|
||
// If any bytes are left over, deal with them individually | ||
++n; | ||
BASIC_MEAN(); | ||
} | ||
|
||
|
||
void imageFilterAddTo_Altivec(unsigned char *dst, unsigned char *src, int length) | ||
{ | ||
int n = length; | ||
|
||
// Compute first few values so we're on a 16-byte boundary in dst | ||
while( (((long)dst & 0xF) > 0) && (n > 0) ) { | ||
ADDTO_PIXEL(); | ||
--n; ++dst; ++src; | ||
} | ||
|
||
// Do bulk of processing using Altivec (add 16 8-bit unsigned integers, with saturation) | ||
while(n >= 16) { | ||
vector unsigned char s = vec_ld(0,src); | ||
vector unsigned char d = vec_ld(0,dst); | ||
vector unsigned char r = vec_adds(d, s); | ||
vec_st(r,0,dst); | ||
|
||
n -= 16; src += 16; dst += 16; | ||
} | ||
|
||
// If any bytes are left over, deal with them individually | ||
++n; | ||
BASIC_ADDTO(); | ||
} | ||
|
||
|
||
void imageFilterSubFrom_Altivec(unsigned char *dst, unsigned char *src, int length) | ||
{ | ||
int n = length; | ||
|
||
// Compute first few values so we're on a 16-byte boundary in dst | ||
while( (((long)dst & 0xF) > 0) && (n > 0) ) { | ||
SUBFROM_PIXEL(); | ||
--n; ++dst; ++src; | ||
} | ||
|
||
// Do bulk of processing using Altivec (sub 16 8-bit unsigned integers, with saturation) | ||
while(n >= 16) { | ||
vector unsigned char s = vec_ld(0,src); | ||
vector unsigned char d = vec_ld(0,dst); | ||
vector unsigned char r = vec_subs(d, s); | ||
vec_st(r,0,dst); | ||
|
||
n -= 16; src += 16; dst += 16; | ||
} | ||
|
||
// If any bytes are left over, deal with them individually | ||
++n; | ||
BASIC_SUBFROM(); | ||
} | ||
|
||
#endif | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* -*- C++ -*- | ||
* | ||
* graphics_altivec.h - graphics routines using PPC Altivec cpu functionality | ||
* | ||
* Copyright (c) 2009 Mion. All rights reserved. | ||
* | ||
* 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 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* 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. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
*/ | ||
|
||
#ifdef USE_PPC_GFX | ||
|
||
void imageFilterMean_Altivec(unsigned char *src1, unsigned char *src2, unsigned char *dst, int length); | ||
void imageFilterAddTo_Altivec(unsigned char *dst, unsigned char *src, int length); | ||
void imageFilterSubFrom_Altivec(unsigned char *dst, unsigned char *src, int length); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.