From c7431401be5da8f41607e8902961820c316fb123 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Sun, 13 Sep 2009 21:18:04 +0000 Subject: [PATCH] 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 --- Source/Core/VideoCommon/Src/BPStructs.cpp | 8 +- Source/Core/VideoCommon/Src/DataReader.h | 5 + .../Core/VideoCommon/Src/NativeVertexFormat.h | 3 +- Source/Core/VideoCommon/Src/VertexLoader.cpp | 17 ++- .../VideoCommon/Src/VertexLoader_Normal.cpp | 141 ++++++++++++++++-- .../VideoCommon/Src/VertexLoader_Normal.h | 13 +- Source/Core/VideoCommon/Src/VideoCommon.h | 2 + Source/Core/VideoCommon/Src/VideoConfig.cpp | 1 + Source/Core/VideoCommon/Src/VideoConfig.h | 3 + .../Src/NativeVertexFormat.cpp | 6 +- Source/Plugins/Plugin_VideoDX9/Src/Render.cpp | 5 +- Source/Plugins/Plugin_VideoDX9/Src/main.cpp | 5 + Source/Plugins/Plugin_VideoOGL/Src/main.cpp | 5 + 13 files changed, 186 insertions(+), 28 deletions(-) diff --git a/Source/Core/VideoCommon/Src/BPStructs.cpp b/Source/Core/VideoCommon/Src/BPStructs.cpp index 9c031f0a71..50c2d110e3 100644 --- a/Source/Core/VideoCommon/Src/BPStructs.cpp +++ b/Source/Core/VideoCommon/Src/BPStructs.cpp @@ -32,16 +32,12 @@ using namespace BPFunctions; -// FIXME: Hangs load-state, but should fix graphic-heavy games state loading -//Common::CriticalSection s_bpCritical; - void BPInit() { memset(&bpmem, 0, sizeof(bpmem)); bpmem.bpMask = 0xFFFFFF; } - 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); @@ -241,9 +237,11 @@ void BPWritten(const BPCmd& bp) (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) + { ClearScreen(bp, rc); + } RestoreRenderState(bp); diff --git a/Source/Core/VideoCommon/Src/DataReader.h b/Source/Core/VideoCommon/Src/DataReader.h index 915bd8d68e..071e1169db 100644 --- a/Source/Core/VideoCommon/Src/DataReader.h +++ b/Source/Core/VideoCommon/Src/DataReader.h @@ -45,6 +45,11 @@ inline u8 DataReadU8() return *g_pVideoData++; } +inline s8 DataReadS8() +{ + return (s8)(*g_pVideoData++); +} + inline u16 DataReadU16() { u16 tmp = Common::swap16(*(u16*)g_pVideoData); diff --git a/Source/Core/VideoCommon/Src/NativeVertexFormat.h b/Source/Core/VideoCommon/Src/NativeVertexFormat.h index 50100fc126..499a1b451d 100644 --- a/Source/Core/VideoCommon/Src/NativeVertexFormat.h +++ b/Source/Core/VideoCommon/Src/NativeVertexFormat.h @@ -57,7 +57,8 @@ enum { #define LOADERDECL __cdecl typedef void (LOADERDECL *TPipelineFunction)(); -enum VarType { +enum VarType +{ VAR_BYTE, VAR_UNSIGNED_BYTE, VAR_SHORT, diff --git a/Source/Core/VideoCommon/Src/VertexLoader.cpp b/Source/Core/VideoCommon/Src/VertexLoader.cpp index 9fe3dc8768..9b61dfa53f 100644 --- a/Source/Core/VideoCommon/Src/VertexLoader.cpp +++ b/Source/Core/VideoCommon/Src/VertexLoader.cpp @@ -19,6 +19,7 @@ #include "Common.h" #include "VideoCommon.h" +#include "VideoConfig.h" #include "Profiler.h" #include "MemoryUtil.h" #include "StringUtil.h" @@ -310,7 +311,7 @@ void VertexLoader::CompileVertexTranslator() vtx_decl.num_normals = 0; if (m_VtxDesc.Normal != NOT_PRESENT) { 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) { char temp[256]; @@ -326,17 +327,25 @@ void VertexLoader::CompileVertexTranslator() switch (vtx_attr.NormalFormat) { case FORMAT_UBYTE: case FORMAT_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_offset[0] = nat_offset; - nat_offset += 4; + nat_offset += native_size; if (vtx_attr.NormalElements) { vtx_decl.normal_offset[1] = nat_offset; - nat_offset += 4; + nat_offset += native_size; vtx_decl.normal_offset[2] = nat_offset; - nat_offset += 4; + nat_offset += native_size; } break; + } case FORMAT_USHORT: case FORMAT_SHORT: vtx_decl.normal_gl_type = VAR_SHORT; diff --git a/Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp b/Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp index 0e03026840..bf38ef1e80 100644 --- a/Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp +++ b/Source/Core/VideoCommon/Src/VertexLoader_Normal.cpp @@ -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]); 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) { @@ -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_SHORT] = Set(6, Normal_Index16_Short3_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) @@ -102,8 +117,13 @@ unsigned int VertexLoader_Normal::GetSize(unsigned int _type, unsigned int _form 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; return pFunc; } @@ -118,7 +138,16 @@ void LOADERDECL VertexLoader_Normal::Normal_DirectByte() *VertexManager::s_pCurBufferPointer++ = DataReadU8(); *VertexManager::s_pCurBufferPointer++ = 0; 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() @@ -129,9 +158,6 @@ void LOADERDECL VertexLoader_Normal::Normal_DirectShort() ((u16*)VertexManager::s_pCurBufferPointer)[3] = 0; VertexManager::s_pCurBufferPointer += 8; 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() @@ -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() { 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[2]; *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(); } +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() { 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() { 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() { 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[1]; *VertexManager::s_pCurBufferPointer++ = pData[2]; - VertexManager::s_pCurBufferPointer++; + *VertexManager::s_pCurBufferPointer++ = 0; 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() { 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)[1] = Common::swap16(pData[1]); ((u16*)VertexManager::s_pCurBufferPointer)[2] = Common::swap16(pData[2]); + ((u16*)VertexManager::s_pCurBufferPointer)[3] = 0; VertexManager::s_pCurBufferPointer += 8; 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() { 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() { for (int i = 0; i < 3; i++) diff --git a/Source/Core/VideoCommon/Src/VertexLoader_Normal.h b/Source/Core/VideoCommon/Src/VertexLoader_Normal.h index 8886116eef..947c83fce8 100644 --- a/Source/Core/VideoCommon/Src/VertexLoader_Normal.h +++ b/Source/Core/VideoCommon/Src/VertexLoader_Normal.h @@ -31,7 +31,7 @@ public: static unsigned int GetSize(unsigned int _type, unsigned int _format, unsigned int _elements, unsigned int _index3); // 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: enum ENormalType @@ -77,33 +77,44 @@ private: 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 static void LOADERDECL Normal_DirectByte(); + static void LOADERDECL Normal_DirectByte_Expand16(); static void LOADERDECL Normal_DirectShort(); static void LOADERDECL Normal_DirectFloat(); static void LOADERDECL Normal_DirectByte3(); + static void LOADERDECL Normal_DirectByte3_Expand16(); static void LOADERDECL Normal_DirectShort3(); static void LOADERDECL Normal_DirectFloat3(); // index8 static void LOADERDECL Normal_Index8_Byte(); + static void LOADERDECL Normal_Index8_Byte_Expand16(); static void LOADERDECL Normal_Index8_Short(); static void LOADERDECL Normal_Index8_Float(); 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_Float3_Indices1(); 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_Float3_Indices3(); // index16 static void LOADERDECL Normal_Index16_Byte(); + static void LOADERDECL Normal_Index16_Byte_Expand16(); static void LOADERDECL Normal_Index16_Short(); static void LOADERDECL Normal_Index16_Float(); 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_Float3_Indices1(); 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_Float3_Indices3(); }; diff --git a/Source/Core/VideoCommon/Src/VideoCommon.h b/Source/Core/VideoCommon/Src/VideoCommon.h index 5df177028a..9e800f887e 100644 --- a/Source/Core/VideoCommon/Src/VideoCommon.h +++ b/Source/Core/VideoCommon/Src/VideoCommon.h @@ -142,4 +142,6 @@ struct TargetRectangle : public MathUtil::Rectangle #define LOG_VTX() +bool IsD3D(); + #endif // _VIDEOCOMMON_H diff --git a/Source/Core/VideoCommon/Src/VideoConfig.cpp b/Source/Core/VideoCommon/Src/VideoConfig.cpp index aa561512b7..5ea67d0e44 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.cpp +++ b/Source/Core/VideoCommon/Src/VideoConfig.cpp @@ -33,6 +33,7 @@ void UpdateActiveConfig() VideoConfig::VideoConfig() { bRunning = false; + bAllowSignedBytes = !IsD3D(); } void VideoConfig::Load(const char *ini_file) diff --git a/Source/Core/VideoCommon/Src/VideoConfig.h b/Source/Core/VideoCommon/Src/VideoConfig.h index be4383f72c..47b28e43a7 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.h +++ b/Source/Core/VideoCommon/Src/VideoConfig.h @@ -131,6 +131,9 @@ struct VideoConfig // With this enabled, the plugin renders directly to the backbuffer. Many features are // disabled but it might be faster on really old GPUs. bool bSimpleFB; + + // Static config per API + bool bAllowSignedBytes; }; extern VideoConfig g_Config; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp b/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp index 9698eb3343..f4891bdcd5 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp @@ -68,8 +68,9 @@ D3DDECLTYPE VarToD3D(VarType t, int size) static const D3DDECLTYPE lookup3[5] = { D3DDECLTYPE_UNUSED, D3DDECLTYPE_UNUSED, D3DDECLTYPE_UNUSED, D3DDECLTYPE_UNUSED, D3DDECLTYPE_FLOAT3, }; + // Sadly, D3D9 has no SBYTE4N. D3D10 does, though. 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; switch (size) { @@ -84,9 +85,6 @@ D3DDECLTYPE VarToD3D(VarType t, int size) 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) { vertex_stride = _vtx_decl.stride; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index 2e59938cf6..385b841780 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -61,6 +61,7 @@ static bool s_AVIDumping; #define NUMWNDRES 6 extern int g_Res[NUMWNDRES][2]; +char st[32768]; void SetupDeviceObjects() { @@ -266,15 +267,13 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect D3D::GetBackBufferSurface(), dst_rect.AsRECT(), D3DTEXF_LINEAR); - char st[8192]; // Finish up the current frame, print some stats if (g_ActiveConfig.bOverlayStats) { Statistics::ToString(st); D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,st,false); } - - if (g_ActiveConfig.bOverlayProjStats) + else if (g_ActiveConfig.bOverlayProjStats) { Statistics::ToStringProj(st); D3D::font.DrawTextScaled(0,30,20,20,0.0f,0xFF00FFFF,st,false); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp index fe699c98e7..bb7ede8192 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp @@ -72,6 +72,11 @@ bool HandleDisplayList(u32 address, u32 size) return false; } +bool IsD3D() +{ + return true; +} + // This is used for the functions right below here which use wxwidgets #if defined(HAVE_WX) && HAVE_WX #ifdef _WIN32 diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index d90949fe13..263a9695f9 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -107,6 +107,11 @@ static u32 s_swapRequested = FALSE; static u32 s_efbAccessRequested = FALSE; static bool ForceSwap = true; +bool IsD3D() +{ + return false; +} + void GetDllInfo (PLUGIN_INFO* _PluginInfo) { _PluginInfo->Version = 0x0100;