D3D: Fix 8-bit signed normals. Fixes lighting problems in Super Smash Bros Melee. misc tiny things

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4265 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2009-09-13 21:18:04 +00:00
parent 2dc3f2c762
commit c7431401be
13 changed files with 186 additions and 28 deletions

View File

@ -32,16 +32,12 @@
using namespace BPFunctions; using namespace BPFunctions;
// FIXME: Hangs load-state, but should fix graphic-heavy games state loading
//Common::CriticalSection s_bpCritical;
void BPInit() void BPInit()
{ {
memset(&bpmem, 0, sizeof(bpmem)); memset(&bpmem, 0, sizeof(bpmem));
bpmem.bpMask = 0xFFFFFF; bpmem.bpMask = 0xFFFFFF;
} }
void RenderToXFB(const BPCmd &bp, const EFBRectangle &rc, float yScale, float xfbLines, u32 xfbAddr, const u32 dstWidth, const u32 dstHeight) void RenderToXFB(const BPCmd &bp, const EFBRectangle &rc, float yScale, float xfbLines, u32 xfbAddr, const u32 dstWidth, const u32 dstHeight)
{ {
Renderer::RenderToXFB(xfbAddr, dstWidth, dstHeight, rc); Renderer::RenderToXFB(xfbAddr, dstWidth, dstHeight, rc);
@ -241,9 +237,11 @@ void BPWritten(const BPCmd& bp)
(u32)xfbLines); (u32)xfbLines);
} }
// Clear the picture after it's done and submitted, to prepare for the next picture // Clear the rectangular region after copying it.
if (PE_copy.clear) if (PE_copy.clear)
{
ClearScreen(bp, rc); ClearScreen(bp, rc);
}
RestoreRenderState(bp); RestoreRenderState(bp);

View File

@ -45,6 +45,11 @@ inline u8 DataReadU8()
return *g_pVideoData++; return *g_pVideoData++;
} }
inline s8 DataReadS8()
{
return (s8)(*g_pVideoData++);
}
inline u16 DataReadU16() inline u16 DataReadU16()
{ {
u16 tmp = Common::swap16(*(u16*)g_pVideoData); u16 tmp = Common::swap16(*(u16*)g_pVideoData);

View File

@ -57,7 +57,8 @@ enum {
#define LOADERDECL __cdecl #define LOADERDECL __cdecl
typedef void (LOADERDECL *TPipelineFunction)(); typedef void (LOADERDECL *TPipelineFunction)();
enum VarType { enum VarType
{
VAR_BYTE, VAR_BYTE,
VAR_UNSIGNED_BYTE, VAR_UNSIGNED_BYTE,
VAR_SHORT, VAR_SHORT,

View File

@ -19,6 +19,7 @@
#include "Common.h" #include "Common.h"
#include "VideoCommon.h" #include "VideoCommon.h"
#include "VideoConfig.h"
#include "Profiler.h" #include "Profiler.h"
#include "MemoryUtil.h" #include "MemoryUtil.h"
#include "StringUtil.h" #include "StringUtil.h"
@ -310,7 +311,7 @@ void VertexLoader::CompileVertexTranslator()
vtx_decl.num_normals = 0; vtx_decl.num_normals = 0;
if (m_VtxDesc.Normal != NOT_PRESENT) { if (m_VtxDesc.Normal != NOT_PRESENT) {
m_VertexSize += VertexLoader_Normal::GetSize(m_VtxDesc.Normal, m_VtxAttr.NormalFormat, m_VtxAttr.NormalElements, m_VtxAttr.NormalIndex3); m_VertexSize += VertexLoader_Normal::GetSize(m_VtxDesc.Normal, m_VtxAttr.NormalFormat, m_VtxAttr.NormalElements, m_VtxAttr.NormalIndex3);
TPipelineFunction pFunc = VertexLoader_Normal::GetFunction(m_VtxDesc.Normal, m_VtxAttr.NormalFormat, m_VtxAttr.NormalElements, m_VtxAttr.NormalIndex3); TPipelineFunction pFunc = VertexLoader_Normal::GetFunction(m_VtxDesc.Normal, m_VtxAttr.NormalFormat, m_VtxAttr.NormalElements, m_VtxAttr.NormalIndex3, g_Config.bAllowSignedBytes);
if (pFunc == 0) if (pFunc == 0)
{ {
char temp[256]; char temp[256];
@ -326,17 +327,25 @@ void VertexLoader::CompileVertexTranslator()
switch (vtx_attr.NormalFormat) { switch (vtx_attr.NormalFormat) {
case FORMAT_UBYTE: case FORMAT_UBYTE:
case FORMAT_BYTE: case FORMAT_BYTE:
{
vtx_decl.normal_gl_type = VAR_BYTE; vtx_decl.normal_gl_type = VAR_BYTE;
int native_size = 4;
if (vtx_attr.NormalFormat == FORMAT_BYTE && !g_Config.bAllowSignedBytes)
{
vtx_decl.normal_gl_type = VAR_SHORT;
native_size = 8;
}
vtx_decl.normal_gl_size = 4; vtx_decl.normal_gl_size = 4;
vtx_decl.normal_offset[0] = nat_offset; vtx_decl.normal_offset[0] = nat_offset;
nat_offset += 4; nat_offset += native_size;
if (vtx_attr.NormalElements) { if (vtx_attr.NormalElements) {
vtx_decl.normal_offset[1] = nat_offset; vtx_decl.normal_offset[1] = nat_offset;
nat_offset += 4; nat_offset += native_size;
vtx_decl.normal_offset[2] = nat_offset; vtx_decl.normal_offset[2] = nat_offset;
nat_offset += 4; nat_offset += native_size;
} }
break; break;
}
case FORMAT_USHORT: case FORMAT_USHORT:
case FORMAT_SHORT: case FORMAT_SHORT:
vtx_decl.normal_gl_type = VAR_SHORT; vtx_decl.normal_gl_type = VAR_SHORT;

View File

@ -26,6 +26,7 @@
#define LOG_NORMF() // PRIM_LOG("norm: %f %f %f, ", ((float*)VertexManager::s_pCurBufferPointer)[-3], ((float*)VertexManager::s_pCurBufferPointer)[-2], ((float*)VertexManager::s_pCurBufferPointer)[-1]); #define LOG_NORMF() // PRIM_LOG("norm: %f %f %f, ", ((float*)VertexManager::s_pCurBufferPointer)[-3], ((float*)VertexManager::s_pCurBufferPointer)[-2], ((float*)VertexManager::s_pCurBufferPointer)[-1]);
VertexLoader_Normal::Set VertexLoader_Normal::m_Table[NUM_NRM_TYPE][NUM_NRM_INDICES][NUM_NRM_ELEMENTS][NUM_NRM_FORMAT]; VertexLoader_Normal::Set VertexLoader_Normal::m_Table[NUM_NRM_TYPE][NUM_NRM_INDICES][NUM_NRM_ELEMENTS][NUM_NRM_FORMAT];
VertexLoader_Normal::Set VertexLoader_Normal::m_TableExpand16[NUM_NRM_TYPE][NUM_NRM_INDICES][NUM_NRM_ELEMENTS][NUM_NRM_FORMAT];
void VertexLoader_Normal::Init(void) void VertexLoader_Normal::Init(void)
{ {
@ -95,6 +96,20 @@ void VertexLoader_Normal::Init(void)
m_Table[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_USHORT] = Set(6, Normal_Index16_Short3_Indices3); //HACK m_Table[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_USHORT] = Set(6, Normal_Index16_Short3_Indices3); //HACK
m_Table[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_SHORT] = Set(6, Normal_Index16_Short3_Indices3); m_Table[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_SHORT] = Set(6, Normal_Index16_Short3_Indices3);
m_Table[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_FLOAT] = Set(6, Normal_Index16_Float3_Indices3); m_Table[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_FLOAT] = Set(6, Normal_Index16_Float3_Indices3);
// Work around D3D's lack of signed bytes
m_TableExpand16[NRM_DIRECT] [NRM_INDICES1][NRM_NBT] [FORMAT_BYTE] = Set(3, Normal_DirectByte_Expand16);
m_TableExpand16[NRM_DIRECT] [NRM_INDICES1][NRM_NBT3][FORMAT_BYTE] = Set(9, Normal_DirectByte3_Expand16);
m_TableExpand16[NRM_DIRECT] [NRM_INDICES3][NRM_NBT] [FORMAT_BYTE] = Set(3, Normal_DirectByte_Expand16);
m_TableExpand16[NRM_DIRECT] [NRM_INDICES3][NRM_NBT3][FORMAT_BYTE] = Set(9, Normal_DirectByte3_Expand16);
m_TableExpand16[NRM_INDEX8] [NRM_INDICES1][NRM_NBT] [FORMAT_BYTE] = Set(1, Normal_Index8_Byte_Expand16);
m_TableExpand16[NRM_INDEX8] [NRM_INDICES1][NRM_NBT3][FORMAT_BYTE] = Set(1, Normal_Index8_Byte3_Indices1_Expand16);
m_TableExpand16[NRM_INDEX8] [NRM_INDICES3][NRM_NBT] [FORMAT_BYTE] = Set(1, Normal_Index8_Byte_Expand16);
m_TableExpand16[NRM_INDEX8] [NRM_INDICES3][NRM_NBT3][FORMAT_BYTE] = Set(3, Normal_Index8_Byte3_Indices3_Expand16);
m_TableExpand16[NRM_INDEX16][NRM_INDICES1][NRM_NBT] [FORMAT_BYTE] = Set(2, Normal_Index16_Byte_Expand16);
m_TableExpand16[NRM_INDEX16][NRM_INDICES1][NRM_NBT3][FORMAT_BYTE] = Set(2, Normal_Index16_Byte3_Indices1_Expand16);
m_TableExpand16[NRM_INDEX16][NRM_INDICES3][NRM_NBT] [FORMAT_BYTE] = Set(2, Normal_Index16_Byte_Expand16);
m_TableExpand16[NRM_INDEX16][NRM_INDICES3][NRM_NBT3][FORMAT_BYTE] = Set(6, Normal_Index16_Byte3_Indices3_Expand16);
} }
unsigned int VertexLoader_Normal::GetSize(unsigned int _type, unsigned int _format, unsigned int _elements, unsigned int _index3) unsigned int VertexLoader_Normal::GetSize(unsigned int _type, unsigned int _format, unsigned int _elements, unsigned int _index3)
@ -102,8 +117,13 @@ unsigned int VertexLoader_Normal::GetSize(unsigned int _type, unsigned int _form
return m_Table[_type][_index3][_elements][_format].gc_size; return m_Table[_type][_index3][_elements][_format].gc_size;
} }
TPipelineFunction VertexLoader_Normal::GetFunction(unsigned int _type, unsigned int _format, unsigned int _elements, unsigned int _index3) TPipelineFunction VertexLoader_Normal::GetFunction(unsigned int _type, unsigned int _format, unsigned int _elements, unsigned int _index3, bool allow_signed_bytes)
{ {
if (!allow_signed_bytes)
{
TPipelineFunction pFunc = m_TableExpand16[_type][_index3][_elements][_format].function;
if (pFunc) return pFunc;
}
TPipelineFunction pFunc = m_Table[_type][_index3][_elements][_format].function; TPipelineFunction pFunc = m_Table[_type][_index3][_elements][_format].function;
return pFunc; return pFunc;
} }
@ -118,7 +138,16 @@ void LOADERDECL VertexLoader_Normal::Normal_DirectByte()
*VertexManager::s_pCurBufferPointer++ = DataReadU8(); *VertexManager::s_pCurBufferPointer++ = DataReadU8();
*VertexManager::s_pCurBufferPointer++ = 0; *VertexManager::s_pCurBufferPointer++ = 0;
LOG_NORM8(); LOG_NORM8();
// ((float*)VertexManager::s_pCurBufferPointer)[0] = ((float)(signed char)DataReadU8()+0.5f) / 127.5f; }
void LOADERDECL VertexLoader_Normal::Normal_DirectByte_Expand16()
{
((s16*)VertexManager::s_pCurBufferPointer)[0] = DataReadS8() << 8;
((s16*)VertexManager::s_pCurBufferPointer)[1] = DataReadS8() << 8;
((s16*)VertexManager::s_pCurBufferPointer)[2] = DataReadS8() << 8;
((s16*)VertexManager::s_pCurBufferPointer)[3] = 0;
VertexManager::s_pCurBufferPointer += 8;
LOG_NORM16();
} }
void LOADERDECL VertexLoader_Normal::Normal_DirectShort() void LOADERDECL VertexLoader_Normal::Normal_DirectShort()
@ -129,9 +158,6 @@ void LOADERDECL VertexLoader_Normal::Normal_DirectShort()
((u16*)VertexManager::s_pCurBufferPointer)[3] = 0; ((u16*)VertexManager::s_pCurBufferPointer)[3] = 0;
VertexManager::s_pCurBufferPointer += 8; VertexManager::s_pCurBufferPointer += 8;
LOG_NORM16() LOG_NORM16()
// ((float*)VertexManager::s_pCurBufferPointer)[0] = ((float)(signed short)DataReadU16()+0.5f) / 32767.5f;
// ((float*)VertexManager::s_pCurBufferPointer)[1] = ((float)(signed short)DataReadU16()+0.5f) / 32767.5f;
// ((float*)VertexManager::s_pCurBufferPointer)[2] = ((float)(signed short)DataReadU16()+0.5f) / 32767.5f;
} }
void LOADERDECL VertexLoader_Normal::Normal_DirectFloat() void LOADERDECL VertexLoader_Normal::Normal_DirectFloat()
@ -155,6 +181,19 @@ void LOADERDECL VertexLoader_Normal::Normal_DirectByte3()
} }
} }
void LOADERDECL VertexLoader_Normal::Normal_DirectByte3_Expand16()
{
for (int i = 0; i < 3; i++)
{
((u16*)VertexManager::s_pCurBufferPointer)[0] = DataReadS8() << 8;
((u16*)VertexManager::s_pCurBufferPointer)[1] = DataReadS8() << 8;
((u16*)VertexManager::s_pCurBufferPointer)[2] = DataReadS8() << 8;
((u16*)VertexManager::s_pCurBufferPointer)[3] = 0;
VertexManager::s_pCurBufferPointer += 8;
LOG_NORM16();
}
}
void LOADERDECL VertexLoader_Normal::Normal_DirectShort3() void LOADERDECL VertexLoader_Normal::Normal_DirectShort3()
{ {
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
@ -191,13 +230,21 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Byte()
*VertexManager::s_pCurBufferPointer++ = pData[1]; *VertexManager::s_pCurBufferPointer++ = pData[1];
*VertexManager::s_pCurBufferPointer++ = pData[2]; *VertexManager::s_pCurBufferPointer++ = pData[2];
*VertexManager::s_pCurBufferPointer++ = 0; *VertexManager::s_pCurBufferPointer++ = 0;
// ((float*)VertexManager::s_pCurBufferPointer)[0] = ((float)(signed char)Memory_Read_U8(iAddress)+0.5f) / 127.5f;
// ((float*)VertexManager::s_pCurBufferPointer)[1] = ((float)(signed char)Memory_Read_U8(iAddress+1)+0.5f) / 127.5f;
// ((float*)VertexManager::s_pCurBufferPointer)[2] = ((float)(signed char)Memory_Read_U8(iAddress+2)+0.5f) / 127.5f;
// VertexManager::s_pCurBufferPointer += 12;
LOG_NORM8(); LOG_NORM8();
} }
void LOADERDECL VertexLoader_Normal::Normal_Index8_Byte_Expand16()
{
u8 Index = DataReadU8();
const s8* pData = (const s8 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]));
((s16*)VertexManager::s_pCurBufferPointer)[0] = pData[0] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[1] = pData[1] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[2] = pData[2] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[3] = 0;
VertexManager::s_pCurBufferPointer += 8;
LOG_NORM16();
}
void LOADERDECL VertexLoader_Normal::Normal_Index8_Short() void LOADERDECL VertexLoader_Normal::Normal_Index8_Short()
{ {
u8 Index = DataReadU8(); u8 Index = DataReadU8();
@ -235,6 +282,21 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Byte3_Indices1()
} }
} }
void LOADERDECL VertexLoader_Normal::Normal_Index8_Byte3_Indices1_Expand16()
{
u8 Index = DataReadU8();
const s8* pData = (const s8*)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]));
for (int i = 0; i < 3; i++)
{
((s16*)VertexManager::s_pCurBufferPointer)[0] = pData[3 * i] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[1] = pData[3 * i + 1] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[2] = pData[3 * i + 2] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[3] = 0;
VertexManager::s_pCurBufferPointer += 8;
LOG_NORM16();
}
}
void LOADERDECL VertexLoader_Normal::Normal_Index8_Short3_Indices1() void LOADERDECL VertexLoader_Normal::Normal_Index8_Short3_Indices1()
{ {
u8 Index = DataReadU8(); u8 Index = DataReadU8();
@ -278,6 +340,21 @@ void LOADERDECL VertexLoader_Normal::Normal_Index8_Byte3_Indices3()
} }
} }
void LOADERDECL VertexLoader_Normal::Normal_Index8_Byte3_Indices3_Expand16()
{
for (int i = 0; i < 3; i++)
{
u8 Index = DataReadU8();
const s8* pData = (const s8 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i);
((s16*)VertexManager::s_pCurBufferPointer)[0] = pData[0] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[1] = pData[1] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[2] = pData[2] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[3] = 0;
VertexManager::s_pCurBufferPointer += 8;
LOG_NORM16();
}
}
void LOADERDECL VertexLoader_Normal::Normal_Index8_Short3_Indices3() void LOADERDECL VertexLoader_Normal::Normal_Index8_Short3_Indices3()
{ {
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
@ -318,10 +395,22 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Byte()
*VertexManager::s_pCurBufferPointer++ = pData[0]; *VertexManager::s_pCurBufferPointer++ = pData[0];
*VertexManager::s_pCurBufferPointer++ = pData[1]; *VertexManager::s_pCurBufferPointer++ = pData[1];
*VertexManager::s_pCurBufferPointer++ = pData[2]; *VertexManager::s_pCurBufferPointer++ = pData[2];
VertexManager::s_pCurBufferPointer++; *VertexManager::s_pCurBufferPointer++ = 0;
LOG_NORM8(); LOG_NORM8();
} }
void LOADERDECL VertexLoader_Normal::Normal_Index16_Byte_Expand16()
{
u16 Index = DataReadU16();
const s8* pData = (const s8 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]));
((s16*)VertexManager::s_pCurBufferPointer)[0] = pData[0] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[1] = pData[1] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[2] = pData[2] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[3] = 0;
VertexManager::s_pCurBufferPointer += 8;
LOG_NORM16();
}
void LOADERDECL VertexLoader_Normal::Normal_Index16_Short() void LOADERDECL VertexLoader_Normal::Normal_Index16_Short()
{ {
u16 Index = DataReadU16(); u16 Index = DataReadU16();
@ -329,6 +418,7 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Short()
((u16*)VertexManager::s_pCurBufferPointer)[0] = Common::swap16(pData[0]); ((u16*)VertexManager::s_pCurBufferPointer)[0] = Common::swap16(pData[0]);
((u16*)VertexManager::s_pCurBufferPointer)[1] = Common::swap16(pData[1]); ((u16*)VertexManager::s_pCurBufferPointer)[1] = Common::swap16(pData[1]);
((u16*)VertexManager::s_pCurBufferPointer)[2] = Common::swap16(pData[2]); ((u16*)VertexManager::s_pCurBufferPointer)[2] = Common::swap16(pData[2]);
((u16*)VertexManager::s_pCurBufferPointer)[3] = 0;
VertexManager::s_pCurBufferPointer += 8; VertexManager::s_pCurBufferPointer += 8;
LOG_NORM16(); LOG_NORM16();
} }
@ -358,6 +448,22 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Byte3_Indices1()
} }
} }
void LOADERDECL VertexLoader_Normal::Normal_Index16_Byte3_Indices1_Expand16()
{
u16 Index = DataReadU16();
const s8* pData = (const s8 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]));
for (int i = 0; i < 3; i++)
{
((s16*)VertexManager::s_pCurBufferPointer)[0] = pData[3 * i] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[1] = pData[3 * i + 1] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[2] = pData[3 * i + 2] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[3] = 0;
VertexManager::s_pCurBufferPointer += 8;
LOG_NORM16();
}
}
void LOADERDECL VertexLoader_Normal::Normal_Index16_Short3_Indices1() void LOADERDECL VertexLoader_Normal::Normal_Index16_Short3_Indices1()
{ {
u16 Index = DataReadU16(); u16 Index = DataReadU16();
@ -403,6 +509,21 @@ void LOADERDECL VertexLoader_Normal::Normal_Index16_Byte3_Indices3()
} }
} }
void LOADERDECL VertexLoader_Normal::Normal_Index16_Byte3_Indices3_Expand16()
{
for (int i = 0; i < 3; i++)
{
u16 Index = DataReadU16();
const s8* pData = (const s8 *)(cached_arraybases[ARRAY_NORMAL] + (Index * arraystrides[ARRAY_NORMAL]) + 2*3*i);
((s16*)VertexManager::s_pCurBufferPointer)[0] = pData[0] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[1] = pData[1] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[2] = pData[2] << 8;
((s16*)VertexManager::s_pCurBufferPointer)[3] = 0;
VertexManager::s_pCurBufferPointer += 8;
LOG_NORM16();
}
}
void LOADERDECL VertexLoader_Normal::Normal_Index16_Short3_Indices3() void LOADERDECL VertexLoader_Normal::Normal_Index16_Short3_Indices3()
{ {
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)

View File

@ -31,7 +31,7 @@ public:
static unsigned int GetSize(unsigned int _type, unsigned int _format, unsigned int _elements, unsigned int _index3); static unsigned int GetSize(unsigned int _type, unsigned int _format, unsigned int _elements, unsigned int _index3);
// GetFunction // GetFunction
static TPipelineFunction GetFunction(unsigned int _type, unsigned int _format, unsigned int _elements, unsigned int _index3); static TPipelineFunction GetFunction(unsigned int _type, unsigned int _format, unsigned int _elements, unsigned int _index3, bool allow_signed_bytes);
private: private:
enum ENormalType enum ENormalType
@ -77,33 +77,44 @@ private:
static Set m_Table[NUM_NRM_TYPE][NUM_NRM_INDICES][NUM_NRM_ELEMENTS][NUM_NRM_FORMAT]; static Set m_Table[NUM_NRM_TYPE][NUM_NRM_INDICES][NUM_NRM_ELEMENTS][NUM_NRM_FORMAT];
// You can't pass signed bytes to D3D9 so we special case them to expand to signed shorts
static Set m_TableExpand16[NUM_NRM_TYPE][NUM_NRM_INDICES][NUM_NRM_ELEMENTS][NUM_NRM_FORMAT];
// direct // direct
static void LOADERDECL Normal_DirectByte(); static void LOADERDECL Normal_DirectByte();
static void LOADERDECL Normal_DirectByte_Expand16();
static void LOADERDECL Normal_DirectShort(); static void LOADERDECL Normal_DirectShort();
static void LOADERDECL Normal_DirectFloat(); static void LOADERDECL Normal_DirectFloat();
static void LOADERDECL Normal_DirectByte3(); static void LOADERDECL Normal_DirectByte3();
static void LOADERDECL Normal_DirectByte3_Expand16();
static void LOADERDECL Normal_DirectShort3(); static void LOADERDECL Normal_DirectShort3();
static void LOADERDECL Normal_DirectFloat3(); static void LOADERDECL Normal_DirectFloat3();
// index8 // index8
static void LOADERDECL Normal_Index8_Byte(); static void LOADERDECL Normal_Index8_Byte();
static void LOADERDECL Normal_Index8_Byte_Expand16();
static void LOADERDECL Normal_Index8_Short(); static void LOADERDECL Normal_Index8_Short();
static void LOADERDECL Normal_Index8_Float(); static void LOADERDECL Normal_Index8_Float();
static void LOADERDECL Normal_Index8_Byte3_Indices1(); static void LOADERDECL Normal_Index8_Byte3_Indices1();
static void LOADERDECL Normal_Index8_Byte3_Indices1_Expand16();
static void LOADERDECL Normal_Index8_Short3_Indices1(); static void LOADERDECL Normal_Index8_Short3_Indices1();
static void LOADERDECL Normal_Index8_Float3_Indices1(); static void LOADERDECL Normal_Index8_Float3_Indices1();
static void LOADERDECL Normal_Index8_Byte3_Indices3(); static void LOADERDECL Normal_Index8_Byte3_Indices3();
static void LOADERDECL Normal_Index8_Byte3_Indices3_Expand16();
static void LOADERDECL Normal_Index8_Short3_Indices3(); static void LOADERDECL Normal_Index8_Short3_Indices3();
static void LOADERDECL Normal_Index8_Float3_Indices3(); static void LOADERDECL Normal_Index8_Float3_Indices3();
// index16 // index16
static void LOADERDECL Normal_Index16_Byte(); static void LOADERDECL Normal_Index16_Byte();
static void LOADERDECL Normal_Index16_Byte_Expand16();
static void LOADERDECL Normal_Index16_Short(); static void LOADERDECL Normal_Index16_Short();
static void LOADERDECL Normal_Index16_Float(); static void LOADERDECL Normal_Index16_Float();
static void LOADERDECL Normal_Index16_Byte3_Indices1(); static void LOADERDECL Normal_Index16_Byte3_Indices1();
static void LOADERDECL Normal_Index16_Byte3_Indices1_Expand16();
static void LOADERDECL Normal_Index16_Short3_Indices1(); static void LOADERDECL Normal_Index16_Short3_Indices1();
static void LOADERDECL Normal_Index16_Float3_Indices1(); static void LOADERDECL Normal_Index16_Float3_Indices1();
static void LOADERDECL Normal_Index16_Byte3_Indices3(); static void LOADERDECL Normal_Index16_Byte3_Indices3();
static void LOADERDECL Normal_Index16_Byte3_Indices3_Expand16();
static void LOADERDECL Normal_Index16_Short3_Indices3(); static void LOADERDECL Normal_Index16_Short3_Indices3();
static void LOADERDECL Normal_Index16_Float3_Indices3(); static void LOADERDECL Normal_Index16_Float3_Indices3();
}; };

View File

@ -142,4 +142,6 @@ struct TargetRectangle : public MathUtil::Rectangle<int>
#define LOG_VTX() #define LOG_VTX()
bool IsD3D();
#endif // _VIDEOCOMMON_H #endif // _VIDEOCOMMON_H

View File

@ -33,6 +33,7 @@ void UpdateActiveConfig()
VideoConfig::VideoConfig() VideoConfig::VideoConfig()
{ {
bRunning = false; bRunning = false;
bAllowSignedBytes = !IsD3D();
} }
void VideoConfig::Load(const char *ini_file) void VideoConfig::Load(const char *ini_file)

View File

@ -131,6 +131,9 @@ struct VideoConfig
// With this enabled, the plugin renders directly to the backbuffer. Many features are // With this enabled, the plugin renders directly to the backbuffer. Many features are
// disabled but it might be faster on really old GPUs. // disabled but it might be faster on really old GPUs.
bool bSimpleFB; bool bSimpleFB;
// Static config per API
bool bAllowSignedBytes;
}; };
extern VideoConfig g_Config; extern VideoConfig g_Config;

View File

@ -68,8 +68,9 @@ D3DDECLTYPE VarToD3D(VarType t, int size)
static const D3DDECLTYPE lookup3[5] = { static const D3DDECLTYPE lookup3[5] = {
D3DDECLTYPE_UNUSED, D3DDECLTYPE_UNUSED, D3DDECLTYPE_UNUSED, D3DDECLTYPE_UNUSED, D3DDECLTYPE_FLOAT3, D3DDECLTYPE_UNUSED, D3DDECLTYPE_UNUSED, D3DDECLTYPE_UNUSED, D3DDECLTYPE_UNUSED, D3DDECLTYPE_FLOAT3,
}; };
// Sadly, D3D9 has no SBYTE4N. D3D10 does, though.
static const D3DDECLTYPE lookup4[5] = { static const D3DDECLTYPE lookup4[5] = {
D3DDECLTYPE_UBYTE4N, D3DDECLTYPE_UBYTE4N, D3DDECLTYPE_SHORT4N, D3DDECLTYPE_USHORT4N, D3DDECLTYPE_FLOAT4, D3DDECLTYPE_UNUSED, D3DDECLTYPE_UBYTE4N, D3DDECLTYPE_SHORT4N, D3DDECLTYPE_USHORT4N, D3DDECLTYPE_FLOAT4,
}; };
D3DDECLTYPE retval = D3DDECLTYPE_UNUSED; D3DDECLTYPE retval = D3DDECLTYPE_UNUSED;
switch (size) { switch (size) {
@ -84,9 +85,6 @@ D3DDECLTYPE VarToD3D(VarType t, int size)
return retval; return retval;
} }
// TODO: Ban signed bytes as normals - not likely that ATI supports them natively.
// We probably won't see much of a speed loss, and any speed loss will be regained anyway
// when we finally compile display lists.
void D3DVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl) void D3DVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl)
{ {
vertex_stride = _vtx_decl.stride; vertex_stride = _vtx_decl.stride;

View File

@ -61,6 +61,7 @@ static bool s_AVIDumping;
#define NUMWNDRES 6 #define NUMWNDRES 6
extern int g_Res[NUMWNDRES][2]; extern int g_Res[NUMWNDRES][2];
char st[32768];
void SetupDeviceObjects() void SetupDeviceObjects()
{ {
@ -266,15 +267,13 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect
D3D::GetBackBufferSurface(), dst_rect.AsRECT(), D3D::GetBackBufferSurface(), dst_rect.AsRECT(),
D3DTEXF_LINEAR); D3DTEXF_LINEAR);
char st[8192];
// Finish up the current frame, print some stats // Finish up the current frame, print some stats
if (g_ActiveConfig.bOverlayStats) if (g_ActiveConfig.bOverlayStats)
{ {
Statistics::ToString(st); Statistics::ToString(st);
D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,st,false); D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,st,false);
} }
else if (g_ActiveConfig.bOverlayProjStats)
if (g_ActiveConfig.bOverlayProjStats)
{ {
Statistics::ToStringProj(st); Statistics::ToStringProj(st);
D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,st,false); D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,st,false);

View File

@ -72,6 +72,11 @@ bool HandleDisplayList(u32 address, u32 size)
return false; return false;
} }
bool IsD3D()
{
return true;
}
// This is used for the functions right below here which use wxwidgets // This is used for the functions right below here which use wxwidgets
#if defined(HAVE_WX) && HAVE_WX #if defined(HAVE_WX) && HAVE_WX
#ifdef _WIN32 #ifdef _WIN32

View File

@ -107,6 +107,11 @@ static u32 s_swapRequested = FALSE;
static u32 s_efbAccessRequested = FALSE; static u32 s_efbAccessRequested = FALSE;
static bool ForceSwap = true; static bool ForceSwap = true;
bool IsD3D()
{
return false;
}
void GetDllInfo (PLUGIN_INFO* _PluginInfo) void GetDllInfo (PLUGIN_INFO* _PluginInfo)
{ {
_PluginInfo->Version = 0x0100; _PluginInfo->Version = 0x0100;