2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2009 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 21:29:41 -06:00
|
|
|
// Refer to the license.txt file included.
|
2010-06-08 19:37:08 -06:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2010-06-08 19:37:08 -06:00
|
|
|
|
2017-08-19 09:08:09 -06:00
|
|
|
#include <array>
|
|
|
|
#include <cstddef>
|
|
|
|
|
2016-09-24 03:16:52 -06:00
|
|
|
#include "Common/CommonTypes.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoBackends/Software/Vec3.h"
|
2010-06-08 19:37:08 -06:00
|
|
|
|
|
|
|
struct Vec4
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float z;
|
|
|
|
float w;
|
2010-06-08 19:37:08 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
struct InputVertexData
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
u8 posMtx;
|
2017-08-19 09:08:09 -06:00
|
|
|
std::array<u8, 8> texMtx;
|
2010-06-08 19:37:08 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
Vec3 position;
|
2017-08-19 09:08:09 -06:00
|
|
|
std::array<Vec3, 3> normal;
|
|
|
|
std::array<std::array<u8, 4>, 2> color;
|
|
|
|
std::array<std::array<float, 2>, 8> texCoords;
|
2010-06-08 19:37:08 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
struct OutputVertexData
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
// components in color channels
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
RED_C,
|
|
|
|
GRN_C,
|
|
|
|
BLU_C,
|
|
|
|
ALP_C
|
|
|
|
};
|
2010-12-30 23:45:18 -07:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
Vec3 mvPosition = {};
|
|
|
|
Vec4 projectedPosition = {};
|
|
|
|
Vec3 screenPosition = {};
|
2017-08-19 09:08:09 -06:00
|
|
|
std::array<Vec3, 3> normal{};
|
|
|
|
std::array<std::array<u8, 4>, 2> color{};
|
|
|
|
std::array<Vec3, 8> texCoords{};
|
2010-06-08 19:37:08 -06:00
|
|
|
|
2016-09-22 18:52:35 -06:00
|
|
|
void Lerp(float t, const OutputVertexData* a, const OutputVertexData* b)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
#define LINTERP(T, OUT, IN) (OUT) + ((IN - OUT) * T)
|
2010-06-08 19:37:08 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
#define LINTERP_INT(T, OUT, IN) (OUT) + (((IN - OUT) * T) >> 8)
|
2010-06-08 19:37:08 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
mvPosition = LINTERP(t, a->mvPosition, b->mvPosition);
|
2010-06-08 19:37:08 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
projectedPosition.x = LINTERP(t, a->projectedPosition.x, b->projectedPosition.x);
|
|
|
|
projectedPosition.y = LINTERP(t, a->projectedPosition.y, b->projectedPosition.y);
|
|
|
|
projectedPosition.z = LINTERP(t, a->projectedPosition.z, b->projectedPosition.z);
|
|
|
|
projectedPosition.w = LINTERP(t, a->projectedPosition.w, b->projectedPosition.w);
|
2010-06-08 19:37:08 -06:00
|
|
|
|
2017-08-19 09:08:09 -06:00
|
|
|
for (std::size_t i = 0; i < normal.size(); ++i)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
normal[i] = LINTERP(t, a->normal[i], b->normal[i]);
|
|
|
|
}
|
2013-04-13 21:54:02 -06:00
|
|
|
|
2017-08-19 09:08:09 -06:00
|
|
|
const u16 t_int = static_cast<u16>(t * 256);
|
|
|
|
for (std::size_t i = 0; i < color[0].size(); ++i)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
color[0][i] = LINTERP_INT(t_int, a->color[0][i], b->color[0][i]);
|
|
|
|
color[1][i] = LINTERP_INT(t_int, a->color[1][i], b->color[1][i]);
|
|
|
|
}
|
2013-04-13 21:54:02 -06:00
|
|
|
|
2017-08-19 09:08:09 -06:00
|
|
|
for (std::size_t i = 0; i < texCoords.size(); ++i)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
texCoords[i] = LINTERP(t, a->texCoords[i], b->texCoords[i]);
|
|
|
|
}
|
2013-04-13 21:54:02 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
#undef LINTERP
|
|
|
|
#undef LINTERP_INT
|
|
|
|
}
|
2010-06-08 19:37:08 -06:00
|
|
|
};
|