Committing magumagu9's work on texture decoding transferral to OGL, I added DX9 support. Speed seems to have increased but I'm not sure. See issue 581 for more info.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2222 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
XTra.KrazzY
2009-02-12 13:54:08 +00:00
parent 1bed914bf4
commit d2d097fba5
5 changed files with 67 additions and 194 deletions

View File

@ -44,11 +44,39 @@ LPDIRECT3DTEXTURE9 CreateTexture2D(const u8* buffer, const int width, const int
D3DLOCKED_RECT Lock;
pTexture->LockRect(level, &Lock, NULL, 0 );
u32* pIn = pBuffer;
switch(fmt)
{
case D3DFMT_L8:
case D3DFMT_A8:
{
const u8 *pIn = buffer;
for (int y = 0; y < height; y++)
{
u8* pBits = ((u8*)Lock.pBits + (y * Lock.Pitch));
memcpy(pBits, pIn, width);
pIn += pitch;
}
}
break;
case D3DFMT_A8L8:
{
const u8 *pIn = buffer;
// TODO(XK): Find a better way that does not involve either unpacking
// or downsampling (i.e. A4L4)
for (int y = 0; y < height; y++)
{
u8* pBits = ((u8*)Lock.pBits + (y * Lock.Pitch));
for(int i = 0; i < width * 2; i += 2) {
pBits[i] = pIn[i / 2];
pBits[i + 1] = pIn[i / 2];
}
pIn += pitch;
}
}
break;
case D3DFMT_A8R8G8B8:
{
u32* pIn = pBuffer;
for (int y = 0; y < height; y++)
{
u32* pBits = (u32*)((u8*)Lock.pBits + (y * Lock.Pitch));

View File

@ -176,6 +176,12 @@ void TextureCache::Load(int stage, u32 address, int width, int height, int forma
case PC_TEX_FMT_BGRA32:
d3d_fmt = D3DFMT_A8R8G8B8;
break;
/*case PC_TEX_FMT_BGRA16: is this of any use?
d3d_fmt = D3DFMT_A4R4G4B4;
break;*/
case PC_TEX_FMT_I8:
d3d_fmt = D3DFMT_A8L8;
break;
}
//Make an entry in the table

View File

@ -343,21 +343,30 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
glPixelStorei(GL_UNPACK_ROW_LENGTH, expandedWidth);
int gl_format;
int gl_iformat;
int gl_type;
switch (dfmt) {
case PC_TEX_FMT_NONE:
PanicAlert("Invalid PC texture format %i", dfmt);
case PC_TEX_FMT_BGRA32:
gl_format = GL_BGRA;
gl_iformat = 4;
gl_type = GL_UNSIGNED_BYTE;
break;
case PC_TEX_FMT_I8:
gl_format = GL_LUMINANCE;
gl_iformat = GL_INTENSITY;
gl_type = GL_UNSIGNED_BYTE;
break;
}
if (!entry.isNonPow2 && ((tm0.min_filter & 3) == 1 || (tm0.min_filter & 3) == 2)) {
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, width, height, gl_format, gl_type, temp);
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
glTexImage2D(GL_TEXTURE_2D, 0, gl_iformat, width, height, 0, gl_format, gl_type, temp);
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE);
entry.bHaveMipMaps = true;
}
else
glTexImage2D(target, 0, 4, width, height, 0, gl_format, gl_type, temp);
glTexImage2D(target, 0, gl_iformat, width, height, 0, gl_format, gl_type, temp);
if (expandedWidth != width) // reset
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);