d3d: a little speedup in efb to ram please test and let me know the result

opengl: a little code cleanup and possible speedup in texture recreation.
d3d and opengl :plugins corrected the efb alignment when efb to ram is used.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4637 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Rodolfo Osvaldo Bogado 2009-12-03 20:09:15 +00:00
parent afdfd29fcd
commit a99a1451f9
5 changed files with 158 additions and 196 deletions

View File

@ -258,10 +258,10 @@ void dumpMatrix(D3DXMATRIX &mtx)
TargetRectangle Renderer::ConvertEFBRectangle(const EFBRectangle& rc)
{
TargetRectangle result;
result.left = (int)ceilf((((float)rc.left * s_target_width) / (float)EFB_WIDTH)-0.5f) ;
result.top = (int)ceilf((((float)rc.top * s_target_height) / (float)EFB_HEIGHT)-0.5f);
result.right = (int)floorf((((float)rc.right * s_target_width) / (float)EFB_WIDTH)+0.5f) ;
result.bottom = (int)floorf((((float)rc.bottom * s_target_height) / (float)EFB_HEIGHT)+0.5f);
result.left = (int)((rc.left) * xScale) ;
result.top = (int)((rc.top) * yScale);
result.right = (int)((rc.right) * xScale) ;
result.bottom = (int)((rc.bottom) * yScale);
return result;
}
@ -636,15 +636,11 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
EFBRectangle source_rect;
LPDIRECT3DTEXTURE9 read_texture = FBManager::GetEFBDepthTexture(source_rect);
D3D::dev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
D3D::dev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
D3D::dev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
D3D::dev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
D3D::drawShadedTexQuad(read_texture,&RectToLock, Renderer::GetTargetWidth() , Renderer::GetTargetHeight(),&PixelRect,(BufferFormat == FOURCC_RAWZ)?PixelShaderCache::GetColorMatrixProgram():PixelShaderCache::GetDepthMatrixProgram(),VertexShaderCache::GetSimpleVertexShader());
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
D3D::RefreshSamplerState(0, D3DSAMP_MAGFILTER);
D3D::RefreshSamplerState(0, D3DSAMP_MIPFILTER);
hr = D3D::dev->SetRenderTarget(0, FBManager::GetEFBColorRTSurface());
hr = D3D::dev->SetDepthStencilSurface(FBManager::GetEFBDepthRTSurface());
@ -785,9 +781,9 @@ void UpdateViewport()
vp.Width = Width;
vp.Height = Height;
//some games set invalids values for z min and z max so fix them to the max an min alowed and let the shaders do this work
vp.MinZ = (xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f;
vp.MaxZ = xfregs.rawViewport[5] / 16777216.0f;
if(vp.MinZ < 0.0f)
vp.MinZ = 0.0f;//(xfregs.rawViewport[5] - xfregs.rawViewport[2]) / 16777216.0f;
vp.MaxZ =1.0f;// xfregs.rawViewport[5] / 16777216.0f;
/*if(vp.MinZ < 0.0f)
vp.MinZ = 0.0f;
if(vp.MinZ > 1.0f)
vp.MinZ = 1.0f;
@ -800,7 +796,7 @@ void UpdateViewport()
float temp = vp.MinZ;
vp.MinZ = vp.MaxZ;
vp.MaxZ = temp;
}
}*/
D3D::dev->SetViewport(&vp);
}

View File

@ -295,7 +295,6 @@ void TextureCache::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, boo
int tex_w = (abs(source_rect.GetWidth()) >> bScaleByHalf);
int tex_h = (abs(source_rect.GetHeight()) >> bScaleByHalf);
TexCache::iterator iter;
LPDIRECT3DTEXTURE9 tex;
iter = textures.find(address);
@ -476,14 +475,22 @@ have_texture:
sourcerect.top = targetSource.top;
if(bScaleByHalf)
{
D3D::dev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
D3D::dev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
}
else
{
D3D::dev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
D3D::dev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
}
D3DFORMAT bformat = FBManager::GetEFBDepthRTSurfaceFormat();
D3D::drawShadedTexQuad(read_texture,&sourcerect, Renderer::GetTargetWidth() , Renderer::GetTargetHeight(),&destrect,((bformat != FOURCC_RAWZ && bformat != D3DFMT_D24X8) && bFromZBuffer)? PixelShaderCache::GetDepthMatrixProgram(): PixelShaderCache::GetColorMatrixProgram(),VertexShaderCache::GetSimpleVertexShader());
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
D3D::RefreshSamplerState(0, D3DSAMP_MAGFILTER);
D3D::dev->SetRenderTarget(0, FBManager::GetEFBColorRTSurface());
D3D::dev->SetDepthStencilSurface(FBManager::GetEFBDepthRTSurface());

View File

@ -33,18 +33,21 @@
#include "D3DUtil.h"
#include "D3DShader.h"
#include "TextureCache.h"
#include "Math.h"
namespace TextureConverter
{
/*static LPDIRECT3DTEXTURE9 s_texConvFrameBuffer = 0;
static LPDIRECT3DTEXTURE9 s_srcTexture = 0; // for decoding from RAM
static u32 s_srcTextureWidth = 0;
static u32 s_srcTextureHeight = 0;
static LPDIRECT3DSURFACE9 s_texConvReadSurface = 0;
const int renderBufferWidth = 1024;
const int renderBufferHeight = 1024;*/
struct TransformBuffer
{
LPDIRECT3DTEXTURE9 FBTexture;
LPDIRECT3DSURFACE9 RenderSurface;
LPDIRECT3DSURFACE9 ReadSurface;
int Width;
int Height;
};
const u32 NUM_TRANSFORM_BUFFERS = 16;
static TransformBuffer TrnBuffers[NUM_TRANSFORM_BUFFERS];
static u32 WorkingBuffers = 0;
static LPDIRECT3DPIXELSHADER9 s_rgbToYuyvProgram = NULL;
static LPDIRECT3DPIXELSHADER9 s_yuyvToRgbProgram = NULL;
@ -136,17 +139,21 @@ LPDIRECT3DPIXELSHADER9 GetOrCreateEncodingShader(u32 format)
void Init()
{
/*HRESULT hr = D3D::dev->CreateTexture(renderBufferWidth, renderBufferHeight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
D3DPOOL_DEFAULT, &s_texConvFrameBuffer, NULL);
hr = D3D::dev->CreateTexture(renderBufferWidth, renderBufferHeight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
D3DPOOL_DEFAULT, &s_srcTexture, NULL);
hr = D3D::dev->CreateOffscreenPlainSurface(renderBufferWidth, renderBufferWidth, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &s_texConvReadSurface, NULL );*/
for (unsigned int i = 0; i < NUM_ENCODING_PROGRAMS; i++)
{
s_encodingPrograms[i] = NULL;
}
for (unsigned int i = 0; i < NUM_TRANSFORM_BUFFERS; i++)
{
TrnBuffers[i].FBTexture = NULL;
TrnBuffers[i].RenderSurface = NULL;
TrnBuffers[i].ReadSurface = NULL;
TrnBuffers[i].Width = 0;
TrnBuffers[i].Height = 0;
}
CreateRgbToYuyvProgram();
CreateYuyvToRgbProgram();
}
void Shutdown()
@ -158,22 +165,30 @@ void Shutdown()
s_yuyvToRgbProgram->Release();
s_yuyvToRgbProgram=NULL;
/*if(s_texConvReadSurface)
s_texConvReadSurface->Release();
s_texConvReadSurface=NULL;*/
for (unsigned int i = 0; i < NUM_ENCODING_PROGRAMS; i++)
{
if(s_encodingPrograms[i])
s_encodingPrograms[i]->Release();
s_encodingPrograms[i] = NULL;
}
/*if(s_srcTexture)
s_srcTexture->Release();
s_srcTexture=NULL;
if(s_texConvFrameBuffer)
s_texConvFrameBuffer->Release();
s_texConvFrameBuffer = NULL;*/
for (unsigned int i = 0; i < NUM_TRANSFORM_BUFFERS; i++)
{
if(TrnBuffers[i].RenderSurface != NULL)
TrnBuffers[i].RenderSurface->Release();
TrnBuffers[i].RenderSurface = NULL;
if(TrnBuffers[i].ReadSurface != NULL)
TrnBuffers[i].ReadSurface->Release();
TrnBuffers[i].ReadSurface = NULL;
if(TrnBuffers[i].FBTexture != NULL)
TrnBuffers[i].FBTexture->Release();
TrnBuffers[i].FBTexture = NULL;
TrnBuffers[i].Width = 0;
TrnBuffers[i].Height = 0;
}
WorkingBuffers = 0;
}
void EncodeToRamUsingShader(LPDIRECT3DPIXELSHADER9 shader, LPDIRECT3DTEXTURE9 srcTexture, const TargetRectangle& sourceRc,
@ -181,31 +196,57 @@ void EncodeToRamUsingShader(LPDIRECT3DPIXELSHADER9 shader, LPDIRECT3DTEXTURE9 sr
{
HRESULT hr;
Renderer::ResetAPIState();
// switch to texture converter frame buffer
LPDIRECT3DTEXTURE9 tempTexture = 0;
hr = D3D::dev->CreateTexture(dstWidth, dstHeight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
D3DPOOL_DEFAULT, &tempTexture, NULL);
LPDIRECT3DSURFACE9 Rendersurf = NULL;
tempTexture->GetSurfaceLevel(0,&Rendersurf);
hr = D3D::dev->SetDepthStencilSurface(NULL);
hr = D3D::dev->SetRenderTarget(0, Rendersurf);
u32 index =0;
while(index < WorkingBuffers && (TrnBuffers[index].Width != dstWidth || TrnBuffers[index].Height != dstHeight))
index++;
LPDIRECT3DSURFACE9 s_texConvReadSurface = NULL;
LPDIRECT3DSURFACE9 Rendersurf = NULL;
if(index >= WorkingBuffers)
{
if(WorkingBuffers < NUM_TRANSFORM_BUFFERS)
WorkingBuffers++;
if(index >= WorkingBuffers)
index--;
if(TrnBuffers[index].RenderSurface != NULL)
{
TrnBuffers[index].RenderSurface->Release();
TrnBuffers[index].RenderSurface = NULL;
}
if(TrnBuffers[index].ReadSurface != NULL)
{
TrnBuffers[index].ReadSurface->Release();
TrnBuffers[index].ReadSurface = NULL;
}
if(TrnBuffers[index].FBTexture != NULL)
{
TrnBuffers[index].FBTexture->Release();
TrnBuffers[index].FBTexture = NULL;
}
TrnBuffers[index].Width = dstWidth;
TrnBuffers[index].Height = dstHeight;
D3D::dev->CreateTexture(dstWidth, dstHeight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
D3DPOOL_DEFAULT, &TrnBuffers[index].FBTexture, NULL);
TrnBuffers[index].FBTexture->GetSurfaceLevel(0,&TrnBuffers[index].RenderSurface);
D3D::dev->CreateOffscreenPlainSurface(dstWidth, dstHeight, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &TrnBuffers[index].ReadSurface, NULL );
}
s_texConvReadSurface = TrnBuffers[index].ReadSurface;
Rendersurf = TrnBuffers[index].RenderSurface;
hr = D3D::dev->SetDepthStencilSurface(NULL);
hr = D3D::dev->SetRenderTarget(0, Rendersurf);
if (linearFilter)
{
D3D::dev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
D3D::dev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
D3D::dev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
D3D::dev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
}
else
{
D3D::dev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
D3D::dev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
D3D::dev->SetSamplerState(0, D3DSAMP_MIPFILTER, D3DTEXF_POINT);
}
D3DVIEWPORT9 vp;
vp.X = 0;
vp.Y = 0;
@ -232,18 +273,14 @@ void EncodeToRamUsingShader(LPDIRECT3DPIXELSHADER9 shader, LPDIRECT3DTEXTURE9 sr
hr = D3D::dev->SetDepthStencilSurface(FBManager::GetEFBDepthRTSurface());
Renderer::RestoreAPIState();
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
D3D::RefreshSamplerState(0, D3DSAMP_MAGFILTER);
D3D::RefreshSamplerState(0, D3DSAMP_MIPFILTER);
// .. and then readback the results.
// TODO: make this less slow.
D3DLOCKED_RECT drect;
LPDIRECT3DSURFACE9 s_tempConvReadSurface = 0;
hr = D3D::dev->CreateOffscreenPlainSurface(dstWidth, dstHeight, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &s_tempConvReadSurface, NULL );
hr = D3D::dev->GetRenderTargetData(Rendersurf,s_tempConvReadSurface);
if((hr = s_tempConvReadSurface->LockRect(&drect, &DstRect, D3DLOCK_READONLY)) != D3D_OK)
hr = D3D::dev->GetRenderTargetData(Rendersurf,s_texConvReadSurface);
if((hr = s_texConvReadSurface->LockRect(&drect, &DstRect, D3DLOCK_READONLY)) != D3D_OK)
{
PanicAlert("ERROR: %s", hr == D3DERR_WASSTILLDRAWING ? "Still drawing" :
hr == D3DERR_INVALIDCALL ? "Invalid call" : "w00t");
@ -273,11 +310,8 @@ void EncodeToRamUsingShader(LPDIRECT3DPIXELSHADER9 shader, LPDIRECT3DTEXTURE9 sr
else
memcpy(destAddr,drect.pBits,dstWidth*dstHeight*4);// 4 bytes per pixel
hr = s_tempConvReadSurface->UnlockRect();
}
s_tempConvReadSurface->Release();
Rendersurf->Release();
tempTexture->Release();
hr = s_texConvReadSurface->UnlockRect();
}
}
void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source)
@ -324,14 +358,13 @@ void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyf
float MValueX = Renderer::GetTargetScaleX();
float MValueY = Renderer::GetTargetScaleY();
float top = source.top * MValueY;
float sampleStride = bScaleByHalf?2.0f:1.0f;
TextureConversionShader::SetShaderParameters(
(float)expandedWidth,
expandedHeight * MValueY,
source.left * MValueX + 0.5f,
top + 0.5f,
ceilf(source.left * MValueX + 1.0f),
ceilf(source.top * MValueY + 1.0f),
sampleStride * MValueX,
sampleStride * MValueY,
(float)Renderer::GetTargetWidth(),

View File

@ -292,11 +292,16 @@ void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyf
float MValueX = Renderer::GetTargetScaleX();
float MValueY = Renderer::GetTargetScaleY();
float top = Renderer::GetTargetHeight() - (source.top + expandedHeight) * MValueY;
float top = Renderer::GetTargetHeight() - floorf((source.top + expandedHeight) * MValueY - 0.5f);
float sampleStride = bScaleByHalf?2.0f:1.0f;
TextureConversionShader::SetShaderParameters((float)expandedWidth, expandedHeight * MValueY, source.left * MValueX, top, sampleStride * MValueX, sampleStride * MValueY);
TextureConversionShader::SetShaderParameters((float)expandedWidth,
expandedHeight * MValueY,
ceilf(source.left * MValueX + 0.5f),
top,
sampleStride * MValueX,
sampleStride * MValueY);
TargetRectangle scaledSource;
scaledSource.top = 0;

View File

@ -424,25 +424,40 @@ TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width
gl_type = GL_UNSIGNED_SHORT_5_6_5;
break;
}
if (!entry.isRectangle && ((tm0.min_filter & 3) == 1 || (tm0.min_filter & 3) == 2))
bool GenerateMipmaps = !entry.isRectangle && ((tm0.min_filter & 3) == 1 || (tm0.min_filter & 3) == 2);
if (GenerateMipmaps)
{
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;
glTexParameteri(target, GL_GENERATE_MIPMAP, GL_TRUE);
}
if(skip_texture_create)
{
glTexSubImage2D(target, 0,0,0,width, height, gl_format, gl_type, temp);
}
else
{
glTexImage2D(target, 0, gl_iformat, width, height, 0, gl_format, gl_type, temp);
}
if (GenerateMipmaps)
{
glTexParameteri(target, GL_GENERATE_MIPMAP, GL_FALSE);
entry.bHaveMipMaps = true;
}
if (expandedWidth != width) // reset
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
}
else
{
glCompressedTexImage2D(target, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
expandedWidth, expandedHeight, 0, expandedWidth*expandedHeight/2, temp);
if(skip_texture_create)
{
glCompressedTexSubImage2D(target, 0,0,0,expandedWidth, expandedHeight,
GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,expandedWidth*expandedHeight/2, temp);
}
else
{
glCompressedTexImage2D(target, 0, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
expandedWidth, expandedHeight, 0, expandedWidth*expandedHeight/2, temp);
}
}
entry.frameCount = frameCount;
@ -496,9 +511,9 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
// IA4,RA4 - IA4
// Z8M,G8,I8,A8,Z8,R8,B8,Z8L - I8
// Z16,GB8,RG8,Z16L,IA8,RA8 - IA8
int gl_format;
int gl_iformat;
int gl_type;
GLenum gl_format = GL_RGBA;
GLenum gl_iformat = 4;
GLenum gl_type = GL_UNSIGNED_BYTE;
float colmat[16];
float fConstAdd[4] = {0};
memset(colmat, 0, sizeof(colmat));
@ -507,60 +522,31 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
{
switch(copyfmt)
{
case 0: // Z4
colmat[2] = colmat[6] = colmat[10] = colmat[14] = 1;
gl_format = GL_LUMINANCE;
gl_iformat = GL_INTENSITY4;
gl_type = GL_UNSIGNED_BYTE;
break;
case 0: // Z4
case 1: // Z8
gl_format = GL_LUMINANCE;
gl_iformat = GL_INTENSITY8;
gl_type = GL_UNSIGNED_BYTE;
colmat[2] = colmat[6] = colmat[10] = colmat[14] = 1;
colmat[2] = colmat[6] = colmat[10] = colmat[14] = 1;
break;
case 3: // Z16 //?
gl_format = GL_LUMINANCE_ALPHA;
gl_iformat = GL_LUMINANCE8_ALPHA8;
gl_type = GL_UNSIGNED_BYTE;
colmat[1] = colmat[5] = colmat[9] = colmat[14] = 1;
colmat[1] = colmat[5] = colmat[9] = colmat[14] = 1;
break;
case 11: // Z16 (reverse order)
gl_format = GL_LUMINANCE_ALPHA;
gl_iformat = GL_LUMINANCE8_ALPHA8;
gl_type = GL_UNSIGNED_BYTE;
colmat[2] = colmat[6] = colmat[10] = colmat[13] = 1;
colmat[2] = colmat[6] = colmat[10] = colmat[13] = 1;
break;
case 6: // Z24X8
gl_format = GL_RGBA;
gl_iformat = 4;
gl_type = GL_UNSIGNED_BYTE;
colmat[2] = colmat[5] = colmat[8] = colmat[15] = 1;
colmat[2] = colmat[5] = colmat[8] = colmat[15] = 1;
break;
case 9: // Z8M
gl_format = GL_LUMINANCE;
gl_iformat = GL_INTENSITY8;
gl_type = GL_UNSIGNED_BYTE;
colmat[1] = colmat[5] = colmat[9] = colmat[13] = 1;
colmat[1] = colmat[5] = colmat[9] = colmat[13] = 1;
break;
case 10: // Z8L
gl_format = GL_LUMINANCE;
gl_iformat = GL_INTENSITY8;
gl_type = GL_UNSIGNED_BYTE;
colmat[0] = colmat[4] = colmat[8] = colmat[12] = 1;
colmat[0] = colmat[4] = colmat[8] = colmat[12] = 1;
break;
case 12: // Z16L
gl_format = GL_LUMINANCE_ALPHA;
gl_iformat = GL_LUMINANCE8_ALPHA8;
gl_type = GL_UNSIGNED_BYTE;
colmat[0] = colmat[4] = colmat[8] = colmat[13] = 1;
colmat[0] = colmat[4] = colmat[8] = colmat[13] = 1;
break;
default:
ERROR_LOG(VIDEO, "Unknown copy zbuf format: 0x%x", copyfmt);
gl_format = GL_RGBA;
gl_iformat = 4;
gl_type = GL_UNSIGNED_BYTE;
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
break;
}
}
@ -577,33 +563,7 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
colmat[12] = 0.257f; colmat[13] = 0.504f; colmat[14] = 0.098f;
}
else// alpha
colmat[15] = 1;
switch (copyfmt)
{
case 0: // I4
gl_format = GL_LUMINANCE;
gl_iformat = GL_INTENSITY4;
gl_type = GL_UNSIGNED_BYTE;
break;
case 1: // I8
gl_format = GL_LUMINANCE;
gl_iformat = GL_INTENSITY8;
gl_type = GL_UNSIGNED_BYTE;
break;
case 2: // IA4
gl_format = GL_LUMINANCE_ALPHA;
gl_iformat = GL_LUMINANCE4_ALPHA4;
gl_type = GL_UNSIGNED_BYTE;
break;
case 3: // IA8
gl_format = GL_LUMINANCE_ALPHA;
gl_iformat = GL_LUMINANCE8_ALPHA8;
gl_type = GL_UNSIGNED_BYTE;
break;
default:
ERROR_LOG(VIDEO, "Unknown copy intensity format: 0x%x", copyfmt);
break;
}
colmat[15] = 1;
}
else
{
@ -611,83 +571,44 @@ void TextureMngr::CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool
{
case 0: // R4
colmat[0] = colmat[4] = colmat[8] = colmat[12] = 1;
gl_format = GL_LUMINANCE;
gl_iformat = GL_INTENSITY4;
gl_type = GL_UNSIGNED_BYTE;
break;
case 8: // R8
gl_format = GL_LUMINANCE;
gl_iformat = GL_INTENSITY8;
gl_type = GL_UNSIGNED_BYTE;
colmat[0] = colmat[4] = colmat[8] = colmat[12] = 1;
colmat[0] = colmat[4] = colmat[8] = colmat[12] = 1;
break;
case 2: // RA4
gl_format = GL_LUMINANCE_ALPHA;
gl_iformat = GL_LUMINANCE4_ALPHA4;
gl_type = GL_UNSIGNED_BYTE;
colmat[0] = colmat[4] = colmat[8] = colmat[15] = 1;
break;
case 3: // RA8
gl_format = GL_LUMINANCE_ALPHA;
gl_iformat = GL_LUMINANCE8_ALPHA8;
gl_type = GL_UNSIGNED_BYTE;
colmat[0] = colmat[4] = colmat[8] = colmat[15] = 1;
colmat[0] = colmat[4] = colmat[8] = colmat[15] = 1;
break;
case 7: // A8
gl_format = GL_ALPHA;
gl_iformat = GL_ALPHA8;
gl_type = GL_UNSIGNED_BYTE;
colmat[3] = colmat[7] = colmat[11] = colmat[15] = 1;
colmat[3] = colmat[7] = colmat[11] = colmat[15] = 1;
break;
case 9: // G8
gl_format = GL_LUMINANCE;
gl_iformat = GL_INTENSITY8;
gl_type = GL_UNSIGNED_BYTE;
colmat[1] = colmat[5] = colmat[9] = colmat[13] = 1;
colmat[1] = colmat[5] = colmat[9] = colmat[13] = 1;
break;
case 10: // B8
gl_format = GL_LUMINANCE;
gl_iformat = GL_INTENSITY8;
gl_type = GL_UNSIGNED_BYTE;
colmat[2] = colmat[6] = colmat[10] = colmat[14] = 1;
colmat[2] = colmat[6] = colmat[10] = colmat[14] = 1;
break;
case 11: // RG8
gl_format = GL_RGBA;
gl_iformat = 4;
gl_type = GL_UNSIGNED_BYTE;
colmat[0] = colmat[4] = colmat[8] = colmat[13] = 1;
colmat[0] = colmat[4] = colmat[8] = colmat[13] = 1;
break;
case 12: // GB8
gl_format = GL_RGBA;
gl_iformat = 4;
gl_type = GL_UNSIGNED_BYTE;
colmat[1] = colmat[5] = colmat[9] = colmat[14] = 1;
colmat[1] = colmat[5] = colmat[9] = colmat[14] = 1;
break;
case 4: // RGB565
gl_format = GL_RGB;
gl_iformat = GL_RGB;
gl_type = GL_UNSIGNED_SHORT_5_6_5;
colmat[0] = colmat[5] = colmat[10] = 1;
colmat[0] = colmat[5] = colmat[10] = 1;
fConstAdd[3] = 1; // set alpha to 1
break;
case 5: // RGB5A3
gl_format = GL_RGBA;
gl_iformat = 4;
gl_type = GL_UNSIGNED_BYTE;
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
break;
case 6: // RGBA8
gl_format = GL_RGBA;
gl_iformat = 4;
gl_type = GL_UNSIGNED_BYTE;
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
break;
default:
ERROR_LOG(VIDEO, "Unknown copy color format: 0x%x", copyfmt);
gl_format = GL_RGBA;
gl_iformat = 4;
gl_type = GL_UNSIGNED_BYTE;
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
colmat[0] = colmat[5] = colmat[10] = colmat[15] = 1;
break;
}
}