summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authoromegadox <omegadox@gmail.com>2009-08-11 20:36:13 +0000
committeromegadox <omegadox@gmail.com>2009-08-11 20:36:13 +0000
commit7aede7309f5d8a1b76f0d353bf8ec2c1e8d9753c (patch)
tree168cbee2e4f43785ba32242c4b379f7757d0ff5d /Source
parentbcf7b2112be4df50a2f845bd2a8d61d933c5d7dc (diff)
GFX: Cleanup - Move OGL's GetBlockHeightInTexels and GetBlockWidthInTexels code into VideoCommon.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3962 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/VideoCommon/Src/TextureDecoder.cpp36
-rw-r--r--Source/Core/VideoCommon/Src/TextureDecoder.h4
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/TextureConversionShader.cpp67
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/TextureConversionShader.h3
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp4
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp2
-rw-r--r--Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.h2
7 files changed, 44 insertions, 74 deletions
diff --git a/Source/Core/VideoCommon/Src/TextureDecoder.cpp b/Source/Core/VideoCommon/Src/TextureDecoder.cpp
index ae27a9909a..bb9e8f34d4 100644
--- a/Source/Core/VideoCommon/Src/TextureDecoder.cpp
+++ b/Source/Core/VideoCommon/Src/TextureDecoder.cpp
@@ -93,7 +93,7 @@ u32 TexDecoder_GetSafeTextureHash(const u8 *src, int width, int height, int texf
return hash;
}
-int TexDecoder_GetBlockWidthInTexels(int format)
+int TexDecoder_GetBlockWidthInTexels(u32 format)
{
switch (format)
{
@@ -108,13 +108,29 @@ int TexDecoder_GetBlockWidthInTexels(int format)
case GX_TF_C8: return 8;
case GX_TF_C14X2: return 4;
case GX_TF_CMPR: return 8;
+ case GX_CTF_R4: return 8;
+ case GX_CTF_RA4: return 8;
+ case GX_CTF_RA8: return 4;
+ case GX_CTF_A8: return 8;
+ case GX_CTF_R8: return 8;
+ case GX_CTF_G8: return 8;
+ case GX_CTF_B8: return 8;
+ case GX_CTF_RG8: return 4;
+ case GX_CTF_GB8: return 4;
+ case GX_TF_Z8: return 8;
+ case GX_TF_Z16: return 4;
+ case GX_TF_Z24X8: return 4;
+ case GX_CTF_Z4: return 8;
+ case GX_CTF_Z8M: return 8;
+ case GX_CTF_Z8L: return 8;
+ case GX_CTF_Z16L: return 4;
default:
ERROR_LOG(VIDEO, "Unsupported Texture Format (%08x)! (GetBlockWidthInTexels)", format);
return 8;
}
}
-int TexDecoder_GetBlockHeightInTexels(int format)
+int TexDecoder_GetBlockHeightInTexels(u32 format)
{
switch (format)
{
@@ -129,6 +145,22 @@ int TexDecoder_GetBlockHeightInTexels(int format)
case GX_TF_C8: return 4;
case GX_TF_C14X2: return 4;
case GX_TF_CMPR: return 4;
+ case GX_CTF_R4: return 8;
+ case GX_CTF_RA4: return 4;
+ case GX_CTF_RA8: return 2;
+ case GX_CTF_A8: return 4;
+ case GX_CTF_R8: return 4;
+ case GX_CTF_G8: return 4;
+ case GX_CTF_B8: return 4;
+ case GX_CTF_RG8: return 2;
+ case GX_CTF_GB8: return 2;
+ case GX_TF_Z8: return 4;
+ case GX_TF_Z16: return 2;
+ case GX_TF_Z24X8: return 1;
+ case GX_CTF_Z4: return 8;
+ case GX_CTF_Z8M: return 4;
+ case GX_CTF_Z8L: return 4;
+ case GX_CTF_Z16L: return 2;
default:
ERROR_LOG(VIDEO, "Unsupported Texture Format (%08x)! (GetBlockHeightInTexels)", format);
return 4;
diff --git a/Source/Core/VideoCommon/Src/TextureDecoder.h b/Source/Core/VideoCommon/Src/TextureDecoder.h
index 2067595c4d..68f4c56fa6 100644
--- a/Source/Core/VideoCommon/Src/TextureDecoder.h
+++ b/Source/Core/VideoCommon/Src/TextureDecoder.h
@@ -66,8 +66,8 @@ enum TextureFormat
int TexDecoder_GetTexelSizeInNibbles(int format);
int TexDecoder_GetTextureSizeInBytes(int width, int height, int format);
-int TexDecoder_GetBlockWidthInTexels(int format);
-int TexDecoder_GetBlockHeightInTexels(int format);
+int TexDecoder_GetBlockWidthInTexels(u32 format);
+int TexDecoder_GetBlockHeightInTexels(u32 format);
int TexDecoder_GetPaletteSize(int fmt);
enum PC_TexFormat
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureConversionShader.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureConversionShader.cpp
index 06d1a4b306..b66feeeab3 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/TextureConversionShader.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureConversionShader.cpp
@@ -33,65 +33,6 @@ static char text[16384];
namespace TextureConversionShader
{
-u16 GetBlockWidthInTexels(u32 format)
-{
- switch (format) {
- case GX_TF_I4: return 8;
- case GX_TF_I8: return 8;
- case GX_TF_IA4: return 8;
- case GX_TF_IA8: return 4;
- case GX_TF_RGB565: return 4;
- case GX_TF_RGB5A3: return 4;
- case GX_TF_RGBA8: return 4;
- case GX_CTF_R4: return 8;
- case GX_CTF_RA4: return 8;
- case GX_CTF_RA8: return 4;
- case GX_CTF_A8: return 8;
- case GX_CTF_R8: return 8;
- case GX_CTF_G8: return 8;
- case GX_CTF_B8: return 8;
- case GX_CTF_RG8: return 4;
- case GX_CTF_GB8: return 4;
- case GX_TF_Z8: return 8;
- case GX_TF_Z16: return 4;
- case GX_TF_Z24X8: return 4;
- case GX_CTF_Z4: return 8;
- case GX_CTF_Z8M: return 8;
- case GX_CTF_Z8L: return 8;
- case GX_CTF_Z16L: return 4;
- default: return 8;
- }
-}
-
-u16 GetBlockHeightInTexels(u32 format)
-{
- switch (format) {
- case GX_TF_I4: return 8;
- case GX_TF_I8: return 4;
- case GX_TF_IA4: return 4;
- case GX_TF_IA8: return 4;
- case GX_TF_RGB565: return 4;
- case GX_TF_RGB5A3: return 4;
- case GX_TF_RGBA8: return 4;
- case GX_CTF_R4: return 8;
- case GX_CTF_RA4: return 4;
- case GX_CTF_RA8: return 4;
- case GX_CTF_A8: return 4;
- case GX_CTF_R8: return 4;
- case GX_CTF_G8: return 4;
- case GX_CTF_B8: return 4;
- case GX_CTF_RG8: return 4;
- case GX_CTF_GB8: return 4;
- case GX_TF_Z8: return 4;
- case GX_TF_Z16: return 4;
- case GX_TF_Z24X8: return 4;
- case GX_CTF_Z4: return 8;
- case GX_CTF_Z8M: return 4;
- case GX_CTF_Z8L: return 4;
- case GX_CTF_Z16L: return 4;
- default: return 8;
- }
-}
u16 GetEncodedSampleCount(u32 format)
{
@@ -130,8 +71,8 @@ void WriteSwizzler(char*& p, u32 format)
WRITE(p, "uniform float4 blkDims : register(c%d);\n", C_COLORMATRIX);
WRITE(p, "uniform float4 textureDims : register(c%d);\n", C_COLORMATRIX + 1);
- float blkW = (float)GetBlockWidthInTexels(format);
- float blkH = (float)GetBlockHeightInTexels(format);
+ float blkW = (float)TexDecoder_GetBlockWidthInTexels(format);
+ float blkH = (float)TexDecoder_GetBlockHeightInTexels(format);
float samples = (float)GetEncodedSampleCount(format);
WRITE(p,
@@ -172,8 +113,8 @@ void Write32BitSwizzler(char*& p, u32 format)
WRITE(p, "uniform float4 blkDims : register(c%d);\n", C_COLORMATRIX);
WRITE(p, "uniform float4 textureDims : register(c%d);\n", C_COLORMATRIX + 1);
- float blkW = (float)GetBlockWidthInTexels(format);
- float blkH = (float)GetBlockHeightInTexels(format);
+ float blkW = (float)TexDecoder_GetBlockWidthInTexels(format);
+ float blkH = (float)TexDecoder_GetBlockHeightInTexels(format);
// 32 bit textures (RGBA8 and Z24) are store in 2 cache line increments
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureConversionShader.h b/Source/Plugins/Plugin_VideoOGL/Src/TextureConversionShader.h
index 5f365f6b7b..5874c16671 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/TextureConversionShader.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureConversionShader.h
@@ -24,9 +24,6 @@
namespace TextureConversionShader
{
-
-u16 GetBlockWidthInTexels(u32 format);
-u16 GetBlockHeightInTexels(u32 format);
u16 GetEncodedSampleCount(u32 format);
const char *GenerateEncodingShader(u32 format);
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp
index 5a37987b2e..2c00b30d8c 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp
@@ -270,8 +270,8 @@ void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyf
height /= 2;
}
- u16 blkW = TextureConversionShader::GetBlockWidthInTexels(format) - 1;
- u16 blkH = TextureConversionShader::GetBlockHeightInTexels(format) - 1;
+ u16 blkW = TexDecoder_GetBlockWidthInTexels(format) - 1;
+ u16 blkH = TexDecoder_GetBlockHeightInTexels(format) - 1;
u16 samples = TextureConversionShader::GetEncodedSampleCount(format);
// only copy on cache line boundaries
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp
index 8538177636..4cc66480b4 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp
+++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.cpp
@@ -226,7 +226,7 @@ void TextureMngr::InvalidateRange(u32 start_address, u32 size) {
}
}
-TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width, int height, int tex_format, int tlutaddr, int tlutfmt)
+TextureMngr::TCacheEntry* TextureMngr::Load(int texstage, u32 address, int width, int height, u32 tex_format, int tlutaddr, int tlutfmt)
{
// notes (about "UNsafe texture cache"):
// Have to be removed soon.
diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.h b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.h
index 4ca22d7d54..fa68bf5cc7 100644
--- a/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.h
+++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureMngr.h
@@ -70,7 +70,7 @@ public:
static void Invalidate(bool shutdown);
static void InvalidateRange(u32 start_address, u32 size);
- static TCacheEntry* Load(int texstage, u32 address, int width, int height, int format, int tlutaddr, int tlutfmt);
+ static TCacheEntry* Load(int texstage, u32 address, int width, int height, u32 format, int tlutaddr, int tlutfmt);
static void CopyRenderTargetToTexture(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, bool bScaleByHalf, const EFBRectangle &source);
static void DisableStage(int stage); // sets active texture