mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-10-05 18:46:18 +02:00
Merge pull request #7177 from unknownbrackets/spline-minor
Use floats for color values in splines
This commit is contained in:
commit
1dca8bcc92
3 files changed
+28
-18
No files matched your search
+23
-16
@@ -18,12 +18,17 @@
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
|
||||
#if defined(_M_SSE)
|
||||
#include <emmintrin.h>
|
||||
#endif
|
||||
|
||||
#include "Core/Config.h"
|
||||
|
||||
#include "GPU/Common/SplineCommon.h"
|
||||
#include "GPU/ge_constants.h"
|
||||
#include "GPU/GPUState.h"
|
||||
|
||||
|
||||
#define START_OPEN 1
|
||||
#define END_OPEN 2
|
||||
|
||||
@@ -139,8 +144,8 @@ void _SplinePatchLowQuality(u8 *&dest, u16 *indices, int &count, const SplinePat
|
||||
const int tile_max_u = (spatch.type_u & END_OPEN) ? spatch.count_u - 1 : spatch.count_u - 2;
|
||||
const int tile_max_v = (spatch.type_v & END_OPEN) ? spatch.count_v - 1 : spatch.count_v - 2;
|
||||
|
||||
float tu_width = spatch.count_u - 3;
|
||||
float tv_height = spatch.count_v - 3;
|
||||
float tu_width = (float)spatch.count_u - 3.0f;
|
||||
float tv_height = (float)spatch.count_v - 3.0f;
|
||||
tu_width /= (float)(tile_max_u - tile_min_u);
|
||||
tv_height /= (float)(tile_max_v - tile_min_v);
|
||||
|
||||
@@ -224,8 +229,8 @@ void _SplinePatchFullQuality(u8 *&dest, u16 *indices, int &count, const SplineP
|
||||
// First compute all the vertices and put them in an array
|
||||
SimpleVertex *&vertices = (SimpleVertex*&)dest;
|
||||
|
||||
float tu_width = spatch.count_u - 3;
|
||||
float tv_height = spatch.count_v - 3;
|
||||
float tu_width = (float)spatch.count_u - 3.0f;
|
||||
float tv_height = (float)spatch.count_v - 3.0f;
|
||||
|
||||
bool computeNormals = gstate.isLightingEnabled();
|
||||
for (int tile_v = 0; tile_v < patch_div_t + 1; tile_v++) {
|
||||
@@ -237,25 +242,23 @@ void _SplinePatchFullQuality(u8 *&dest, u16 *indices, int &count, const SplineP
|
||||
if (u < 0.0f)
|
||||
u = 0.0f;
|
||||
SimpleVertex *vert = &vertices[tile_v * (patch_div_s + 1) + tile_u];
|
||||
Vec4f vert_color;
|
||||
vert->pos.SetZero();
|
||||
if (origVertType & GE_VTYPE_NRM_MASK) {
|
||||
vert->nrm.SetZero();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
vert->nrm.SetZero();
|
||||
vert->nrm.z = 1.0f;
|
||||
}
|
||||
if (origVertType & GE_VTYPE_COL_MASK) {
|
||||
memset(vert->color, 0, 4);
|
||||
}
|
||||
else {
|
||||
vert_color.SetZero();
|
||||
} else {
|
||||
memcpy(vert->color, spatch.points[0]->color, 4);
|
||||
}
|
||||
if (origVertType & GE_VTYPE_TC_MASK) {
|
||||
vert->uv[0] = 0.0f;
|
||||
vert->uv[1] = 0.0f;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
vert->uv[0] = tu_width * ((float)tile_u / (float)patch_div_s);
|
||||
vert->uv[1] = tv_height * ((float)tile_v / (float)patch_div_t);
|
||||
}
|
||||
@@ -288,11 +291,12 @@ void _SplinePatchFullQuality(u8 *&dest, u16 *indices, int &count, const SplineP
|
||||
vert->uv[1] += a->uv[1] * f;
|
||||
}
|
||||
if (origVertType & GE_VTYPE_COL_MASK) {
|
||||
// TODO: Accumulating values in u8s is crazy. We need floats or something.
|
||||
vert->color[0] += a->color[0] * f;
|
||||
vert->color[1] += a->color[1] * f;
|
||||
vert->color[2] += a->color[2] * f;
|
||||
vert->color[3] += a->color[3] * f;
|
||||
Vec4f a_color = Vec4f::FromRGBA(a->color_32);
|
||||
#ifdef _M_SSE
|
||||
vert_color.vec = _mm_add_ps(vert_color.vec, _mm_mul_ps(a_color.vec, _mm_set_ps1(f)));
|
||||
#else
|
||||
vert_color += a_color * f;
|
||||
#endif
|
||||
}
|
||||
if (origVertType & GE_VTYPE_NRM_MASK) {
|
||||
vert->nrm += a->nrm * f;
|
||||
@@ -303,6 +307,9 @@ void _SplinePatchFullQuality(u8 *&dest, u16 *indices, int &count, const SplineP
|
||||
if (origVertType & GE_VTYPE_NRM_MASK) {
|
||||
vert->nrm.Normalize();
|
||||
}
|
||||
if (origVertType & GE_VTYPE_COL_MASK) {
|
||||
vert->color_32 = vert_color.ToRGBA();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,10 @@
|
||||
// PSP compatible format so we can use the end of the pipeline in beziers etc
|
||||
struct SimpleVertex {
|
||||
float uv[2];
|
||||
u8 color[4];
|
||||
union {
|
||||
u8 color[4];
|
||||
u32_le color_32;
|
||||
};
|
||||
Vec3Packedf nrm;
|
||||
Vec3Packedf pos;
|
||||
};
|
||||
|
||||
+1
-1
@@ -636,7 +636,7 @@ public:
|
||||
|
||||
void SetZero()
|
||||
{
|
||||
x=0; y=0; z=0;
|
||||
x=0; y=0; z=0; w=0;
|
||||
}
|
||||
|
||||
// Common alias: RGBA (colors)
|
||||
|
||||
Reference in new issue
Block a user