2013-04-18 03:09:55 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2014-09-08 01:06:58 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/MemoryUtil.h"
|
|
|
|
|
|
|
|
#include "Core/Host.h"
|
|
|
|
|
2014-09-17 01:04:37 +00:00
|
|
|
#include "VideoCommon/BoundingBox.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/DataReader.h"
|
|
|
|
#include "VideoCommon/PixelEngine.h"
|
|
|
|
#include "VideoCommon/VertexLoader.h"
|
|
|
|
#include "VideoCommon/VertexLoader_Color.h"
|
|
|
|
#include "VideoCommon/VertexLoader_Normal.h"
|
|
|
|
#include "VideoCommon/VertexLoader_Position.h"
|
|
|
|
#include "VideoCommon/VertexLoader_TextCoord.h"
|
|
|
|
#include "VideoCommon/VideoCommon.h"
|
|
|
|
#include "VideoCommon/VideoConfig.h"
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2014-12-09 07:30:38 +00:00
|
|
|
// This pointer is used as the source/dst for all fixed function loader calls
|
2014-11-27 22:53:11 +00:00
|
|
|
u8* g_video_buffer_read_ptr;
|
2014-12-09 07:30:38 +00:00
|
|
|
u8* g_vertex_manager_write_ptr;
|
2014-11-27 22:53:11 +00:00
|
|
|
|
2014-12-13 09:57:46 +00:00
|
|
|
static void LOADERDECL PosMtx_ReadDirect_UByte(VertexLoader* loader)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2015-01-15 00:46:23 +00:00
|
|
|
u8 posmtx = BoundingBox::posMtxIdx = DataReadU8() & 0x3f;
|
|
|
|
DataWrite<u32>(posmtx);
|
|
|
|
PRIM_LOG("posmtx: %d, ", posmtx);
|
2009-06-28 20:04:07 +00:00
|
|
|
}
|
|
|
|
|
2014-12-13 09:57:46 +00:00
|
|
|
static void LOADERDECL TexMtx_ReadDirect_UByte(VertexLoader* loader)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2014-12-13 09:57:46 +00:00
|
|
|
BoundingBox::texMtxIdx[loader->m_texmtxread] = loader->m_curtexmtx[loader->m_texmtxread] = DataReadU8() & 0x3f;
|
2014-09-14 16:52:51 +00:00
|
|
|
|
2014-12-13 09:57:46 +00:00
|
|
|
PRIM_LOG("texmtx%d: %d, ", loader->m_texmtxread, loader->m_curtexmtx[loader->m_texmtxread]);
|
|
|
|
loader->m_texmtxread++;
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2014-12-13 09:57:46 +00:00
|
|
|
static void LOADERDECL TexMtx_Write_Float(VertexLoader* loader)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2014-12-13 09:57:46 +00:00
|
|
|
DataWrite(float(loader->m_curtexmtx[loader->m_texmtxwrite++]));
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2014-12-13 09:57:46 +00:00
|
|
|
static void LOADERDECL TexMtx_Write_Float2(VertexLoader* loader)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2013-02-22 08:19:59 +00:00
|
|
|
DataWrite(0.f);
|
2014-12-13 09:57:46 +00:00
|
|
|
DataWrite(float(loader->m_curtexmtx[loader->m_texmtxwrite++]));
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2015-01-15 00:46:23 +00:00
|
|
|
static void LOADERDECL TexMtx_Write_Float3(VertexLoader* loader)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2013-02-22 08:19:59 +00:00
|
|
|
DataWrite(0.f);
|
|
|
|
DataWrite(0.f);
|
2014-12-13 09:57:46 +00:00
|
|
|
DataWrite(float(loader->m_curtexmtx[loader->m_texmtxwrite++]));
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2014-12-21 13:29:44 +00:00
|
|
|
static void LOADERDECL SkipVertex(VertexLoader* loader)
|
|
|
|
{
|
|
|
|
if (loader->m_vertexSkip)
|
|
|
|
{
|
|
|
|
// reset the output buffer
|
|
|
|
g_vertex_manager_write_ptr -= loader->m_native_vtx_decl.stride;
|
|
|
|
|
|
|
|
loader->m_skippedVertices++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-29 05:23:17 +00:00
|
|
|
VertexLoader::VertexLoader(const TVtxDesc &vtx_desc, const VAT &vtx_attr)
|
2014-12-13 00:51:14 +00:00
|
|
|
: VertexLoaderBase(vtx_desc, vtx_attr)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
|
|
|
VertexLoader_Normal::Init();
|
|
|
|
|
2013-03-06 17:58:15 +00:00
|
|
|
CompileVertexTranslator();
|
2014-12-13 09:57:46 +00:00
|
|
|
|
|
|
|
// generate frac factors
|
2015-01-19 17:33:08 +00:00
|
|
|
m_posScale = 1.0f / (1U << m_VtxAttr.PosFrac);
|
2014-12-13 09:57:46 +00:00
|
|
|
for (int i = 0; i < 8; i++)
|
2015-01-19 17:33:08 +00:00
|
|
|
m_tcScale[i] = 1.0f / (1U << m_VtxAttr.texCoord[i].Frac);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void VertexLoader::CompileVertexTranslator()
|
|
|
|
{
|
|
|
|
m_VertexSize = 0;
|
|
|
|
const TVtxAttr &vtx_attr = m_VtxAttr;
|
|
|
|
|
2014-02-23 14:14:27 +00:00
|
|
|
// Reset pipeline
|
|
|
|
m_numPipelineStages = 0;
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2014-09-14 16:52:51 +00:00
|
|
|
// Get the pointer to this vertex's buffer data for the bounding box
|
2015-04-06 00:17:57 +00:00
|
|
|
if (!g_ActiveConfig.backend_info.bSupportsBBox && g_ActiveConfig.bBBoxEnable)
|
2014-11-13 22:26:49 +00:00
|
|
|
WriteCall(BoundingBox::SetVertexBufferPosition);
|
2014-09-14 16:52:51 +00:00
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
// Colors
|
2015-02-15 19:43:31 +00:00
|
|
|
const u64 col[2] = { m_VtxDesc.Color0, m_VtxDesc.Color1 };
|
2008-12-08 05:25:12 +00:00
|
|
|
// TextureCoord
|
2014-09-01 09:00:25 +00:00
|
|
|
const u64 tc[8] = {
|
2008-12-08 05:25:12 +00:00
|
|
|
m_VtxDesc.Tex0Coord, m_VtxDesc.Tex1Coord, m_VtxDesc.Tex2Coord, m_VtxDesc.Tex3Coord,
|
2014-09-01 09:00:25 +00:00
|
|
|
m_VtxDesc.Tex4Coord, m_VtxDesc.Tex5Coord, m_VtxDesc.Tex6Coord, m_VtxDesc.Tex7Coord
|
2008-12-08 05:25:12 +00:00
|
|
|
};
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2014-01-15 15:58:36 +00:00
|
|
|
u32 components = 0;
|
2008-12-08 05:25:12 +00:00
|
|
|
|
|
|
|
// Position in pc vertex format.
|
|
|
|
int nat_offset = 0;
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
// Position Matrix Index
|
2013-04-24 13:21:54 +00:00
|
|
|
if (m_VtxDesc.PosMatIdx)
|
|
|
|
{
|
2008-12-08 05:25:12 +00:00
|
|
|
WriteCall(PosMtx_ReadDirect_UByte);
|
2014-01-15 15:58:36 +00:00
|
|
|
components |= VB_HAS_POSMTXIDX;
|
2015-01-15 00:46:23 +00:00
|
|
|
m_native_vtx_decl.posmtx.components = 4;
|
|
|
|
m_native_vtx_decl.posmtx.enable = true;
|
|
|
|
m_native_vtx_decl.posmtx.offset = nat_offset;
|
|
|
|
m_native_vtx_decl.posmtx.type = VAR_UNSIGNED_BYTE;
|
|
|
|
m_native_vtx_decl.posmtx.integer = true;
|
|
|
|
nat_offset += 4;
|
2008-12-08 05:25:12 +00:00
|
|
|
m_VertexSize += 1;
|
|
|
|
}
|
|
|
|
|
2015-02-15 19:43:31 +00:00
|
|
|
if (m_VtxDesc.Tex0MatIdx) { m_VertexSize += 1; components |= VB_HAS_TEXMTXIDX0; WriteCall(TexMtx_ReadDirect_UByte); }
|
|
|
|
if (m_VtxDesc.Tex1MatIdx) { m_VertexSize += 1; components |= VB_HAS_TEXMTXIDX1; WriteCall(TexMtx_ReadDirect_UByte); }
|
|
|
|
if (m_VtxDesc.Tex2MatIdx) { m_VertexSize += 1; components |= VB_HAS_TEXMTXIDX2; WriteCall(TexMtx_ReadDirect_UByte); }
|
|
|
|
if (m_VtxDesc.Tex3MatIdx) { m_VertexSize += 1; components |= VB_HAS_TEXMTXIDX3; WriteCall(TexMtx_ReadDirect_UByte); }
|
|
|
|
if (m_VtxDesc.Tex4MatIdx) { m_VertexSize += 1; components |= VB_HAS_TEXMTXIDX4; WriteCall(TexMtx_ReadDirect_UByte); }
|
|
|
|
if (m_VtxDesc.Tex5MatIdx) { m_VertexSize += 1; components |= VB_HAS_TEXMTXIDX5; WriteCall(TexMtx_ReadDirect_UByte); }
|
|
|
|
if (m_VtxDesc.Tex6MatIdx) { m_VertexSize += 1; components |= VB_HAS_TEXMTXIDX6; WriteCall(TexMtx_ReadDirect_UByte); }
|
|
|
|
if (m_VtxDesc.Tex7MatIdx) { m_VertexSize += 1; components |= VB_HAS_TEXMTXIDX7; WriteCall(TexMtx_ReadDirect_UByte); }
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2010-02-28 08:41:02 +00:00
|
|
|
// Write vertex position loader
|
2014-09-14 16:52:51 +00:00
|
|
|
WriteCall(VertexLoader_Position::GetFunction(m_VtxDesc.Position, m_VtxAttr.PosFormat, m_VtxAttr.PosElements));
|
|
|
|
|
2010-04-09 15:13:42 +00:00
|
|
|
m_VertexSize += VertexLoader_Position::GetSize(m_VtxDesc.Position, m_VtxAttr.PosFormat, m_VtxAttr.PosElements);
|
2015-03-17 06:05:19 +00:00
|
|
|
int pos_elements = m_VtxAttr.PosElements + 2;
|
|
|
|
m_native_vtx_decl.position.components = pos_elements;
|
2014-07-25 23:10:44 +00:00
|
|
|
m_native_vtx_decl.position.enable = true;
|
2015-01-19 16:38:40 +00:00
|
|
|
m_native_vtx_decl.position.offset = nat_offset;
|
2014-07-25 23:10:44 +00:00
|
|
|
m_native_vtx_decl.position.type = VAR_FLOAT;
|
|
|
|
m_native_vtx_decl.position.integer = false;
|
2015-03-17 06:05:19 +00:00
|
|
|
nat_offset += pos_elements * sizeof(float);
|
2008-12-08 05:25:12 +00:00
|
|
|
|
|
|
|
// Normals
|
2011-03-21 05:46:33 +00:00
|
|
|
if (m_VtxDesc.Normal != NOT_PRESENT)
|
|
|
|
{
|
|
|
|
m_VertexSize += VertexLoader_Normal::GetSize(m_VtxDesc.Normal,
|
|
|
|
m_VtxAttr.NormalFormat, m_VtxAttr.NormalElements, m_VtxAttr.NormalIndex3);
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-03-21 05:46:33 +00:00
|
|
|
TPipelineFunction pFunc = VertexLoader_Normal::GetFunction(m_VtxDesc.Normal,
|
|
|
|
m_VtxAttr.NormalFormat, m_VtxAttr.NormalElements, m_VtxAttr.NormalIndex3);
|
|
|
|
|
2014-03-09 20:14:26 +00:00
|
|
|
if (pFunc == nullptr)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2014-11-05 07:22:33 +00:00
|
|
|
PanicAlert("VertexLoader_Normal::GetFunction(%i %i %i %i) returned zero!",
|
2014-09-01 09:00:25 +00:00
|
|
|
(u32)m_VtxDesc.Normal, m_VtxAttr.NormalFormat,
|
2014-11-05 07:22:33 +00:00
|
|
|
m_VtxAttr.NormalElements, m_VtxAttr.NormalIndex3);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
WriteCall(pFunc);
|
|
|
|
|
2014-01-24 14:16:52 +00:00
|
|
|
for (int i = 0; i < (vtx_attr.NormalElements ? 3 : 1); i++)
|
2013-04-24 13:21:54 +00:00
|
|
|
{
|
2014-07-25 23:10:44 +00:00
|
|
|
m_native_vtx_decl.normals[i].components = 3;
|
|
|
|
m_native_vtx_decl.normals[i].enable = true;
|
|
|
|
m_native_vtx_decl.normals[i].offset = nat_offset;
|
|
|
|
m_native_vtx_decl.normals[i].type = VAR_FLOAT;
|
|
|
|
m_native_vtx_decl.normals[i].integer = false;
|
2011-01-19 13:57:15 +00:00
|
|
|
nat_offset += 12;
|
2013-03-20 01:51:12 +00:00
|
|
|
}
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2014-01-15 15:58:36 +00:00
|
|
|
components |= VB_HAS_NRM0;
|
2014-03-26 21:54:40 +00:00
|
|
|
if (m_VtxAttr.NormalElements == 1)
|
2014-01-15 15:58:36 +00:00
|
|
|
components |= VB_HAS_NRM1 | VB_HAS_NRM2;
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2013-04-24 13:21:54 +00:00
|
|
|
for (int i = 0; i < 2; i++)
|
|
|
|
{
|
2014-07-25 23:10:44 +00:00
|
|
|
m_native_vtx_decl.colors[i].components = 4;
|
|
|
|
m_native_vtx_decl.colors[i].type = VAR_UNSIGNED_BYTE;
|
|
|
|
m_native_vtx_decl.colors[i].integer = false;
|
2008-12-08 05:25:12 +00:00
|
|
|
switch (col[i])
|
|
|
|
{
|
2013-10-29 05:23:17 +00:00
|
|
|
case NOT_PRESENT:
|
2008-12-08 05:25:12 +00:00
|
|
|
break;
|
|
|
|
case DIRECT:
|
|
|
|
switch (m_VtxAttr.color[i].Comp)
|
|
|
|
{
|
2014-02-17 04:51:41 +00:00
|
|
|
case FORMAT_16B_565: m_VertexSize += 2; WriteCall(Color_ReadDirect_16b_565); break;
|
|
|
|
case FORMAT_24B_888: m_VertexSize += 3; WriteCall(Color_ReadDirect_24b_888); break;
|
|
|
|
case FORMAT_32B_888x: m_VertexSize += 4; WriteCall(Color_ReadDirect_32b_888x); break;
|
|
|
|
case FORMAT_16B_4444: m_VertexSize += 2; WriteCall(Color_ReadDirect_16b_4444); break;
|
|
|
|
case FORMAT_24B_6666: m_VertexSize += 3; WriteCall(Color_ReadDirect_24b_6666); break;
|
|
|
|
case FORMAT_32B_8888: m_VertexSize += 4; WriteCall(Color_ReadDirect_32b_8888); break;
|
2008-12-08 05:25:12 +00:00
|
|
|
default: _assert_(0); break;
|
|
|
|
}
|
|
|
|
break;
|
2013-03-20 01:51:12 +00:00
|
|
|
case INDEX8:
|
2008-12-08 05:25:12 +00:00
|
|
|
m_VertexSize += 1;
|
|
|
|
switch (m_VtxAttr.color[i].Comp)
|
|
|
|
{
|
2014-02-17 04:51:41 +00:00
|
|
|
case FORMAT_16B_565: WriteCall(Color_ReadIndex8_16b_565); break;
|
|
|
|
case FORMAT_24B_888: WriteCall(Color_ReadIndex8_24b_888); break;
|
|
|
|
case FORMAT_32B_888x: WriteCall(Color_ReadIndex8_32b_888x); break;
|
|
|
|
case FORMAT_16B_4444: WriteCall(Color_ReadIndex8_16b_4444); break;
|
|
|
|
case FORMAT_24B_6666: WriteCall(Color_ReadIndex8_24b_6666); break;
|
|
|
|
case FORMAT_32B_8888: WriteCall(Color_ReadIndex8_32b_8888); break;
|
2008-12-08 05:25:12 +00:00
|
|
|
default: _assert_(0); break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case INDEX16:
|
|
|
|
m_VertexSize += 2;
|
|
|
|
switch (m_VtxAttr.color[i].Comp)
|
|
|
|
{
|
2014-02-17 04:51:41 +00:00
|
|
|
case FORMAT_16B_565: WriteCall(Color_ReadIndex16_16b_565); break;
|
|
|
|
case FORMAT_24B_888: WriteCall(Color_ReadIndex16_24b_888); break;
|
|
|
|
case FORMAT_32B_888x: WriteCall(Color_ReadIndex16_32b_888x); break;
|
|
|
|
case FORMAT_16B_4444: WriteCall(Color_ReadIndex16_16b_4444); break;
|
|
|
|
case FORMAT_24B_6666: WriteCall(Color_ReadIndex16_24b_6666); break;
|
|
|
|
case FORMAT_32B_8888: WriteCall(Color_ReadIndex16_32b_8888); break;
|
2008-12-08 05:25:12 +00:00
|
|
|
default: _assert_(0); break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Common for the three bottom cases
|
2013-04-24 13:21:54 +00:00
|
|
|
if (col[i] != NOT_PRESENT)
|
|
|
|
{
|
2014-01-24 14:23:50 +00:00
|
|
|
components |= VB_HAS_COL0 << i;
|
2014-07-25 23:10:44 +00:00
|
|
|
m_native_vtx_decl.colors[i].offset = nat_offset;
|
|
|
|
m_native_vtx_decl.colors[i].enable = true;
|
2008-12-08 05:25:12 +00:00
|
|
|
nat_offset += 4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Texture matrix indices (remove if corresponding texture coordinate isn't enabled)
|
2013-04-24 13:21:54 +00:00
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
{
|
2014-07-25 23:10:44 +00:00
|
|
|
m_native_vtx_decl.texcoords[i].offset = nat_offset;
|
|
|
|
m_native_vtx_decl.texcoords[i].type = VAR_FLOAT;
|
|
|
|
m_native_vtx_decl.texcoords[i].integer = false;
|
2014-01-24 14:32:27 +00:00
|
|
|
|
2010-02-28 11:36:00 +00:00
|
|
|
const int format = m_VtxAttr.texCoord[i].Format;
|
|
|
|
const int elements = m_VtxAttr.texCoord[i].Elements;
|
|
|
|
|
2015-01-15 00:46:23 +00:00
|
|
|
if (tc[i] != NOT_PRESENT)
|
2013-04-24 13:21:54 +00:00
|
|
|
{
|
2014-09-01 09:00:25 +00:00
|
|
|
_assert_msg_(VIDEO, DIRECT <= tc[i] && tc[i] <= INDEX16, "Invalid texture coordinates!\n(tc[i] = %d)", (u32)tc[i]);
|
2010-02-28 11:36:00 +00:00
|
|
|
_assert_msg_(VIDEO, FORMAT_UBYTE <= format && format <= FORMAT_FLOAT, "Invalid texture coordinates format!\n(format = %d)", format);
|
2013-04-19 13:21:45 +00:00
|
|
|
_assert_msg_(VIDEO, 0 <= elements && elements <= 1, "Invalid number of texture coordinates elements!\n(elements = %d)", elements);
|
2010-02-28 11:36:00 +00:00
|
|
|
|
2014-01-15 15:58:36 +00:00
|
|
|
components |= VB_HAS_UV0 << i;
|
2010-04-09 15:13:42 +00:00
|
|
|
WriteCall(VertexLoader_TextCoord::GetFunction(tc[i], format, elements));
|
|
|
|
m_VertexSize += VertexLoader_TextCoord::GetSize(tc[i], format, elements);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
2014-01-15 15:58:36 +00:00
|
|
|
if (components & (VB_HAS_TEXMTXIDX0 << i))
|
2013-04-24 13:21:54 +00:00
|
|
|
{
|
2014-07-25 23:10:44 +00:00
|
|
|
m_native_vtx_decl.texcoords[i].enable = true;
|
2013-04-24 13:21:54 +00:00
|
|
|
if (tc[i] != NOT_PRESENT)
|
|
|
|
{
|
2008-12-08 05:25:12 +00:00
|
|
|
// if texmtx is included, texcoord will always be 3 floats, z will be the texmtx index
|
2014-07-25 23:10:44 +00:00
|
|
|
m_native_vtx_decl.texcoords[i].components = 3;
|
2008-12-08 05:25:12 +00:00
|
|
|
nat_offset += 12;
|
|
|
|
WriteCall(m_VtxAttr.texCoord[i].Elements ? TexMtx_Write_Float : TexMtx_Write_Float2);
|
|
|
|
}
|
2013-04-24 13:21:54 +00:00
|
|
|
else
|
|
|
|
{
|
2015-01-15 00:46:23 +00:00
|
|
|
m_native_vtx_decl.texcoords[i].components = 3;
|
|
|
|
nat_offset += 12;
|
|
|
|
WriteCall(TexMtx_Write_Float3);
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
}
|
2013-04-24 13:21:54 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (tc[i] != NOT_PRESENT)
|
|
|
|
{
|
2014-07-25 23:10:44 +00:00
|
|
|
m_native_vtx_decl.texcoords[i].enable = true;
|
|
|
|
m_native_vtx_decl.texcoords[i].components = vtx_attr.texCoord[i].Elements ? 2 : 1;
|
2008-12-08 05:25:12 +00:00
|
|
|
nat_offset += 4 * (vtx_attr.texCoord[i].Elements ? 2 : 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-24 13:21:54 +00:00
|
|
|
if (tc[i] == NOT_PRESENT)
|
|
|
|
{
|
2013-10-29 05:23:17 +00:00
|
|
|
// if there's more tex coords later, have to write a dummy call
|
2008-12-08 05:25:12 +00:00
|
|
|
int j = i + 1;
|
2013-04-24 13:21:54 +00:00
|
|
|
for (; j < 8; ++j)
|
|
|
|
{
|
|
|
|
if (tc[j] != NOT_PRESENT)
|
|
|
|
{
|
2010-04-09 15:13:42 +00:00
|
|
|
WriteCall(VertexLoader_TextCoord::GetDummyFunction()); // important to get indices right!
|
2008-12-08 05:25:12 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// tricky!
|
2014-01-15 15:58:36 +00:00
|
|
|
if (j == 8 && !((components & VB_HAS_TEXMTXIDXALL) & (VB_HAS_TEXMTXIDXALL << (i + 1))))
|
2013-04-24 13:21:54 +00:00
|
|
|
{
|
2008-12-08 05:25:12 +00:00
|
|
|
// no more tex coords and tex matrices, so exit loop
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-14 16:52:51 +00:00
|
|
|
// Update the bounding box
|
2015-04-06 00:17:57 +00:00
|
|
|
if (!g_ActiveConfig.backend_info.bSupportsBBox && g_ActiveConfig.bBBoxEnable)
|
2014-11-13 22:26:49 +00:00
|
|
|
WriteCall(BoundingBox::Update);
|
2014-09-14 16:52:51 +00:00
|
|
|
|
2014-12-21 13:29:44 +00:00
|
|
|
// indexed position formats may skip a the vertex
|
|
|
|
if (m_VtxDesc.Position & 2)
|
|
|
|
{
|
|
|
|
WriteCall(SkipVertex);
|
|
|
|
}
|
|
|
|
|
2014-07-25 23:10:44 +00:00
|
|
|
m_native_components = components;
|
|
|
|
m_native_vtx_decl.stride = nat_offset;
|
2008-12-08 05:25:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void VertexLoader::WriteCall(TPipelineFunction func)
|
|
|
|
{
|
|
|
|
m_PipelineStages[m_numPipelineStages++] = func;
|
2009-01-10 23:10:33 +00:00
|
|
|
}
|
|
|
|
|
2015-02-13 00:50:10 +00:00
|
|
|
int VertexLoader::RunVertices(DataReader src, DataReader dst, int count, int primitive)
|
2008-12-08 05:25:12 +00:00
|
|
|
{
|
2015-01-06 16:49:27 +00:00
|
|
|
g_vertex_manager_write_ptr = dst.GetPointer();
|
|
|
|
g_video_buffer_read_ptr = src.GetPointer();
|
2014-12-18 23:32:46 +00:00
|
|
|
|
2008-12-08 05:25:12 +00:00
|
|
|
m_numLoadedVertices += count;
|
2014-12-21 13:29:44 +00:00
|
|
|
m_skippedVertices = 0;
|
2011-03-04 22:48:54 +00:00
|
|
|
|
Rewrote bounding box algotithm. Fixes issues 5967, 6154, 6196, 6211.
Instead of being vertex-based, it is now primitive (point, line or dissected triangle) based, with proper clipping.
Also, screen position is now calculated based on viewport values, instead of "guesstimating".
This fixes many graphical glitches in Paper Mario: TTYD and Super Paper Mario.
Also, the new code allows Mickey's Magical Mirror and Disney's Hide & Sneak to work (mostly) bug-free. I changed their inis to use bbox.
These changes have a slight cost in performance when bbox is being used (rare), mostly due to the new clipping algorithm.
Please check for any regressions or crashes.
2014-01-25 15:36:23 +00:00
|
|
|
// Prepare bounding box
|
2015-04-06 00:17:57 +00:00
|
|
|
if (!g_ActiveConfig.backend_info.bSupportsBBox && g_ActiveConfig.bBBoxEnable)
|
2014-12-11 21:39:58 +00:00
|
|
|
BoundingBox::Prepare(m_vat, primitive, m_VtxDesc, m_native_vtx_decl);
|
2008-12-08 05:25:12 +00:00
|
|
|
|
2013-02-21 10:36:10 +00:00
|
|
|
for (int s = 0; s < count; s++)
|
|
|
|
{
|
2014-12-13 09:57:46 +00:00
|
|
|
m_tcIndex = 0;
|
|
|
|
m_colIndex = 0;
|
|
|
|
m_texmtxwrite = m_texmtxread = 0;
|
2013-02-21 10:36:10 +00:00
|
|
|
for (int i = 0; i < m_numPipelineStages; i++)
|
2014-12-13 09:57:46 +00:00
|
|
|
m_PipelineStages[i](this);
|
2013-02-21 10:36:10 +00:00
|
|
|
PRIM_LOG("\n");
|
|
|
|
}
|
|
|
|
|
2014-12-21 13:29:44 +00:00
|
|
|
return count - m_skippedVertices;
|
2014-01-30 13:48:23 +00:00
|
|
|
}
|