From 45024133e2aae56846bd19c3a584bac84044e467 Mon Sep 17 00:00:00 2001 From: donkopunchstania Date: Sat, 29 Jan 2011 06:09:56 +0000 Subject: [PATCH] Remove vertex format converter from software plugin because it is not needed as of r6881. Maybe fix z range adjustment. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6961 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugin_VideoSoftware/CMakeLists.txt | 1 - .../Plugin_VideoSoftware.vcproj | 8 -- .../Plugin_VideoSoftware/Src/Clipper.cpp | 6 +- .../Plugin_VideoSoftware/Src/HwRasterizer.cpp | 2 +- .../Plugin_VideoSoftware/Src/Rasterizer.cpp | 15 ++-- .../Plugin_VideoSoftware/Src/SConscript | 1 - .../Src/VertexFormatConverter.cpp | 79 ------------------- .../Src/VertexFormatConverter.h | 35 -------- .../Plugin_VideoSoftware/Src/VertexLoader.cpp | 32 +------- .../Plugin_VideoSoftware/Src/VertexLoader.h | 3 - 10 files changed, 15 insertions(+), 167 deletions(-) delete mode 100644 Source/Plugins/Plugin_VideoSoftware/Src/VertexFormatConverter.cpp delete mode 100644 Source/Plugins/Plugin_VideoSoftware/Src/VertexFormatConverter.h diff --git a/Source/Plugins/Plugin_VideoSoftware/CMakeLists.txt b/Source/Plugins/Plugin_VideoSoftware/CMakeLists.txt index 9a6a33b0d6..7abe14dcbd 100644 --- a/Source/Plugins/Plugin_VideoSoftware/CMakeLists.txt +++ b/Source/Plugins/Plugin_VideoSoftware/CMakeLists.txt @@ -19,7 +19,6 @@ set(SRCS Src/BPMemLoader.cpp Src/TextureEncoder.cpp Src/TextureSampler.cpp Src/TransformUnit.cpp - Src/VertexFormatConverter.cpp Src/VertexLoader.cpp Src/VideoConfig.cpp Src/XFMemLoader.cpp) diff --git a/Source/Plugins/Plugin_VideoSoftware/Plugin_VideoSoftware.vcproj b/Source/Plugins/Plugin_VideoSoftware/Plugin_VideoSoftware.vcproj index 4cc4c0943d..7ead9726d0 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Plugin_VideoSoftware.vcproj +++ b/Source/Plugins/Plugin_VideoSoftware/Plugin_VideoSoftware.vcproj @@ -639,14 +639,6 @@ RelativePath=".\Src\Vec3.h" > - - - - diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Clipper.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Clipper.cpp index 3dc38ac0e8..02ca28ed3e 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Clipper.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Clipper.cpp @@ -61,7 +61,8 @@ namespace Clipper { enum { NUM_CLIPPED_VERTICES = 33, NUM_INDICES = NUM_CLIPPED_VERTICES + 3 }; - float m_ViewOffset[3]; + float m_ViewOffset[2]; + OutputVertexData ClippedVertices[NUM_CLIPPED_VERTICES]; OutputVertexData *Vertices[NUM_INDICES]; @@ -75,7 +76,6 @@ namespace Clipper { m_ViewOffset[0] = xfregs.viewport.xOrig - 342; m_ViewOffset[1] = xfregs.viewport.yOrig - 342; - m_ViewOffset[2] = xfregs.viewport.farZ - xfregs.viewport.farZ; } @@ -440,7 +440,7 @@ namespace Clipper float wInverse = 1.0f/projected.w; screen.x = projected.x * wInverse * xfregs.viewport.wd + m_ViewOffset[0]; screen.y = projected.y * wInverse * xfregs.viewport.ht + m_ViewOffset[1]; - screen.z = projected.z * wInverse + m_ViewOffset[2]; + screen.z = projected.z * wInverse * xfregs.viewport.zRange + xfregs.viewport.farZ; } } diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/HwRasterizer.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/HwRasterizer.cpp index 3daf017c2f..c5516d6e86 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/HwRasterizer.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/HwRasterizer.cpp @@ -80,7 +80,7 @@ namespace HwRasterizer void DrawColorVertex(OutputVertexData *v) { glColor3ub(v->color[0][OutputVertexData::RED_C], v->color[0][OutputVertexData::GRN_C], v->color[0][OutputVertexData::BLU_C]); - glVertex3f(v->screenPosition.x / efbHalfWidth - 1.0f, 1.0f - v->screenPosition.y / efbHalfHeight, v->screenPosition.z); + glVertex3f(v->screenPosition.x / efbHalfWidth - 1.0f, 1.0f - v->screenPosition.y / efbHalfHeight, v->screenPosition.z / (float)0x00ffffff); } void DrawTextureVertex(OutputVertexData *v) diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.cpp index 98af555e9a..09ae528bb9 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Rasterizer.cpp @@ -116,12 +116,10 @@ inline void Draw(s32 x, s32 y, s32 xi, s32 yi) float dx = vertexOffsetX + (float)(x - vertex0X); float dy = vertexOffsetY + (float)(y - vertex0Y); - float zFloat = 1.0f + ZSlope.GetValue(dx, dy); - if (zFloat < 0.0f || zFloat > 1.0f) + s32 z = (s32)ZSlope.GetValue(dx, dy); + if (z < 0 || z > 0x00ffffff) return; - s32 z = (s32)(zFloat * 0x00ffffff); - if (bpmem.zcontrol.zcomploc && bpmem.zmode.testenable) { // early z @@ -139,7 +137,14 @@ inline void Draw(s32 x, s32 y, s32 xi, s32 yi) for (unsigned int i = 0; i < bpmem.genMode.numcolchans; i++) { for(int comp = 0; comp < 4; comp++) - tev.Color[i][comp] = (u8)ColorSlopes[i][comp].GetValue(dx, dy); + { + u16 color = (u16)ColorSlopes[i][comp].GetValue(dx, dy); + + // clamp color value to 0 + u16 mask = ~(color >> 8); + + tev.Color[i][comp] = color & mask; + } } // tex coords diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SConscript b/Source/Plugins/Plugin_VideoSoftware/Src/SConscript index 169ece38f2..e009d4d983 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SConscript +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SConscript @@ -26,7 +26,6 @@ files = [ 'TextureEncoder.cpp', 'TextureSampler.cpp', 'TransformUnit.cpp', - 'VertexFormatConverter.cpp', 'VertexLoader.cpp', 'VideoConfig.cpp', 'XFMemLoader.cpp', diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/VertexFormatConverter.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/VertexFormatConverter.cpp deleted file mode 100644 index a26a8407b8..0000000000 --- a/Source/Plugins/Plugin_VideoSoftware/Src/VertexFormatConverter.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (C) 2003-2009 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -#include "Common.h" - -#include "VertexFormatConverter.h" - - -namespace VertexFormatConverter -{ - // This fracs are fixed acording to format -#define S8FRAC 0.015625f; // 1.0f / (1U << 6) -#define S16FRAC 0.00006103515625f; // 1.0f / (1U << 14) - - void LoadNormal1_Byte(InputVertexData *dst, u8 *src) - { - dst->normal[0].x = ((s8)src[0]) * S8FRAC; - dst->normal[0].y = ((s8)src[1]) * S8FRAC; - dst->normal[0].z = ((s8)src[2]) * S8FRAC; - } - - void LoadNormal1_Short(InputVertexData *dst, u8 *src) - { - dst->normal[0].x = ((s16*)src)[0] * S16FRAC; - dst->normal[0].y = ((s16*)src)[1] * S16FRAC; - dst->normal[0].z = ((s16*)src)[2] * S16FRAC; - } - - void LoadNormal1_Float(InputVertexData *dst, u8 *src) - { - dst->normal[0].x = ((float*)src)[0]; - dst->normal[0].y = ((float*)src)[1]; - dst->normal[0].z = ((float*)src)[2]; - } - - void LoadNormal3_Byte(InputVertexData *dst, u8 *src) - { - for (int i = 0, j = 0; i < 3; i++, j+=3) - { - dst->normal[i].x = ((s8)src[j + 0]) * S8FRAC; - dst->normal[i].y = ((s8)src[j + 1]) * S8FRAC; - dst->normal[i].z = ((s8)src[j + 2]) * S8FRAC; - } - } - - void LoadNormal3_Short(InputVertexData *dst, u8 *src) - { - for (int i = 0, j = 0; i < 3; i++, j+=3) - { - dst->normal[i].x = ((s16*)src)[j + 0] * S16FRAC; - dst->normal[i].y = ((s16*)src)[j + 1] * S16FRAC; - dst->normal[i].z = ((s16*)src)[j + 2] * S16FRAC; - } - } - - void LoadNormal3_Float(InputVertexData *dst, u8 *src) - { - for (int i = 0, j = 0; i < 3; i++, j+=3) - { - dst->normal[i].x = ((float*)src)[j + 0]; - dst->normal[i].y = ((float*)src)[j + 1]; - dst->normal[i].z = ((float*)src)[j + 2]; - } - } -} diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/VertexFormatConverter.h b/Source/Plugins/Plugin_VideoSoftware/Src/VertexFormatConverter.h deleted file mode 100644 index d8ea7f38cc..0000000000 --- a/Source/Plugins/Plugin_VideoSoftware/Src/VertexFormatConverter.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2003-2009 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ - -#ifndef _VERTEXFORMATCONVERTER_H -#define _VERTEXFORMATCONVERTER_H - -#include "NativeVertexFormat.h" - -namespace VertexFormatConverter -{ - typedef void (*NormalConverter)(InputVertexData*, u8*); - - void LoadNormal1_Byte(InputVertexData *dst, u8 *src); - void LoadNormal1_Short(InputVertexData *dst, u8 *src); - void LoadNormal1_Float(InputVertexData *dst, u8 *src); - void LoadNormal3_Byte(InputVertexData *dst, u8 *src); - void LoadNormal3_Short(InputVertexData *dst, u8 *src); - void LoadNormal3_Float(InputVertexData *dst, u8 *src); -} - -#endif diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/VertexLoader.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/VertexLoader.cpp index 2dd89b4713..d537515c93 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/VertexLoader.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/VertexLoader.cpp @@ -30,7 +30,6 @@ #include "SetupUnit.h" #include "Statistics.h" #include "VertexManagerBase.h" -#include "VertexFormatConverter.h" #include "../../../Core/VideoCommon/Src/DataReader.h" // Vertex loaders read these @@ -175,30 +174,6 @@ void VertexLoader::SetFormat(u8 attributeIndex, u8 primitiveType) ERROR_LOG(VIDEO, "VertexLoader_Normal::GetFunction returned zero!"); } AddAttributeLoader(LoadNormal); - - switch (m_CurrentVat->g0.NormalFormat) { - case FORMAT_UBYTE: - case FORMAT_BYTE: - if (m_CurrentVat->g0.NormalElements) - m_normalConverter = VertexFormatConverter::LoadNormal3_Byte; - else - m_normalConverter = VertexFormatConverter::LoadNormal1_Byte; - break; - case FORMAT_USHORT: - case FORMAT_SHORT: - if (m_CurrentVat->g0.NormalElements) - m_normalConverter = VertexFormatConverter::LoadNormal3_Short; - else - m_normalConverter = VertexFormatConverter::LoadNormal1_Short; - break; - case FORMAT_FLOAT: - if (m_CurrentVat->g0.NormalElements) - m_normalConverter = VertexFormatConverter::LoadNormal3_Float; - else - m_normalConverter = VertexFormatConverter::LoadNormal1_Float; - break; - default: _assert_(0); break; - } } for (int i = 0; i < 2; i++) { @@ -326,13 +301,8 @@ void VertexLoader::LoadPosition(VertexLoader *vertexLoader, InputVertexData *ver void VertexLoader::LoadNormal(VertexLoader *vertexLoader, InputVertexData *vertex, u8 unused) { - u8 buffer[3*3*4]; - - VertexManager::s_pCurBufferPointer = buffer; + VertexManager::s_pCurBufferPointer = (u8*)&vertex->normal; vertexLoader->m_normalLoader(); - - // the common vertex loader loads data as bytes, shorts or floats so an extra step is needed to make it floats - vertexLoader->m_normalConverter(vertex, buffer); } void VertexLoader::LoadColor(VertexLoader *vertexLoader, InputVertexData *vertex, u8 index) diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/VertexLoader.h b/Source/Plugins/Plugin_VideoSoftware/Src/VertexLoader.h index d5f152d27f..6db5d0d1dc 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/VertexLoader.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/VertexLoader.h @@ -21,7 +21,6 @@ #include "Common.h" #include "NativeVertexFormat.h" -#include "VertexFormatConverter.h" #include "CPMemLoader.h" class SetupUnit; @@ -37,8 +36,6 @@ class VertexLoader TPipelineFunction m_colorLoader[2]; TPipelineFunction m_texCoordLoader[8]; - VertexFormatConverter::NormalConverter m_normalConverter; - InputVertexData m_Vertex; typedef void (*AttributeLoader)(VertexLoader*, InputVertexData*, u8);