mirror of
https://github.com/libretro/ppsspp.git
synced 2025-02-23 18:30:46 +00:00
Add tests for various vertex formats.
This commit is contained in:
parent
e2620a7185
commit
683b3eb082
@ -20,6 +20,7 @@
|
||||
#include "Core/Config.h"
|
||||
#include "GPU/Common/VertexDecoderCommon.h"
|
||||
#include "GPU/ge_constants.h"
|
||||
#include "GPU/GPUState.h"
|
||||
#include "unittest/TestVertexJit.h"
|
||||
#include "unittest/UnitTest.h"
|
||||
|
||||
@ -29,7 +30,7 @@ class VertexDecoderTestHarness {
|
||||
|
||||
public:
|
||||
VertexDecoderTestHarness()
|
||||
: dec_(nullptr), needsReset_(true), dstPos_(0) {
|
||||
: dec_(nullptr), needsReset_(true), dstPos_(0), assertFailed_(false) {
|
||||
src_ = new u8[BUFFER_SIZE];
|
||||
dst_ = new u8[BUFFER_SIZE];
|
||||
cache_ = new VertexDecoderJitCache();
|
||||
@ -108,6 +109,12 @@ public:
|
||||
Add8(y);
|
||||
Add8(z);
|
||||
}
|
||||
void Add8(u8 x, u8 y, u8 z, u8 w) {
|
||||
Add8(x);
|
||||
Add8(y);
|
||||
Add8(z);
|
||||
Add8(w);
|
||||
}
|
||||
|
||||
void Add16(u16_le x) {
|
||||
if (needsReset_) {
|
||||
@ -148,19 +155,98 @@ public:
|
||||
}
|
||||
|
||||
u16 Get16() {
|
||||
u16 result;
|
||||
u16_le result;
|
||||
memcpy(&result, dst_ + dstPos_, sizeof(result));
|
||||
dstPos_ += sizeof(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
float GetFloat() {
|
||||
float result;
|
||||
float_le result;
|
||||
memcpy(&result, dst_ + dstPos_, sizeof(result));
|
||||
dstPos_ += sizeof(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void Assert8(const char *title, u8 x, u8 y) {
|
||||
u8 resx = Get8();
|
||||
u8 resy = Get8();
|
||||
if (resx != x || resy != y) {
|
||||
assertFailed_ = true;
|
||||
printf("%s: Failed %d, %d != expected %d, %d\n", title, resx, resy, x, y);
|
||||
}
|
||||
}
|
||||
void Assert8(const char *title, u8 x, u8 y, u8 z) {
|
||||
u8 resx = Get8();
|
||||
u8 resy = Get8();
|
||||
u8 resz = Get8();
|
||||
if (resx != x || resy != y || resz != z) {
|
||||
assertFailed_ = true;
|
||||
printf("%s: Failed %d, %d, %d != expected %d, %d, %d\n", title, resx, resy, resz, x, y, z);
|
||||
}
|
||||
}
|
||||
void Assert8(const char *title, u8 x, u8 y, u8 z, u8 w) {
|
||||
u8 resx = Get8();
|
||||
u8 resy = Get8();
|
||||
u8 resz = Get8();
|
||||
u8 resw = Get8();
|
||||
if (resx != x || resy != y || resz != z || resw != w) {
|
||||
assertFailed_ = true;
|
||||
printf("%s: Failed %d, %d, %d, %d != expected %d, %d, %d, %d\n", title, resx, resy, resz, resw, x, y, z, w);
|
||||
}
|
||||
}
|
||||
|
||||
void Assert16(const char *title, u16 x, u16 y) {
|
||||
u16 resx = Get16();
|
||||
u16 resy = Get16();
|
||||
if (resx != x || resy != y) {
|
||||
assertFailed_ = true;
|
||||
printf("%s: Failed %d, %d != expected %d, %d\n", title, resx, resy, x, y);
|
||||
}
|
||||
}
|
||||
void Assert16(const char *title, u16 x, u16 y, u16 z) {
|
||||
u16 resx = Get16();
|
||||
u16 resy = Get16();
|
||||
u16 resz = Get16();
|
||||
if (resx != x || resy != y || resz != z) {
|
||||
assertFailed_ = true;
|
||||
printf("%s: Failed %d, %d, %d != expected %d, %d, %d\n", title, resx, resy, resz, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
bool CompareFloat(float a, float b) {
|
||||
return a - fmodf(a, 0.0000001f) == b - fmodf(b, 0.0000001f);
|
||||
}
|
||||
|
||||
void AssertFloat(const char *title, float x) {
|
||||
float resx = GetFloat();
|
||||
if (!CompareFloat(resx, x)) {
|
||||
assertFailed_ = true;
|
||||
printf("%s: Failed %f != expected %f\n", title, resx, x);
|
||||
}
|
||||
}
|
||||
void AssertFloat(const char *title, float x, float y) {
|
||||
float resx = GetFloat();
|
||||
float resy = GetFloat();
|
||||
if (!CompareFloat(resx, x) || !CompareFloat(resy, y)) {
|
||||
assertFailed_ = true;
|
||||
printf("%s: Failed %f, %f != expected %f, %f\n", title, resx, resy, x, y);
|
||||
}
|
||||
}
|
||||
void AssertFloat(const char *title, float x, float y, float z) {
|
||||
float resx = GetFloat();
|
||||
float resy = GetFloat();
|
||||
float resz = GetFloat();
|
||||
if (!CompareFloat(resx, x) || !CompareFloat(resy, y) || !CompareFloat(resz, z)) {
|
||||
assertFailed_ = true;
|
||||
printf("%s: Failed %f, %f, %f != expected %f, %f, %f\n", title, resx, resy, resz, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
void Skip(u32 c) {
|
||||
dstPos_ += c;
|
||||
}
|
||||
|
||||
void *GetData() {
|
||||
return dst_;
|
||||
}
|
||||
@ -172,6 +258,10 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool HasFailed() {
|
||||
return assertFailed_;
|
||||
}
|
||||
|
||||
private:
|
||||
void SetupExecute(int vtype, bool useJit) {
|
||||
if (dec_ != nullptr) {
|
||||
@ -179,6 +269,7 @@ private:
|
||||
}
|
||||
dec_ = new VertexDecoder();
|
||||
dec_->SetVertexType(vtype, options_, useJit ? cache_ : nullptr);
|
||||
dstPos_ = 0;
|
||||
|
||||
needsReset_ = true;
|
||||
}
|
||||
@ -193,19 +284,401 @@ private:
|
||||
bool needsReset_;
|
||||
size_t srcPos_;
|
||||
size_t dstPos_;
|
||||
bool assertFailed_;
|
||||
};
|
||||
|
||||
static bool TestVertex8() {
|
||||
VertexDecoderTestHarness dec;
|
||||
int vtype = GE_VTYPE_POS_8BIT | GE_VTYPE_NRM_8BIT | GE_VTYPE_TC_8BIT;
|
||||
|
||||
dec.Add8(127, 128);
|
||||
dec.Add8(127, 0, 128);
|
||||
dec.Add8(127, 0, 128);
|
||||
|
||||
for (int jit = 0; jit <= 1; ++jit) {
|
||||
dec.Execute(vtype, 0, jit == 1);
|
||||
dec.Assert8("TestVertex8-TC", 127, 128);
|
||||
dec.Skip(2);
|
||||
dec.Assert8("TestVertex8-Nrm", 127, 0, 128);
|
||||
dec.Skip(1);
|
||||
dec.AssertFloat("TestVertex8-Pos", 127.0f / 128.0f, 0.0f, -1.0f);
|
||||
}
|
||||
|
||||
return !dec.HasFailed();
|
||||
}
|
||||
|
||||
static bool TestVertex16() {
|
||||
VertexDecoderTestHarness dec;
|
||||
int vtype = GE_VTYPE_POS_16BIT | GE_VTYPE_NRM_16BIT | GE_VTYPE_TC_16BIT;
|
||||
|
||||
dec.Add16(32767, 32768);
|
||||
dec.Add16(32767, 0, 32768);
|
||||
dec.Add16(32767, 0, 32768);
|
||||
|
||||
for (int jit = 0; jit <= 1; ++jit) {
|
||||
dec.Execute(vtype, 0, jit == 1);
|
||||
dec.Assert16("TestVertex16-TC", 32767, 32768);
|
||||
dec.Assert16("TestVertex16-Nrm", 32767, 0, 32768);
|
||||
dec.Skip(2);
|
||||
dec.AssertFloat("TestVertex16-Pos", 32767.0f / 32768.0f, 0.0f, -1.0f);
|
||||
}
|
||||
|
||||
return !dec.HasFailed();
|
||||
}
|
||||
|
||||
static bool TestVertexFloat() {
|
||||
VertexDecoderTestHarness dec;
|
||||
int vtype = GE_VTYPE_POS_FLOAT | GE_VTYPE_NRM_FLOAT | GE_VTYPE_TC_FLOAT;
|
||||
|
||||
dec.AddFloat(1.0f, -1.0f);
|
||||
dec.AddFloat(1.0f, 0.5f, -1.0f);
|
||||
dec.AddFloat(1.0f, 0.5f, -1.0f);
|
||||
|
||||
for (int jit = 0; jit <= 1; ++jit) {
|
||||
dec.Execute(vtype, 0, jit == 1);
|
||||
dec.AssertFloat("TestVertexFloat-TC", 1.0f, -1.0f);
|
||||
dec.AssertFloat("TestVertexFloat-Nrm", 1.0f, 0.5f, -1.0f);
|
||||
dec.AssertFloat("TestVertexFloat-Pos", 1.0f, 0.5f, -1.0f);
|
||||
}
|
||||
|
||||
return !dec.HasFailed();
|
||||
}
|
||||
|
||||
static bool TestVertex8Through() {
|
||||
VertexDecoderTestHarness dec;
|
||||
int vtype = GE_VTYPE_POS_8BIT | GE_VTYPE_NRM_8BIT | GE_VTYPE_TC_8BIT | GE_VTYPE_THROUGH;
|
||||
|
||||
dec.Add8(127, 128);
|
||||
dec.Add8(127, 0, 128);
|
||||
dec.Add8(127, 0, 128);
|
||||
|
||||
for (int jit = 0; jit <= 1; ++jit) {
|
||||
dec.Execute(vtype, 0, jit == 1);
|
||||
dec.Assert8("TestVertex8Through-TC", 127, 128);
|
||||
dec.Skip(2);
|
||||
dec.Assert8("TestVertex8Through-Nrm", 127, 0, 128);
|
||||
// Ignoring Pos since s8 through isn't really an option.
|
||||
}
|
||||
|
||||
return !dec.HasFailed();
|
||||
}
|
||||
|
||||
static bool TestVertex16Through() {
|
||||
VertexDecoderTestHarness dec;
|
||||
int vtype = GE_VTYPE_POS_16BIT | GE_VTYPE_NRM_16BIT | GE_VTYPE_TC_16BIT | GE_VTYPE_THROUGH;
|
||||
|
||||
dec.Add16(32767, 32768);
|
||||
dec.Add16(32767, 0, 32768);
|
||||
dec.Add16(32767, 0, 32768);
|
||||
|
||||
for (int jit = 0; jit <= 1; ++jit) {
|
||||
dec.Execute(vtype, 0, jit == 1);
|
||||
dec.Assert16("TestVertex16Through-TC", 32767, 32768);
|
||||
dec.Assert16("TestVertex16Through-Nrm", 32767, 0, 32768);
|
||||
dec.Skip(2);
|
||||
dec.AssertFloat("TestVertex16Through-Pos", 32767.0f, 0.0f, 32768.0f);
|
||||
}
|
||||
|
||||
return !dec.HasFailed();
|
||||
}
|
||||
|
||||
static bool TestVertexFloatThrough() {
|
||||
VertexDecoderTestHarness dec;
|
||||
int vtype = GE_VTYPE_POS_FLOAT | GE_VTYPE_NRM_FLOAT | GE_VTYPE_TC_FLOAT | GE_VTYPE_THROUGH;
|
||||
|
||||
dec.AddFloat(1.0f, -1.0f);
|
||||
dec.AddFloat(1.0f, 0.5f, -1.0f);
|
||||
dec.AddFloat(1.0f, 0.5f, -1.0f);
|
||||
|
||||
for (int jit = 0; jit <= 1; ++jit) {
|
||||
dec.Execute(vtype, 0, jit == 1);
|
||||
dec.AssertFloat("TestVertexFloatThrough-TC", 1.0f, -1.0f);
|
||||
dec.AssertFloat("TestVertexFloatThrough-Nrm", 1.0f, 0.5f, -1.0f);
|
||||
dec.AssertFloat("TestVertexFloatThrough-Pos", 1.0f, 0.5f, -1.0f);
|
||||
}
|
||||
|
||||
return !dec.HasFailed();
|
||||
}
|
||||
|
||||
static bool TestVertexColor8888() {
|
||||
VertexDecoderTestHarness dec;
|
||||
int vtype = GE_VTYPE_POS_FLOAT | GE_VTYPE_COL_8888;
|
||||
bool failed = false;
|
||||
|
||||
dec.Add8(1, 2, 3, 4);
|
||||
dec.AddFloat(1.0f, 0.5f, -1.0f);
|
||||
|
||||
for (int jit = 0; jit <= 1; ++jit) {
|
||||
gstate_c.vertexFullAlpha = true;
|
||||
dec.Execute(vtype, 0, jit == 1);
|
||||
dec.Assert8("TestVertexColor8888-Col", 1, 2, 3, 4);
|
||||
dec.AssertFloat("TestVertexColor8888-Pos", 1.0f, 0.5f, -1.0f);
|
||||
|
||||
if (gstate_c.vertexFullAlpha) {
|
||||
printf("TestVertexColor8888: failed to clear vertexFullAlpha\n");
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
dec.Add8(255, 255, 255, 255);
|
||||
dec.AddFloat(1.0f, 0.5f, -1.0f);
|
||||
|
||||
for (int jit = 0; jit <= 1; ++jit) {
|
||||
gstate_c.vertexFullAlpha = true;
|
||||
dec.Execute(vtype, 0, jit == 1);
|
||||
dec.Assert8("TestVertexColor8888-Col", 255, 255, 255, 255);
|
||||
dec.AssertFloat("TestVertexColor8888-Pos", 1.0f, 0.5f, -1.0f);
|
||||
|
||||
if (!gstate_c.vertexFullAlpha) {
|
||||
printf("TestVertexColor8888: cleared vertexFullAlpha\n");
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return !dec.HasFailed() && !failed;
|
||||
}
|
||||
|
||||
static bool TestVertexColor4444() {
|
||||
VertexDecoderTestHarness dec;
|
||||
int vtype = GE_VTYPE_POS_FLOAT | GE_VTYPE_COL_4444;
|
||||
bool failed = false;
|
||||
|
||||
dec.Add16(0x1234, 0);
|
||||
dec.AddFloat(1.0f, 0.5f, -1.0f);
|
||||
|
||||
for (int jit = 0; jit <= 1; ++jit) {
|
||||
gstate_c.vertexFullAlpha = true;
|
||||
dec.Execute(vtype, 0, jit == 1);
|
||||
dec.Assert8("TestVertexColor4444-Col", 0x44, 0x33, 0x22, 0x11);
|
||||
dec.AssertFloat("TestVertexColor4444-Pos", 1.0f, 0.5f, -1.0f);
|
||||
|
||||
if (gstate_c.vertexFullAlpha) {
|
||||
printf("TestVertexColor4444: failed to clear vertexFullAlpha\n");
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
dec.Add16(0xFFFF, 0);
|
||||
dec.AddFloat(1.0f, 0.5f, -1.0f);
|
||||
|
||||
for (int jit = 0; jit <= 1; ++jit) {
|
||||
gstate_c.vertexFullAlpha = true;
|
||||
dec.Execute(vtype, 0, jit == 1);
|
||||
dec.Assert8("TestVertexColor4444-Col", 255, 255, 255, 255);
|
||||
dec.AssertFloat("TestVertexColor4444-Pos", 1.0f, 0.5f, -1.0f);
|
||||
|
||||
if (!gstate_c.vertexFullAlpha) {
|
||||
printf("TestVertexColor4444: cleared vertexFullAlpha\n");
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return !dec.HasFailed() && !failed;
|
||||
}
|
||||
|
||||
static bool TestVertexColor5551() {
|
||||
VertexDecoderTestHarness dec;
|
||||
int vtype = GE_VTYPE_POS_FLOAT | GE_VTYPE_COL_5551;
|
||||
bool failed = false;
|
||||
|
||||
dec.Add16((0 << 15) | (1 << 10) | (2 << 5) | 3, 0);
|
||||
dec.AddFloat(1.0f, 0.5f, -1.0f);
|
||||
|
||||
for (int jit = 0; jit <= 1; ++jit) {
|
||||
gstate_c.vertexFullAlpha = true;
|
||||
dec.Execute(vtype, 0, jit == 1);
|
||||
dec.Assert8("TestVertexColor5551-Col", 0x18, 0x10, 0x8, 0x0);
|
||||
dec.AssertFloat("TestVertexColor5551-Pos", 1.0f, 0.5f, -1.0f);
|
||||
|
||||
if (gstate_c.vertexFullAlpha) {
|
||||
printf("TestVertexColor5551: failed to clear vertexFullAlpha\n");
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
dec.Add16(0xFFFF, 0);
|
||||
dec.AddFloat(1.0f, 0.5f, -1.0f);
|
||||
|
||||
for (int jit = 0; jit <= 1; ++jit) {
|
||||
gstate_c.vertexFullAlpha = true;
|
||||
dec.Execute(vtype, 0, jit == 1);
|
||||
dec.Assert8("TestVertexColor5551-Col", 255, 255, 255, 255);
|
||||
dec.AssertFloat("TestVertexColor5551-Pos", 1.0f, 0.5f, -1.0f);
|
||||
|
||||
if (!gstate_c.vertexFullAlpha) {
|
||||
printf("TestVertexColor5551: cleared vertexFullAlpha\n");
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return !dec.HasFailed() && !failed;
|
||||
}
|
||||
|
||||
static bool TestVertexColor565() {
|
||||
VertexDecoderTestHarness dec;
|
||||
int vtype = GE_VTYPE_POS_FLOAT | GE_VTYPE_COL_565;
|
||||
bool failed = false;
|
||||
|
||||
dec.Add16((1 << 11) | (2 << 5) | 3, 0);
|
||||
dec.AddFloat(1.0f, 0.5f, -1.0f);
|
||||
|
||||
for (int jit = 0; jit <= 1; ++jit) {
|
||||
gstate_c.vertexFullAlpha = true;
|
||||
dec.Execute(vtype, 0, jit == 1);
|
||||
dec.Assert8("TestVertexColor565-Col", 0x18, 0x8, 0x8, 255);
|
||||
dec.AssertFloat("TestVertexColor565-Pos", 1.0f, 0.5f, -1.0f);
|
||||
|
||||
if (!gstate_c.vertexFullAlpha) {
|
||||
printf("TestVertexColor565: cleared vertexFullAlpha\n");
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return !dec.HasFailed() && !failed;
|
||||
}
|
||||
|
||||
static bool TestVertex8Skin() {
|
||||
VertexDecoderTestHarness dec;
|
||||
|
||||
g_Config.bSoftwareSkinning = true;
|
||||
for (int i = 0; i < 8 * 12; ++i) {
|
||||
gstate.boneMatrix[i] = 0.0f;
|
||||
}
|
||||
gstate.boneMatrix[0] = 2.0f;
|
||||
gstate.boneMatrix[4] = 1.0f;
|
||||
gstate.boneMatrix[8] = 5.0f;
|
||||
|
||||
gstate.boneMatrix[12] = 1.0f;
|
||||
gstate.boneMatrix[16] = 2.0f;
|
||||
gstate.boneMatrix[20] = 5.0f;
|
||||
|
||||
int vtype = GE_VTYPE_POS_8BIT | GE_VTYPE_NRM_8BIT | GE_VTYPE_WEIGHT_8BIT | (1 << GE_VTYPE_WEIGHTCOUNT_SHIFT);
|
||||
|
||||
dec.Add8(128 + 64, 128 - 64);
|
||||
dec.Add8(127, 0, 128);
|
||||
dec.Add8(127, 0, 128);
|
||||
|
||||
for (int jit = 0; jit <= 1; ++jit) {
|
||||
dec.Execute(vtype, 0, jit == 1);
|
||||
dec.AssertFloat("TestVertex8Skin-Nrm", (2.0f * 1.5f + 1.0f * 0.5f) * 127.0f / 128.0f, 0.0f, 2.0f * 5.0f * -1.0f);
|
||||
dec.AssertFloat("TestVertex8Skin-Pos", (2.0f * 1.5f + 1.0f * 0.5f) * 127.0f / 128.0f, 0.0f, 2.0f * 5.0f * -1.0f);
|
||||
}
|
||||
|
||||
return !dec.HasFailed();
|
||||
}
|
||||
|
||||
static bool TestVertex16Skin() {
|
||||
VertexDecoderTestHarness dec;
|
||||
|
||||
g_Config.bSoftwareSkinning = true;
|
||||
for (int i = 0; i < 8 * 12; ++i) {
|
||||
gstate.boneMatrix[i] = 0.0f;
|
||||
}
|
||||
gstate.boneMatrix[0] = 2.0f;
|
||||
gstate.boneMatrix[4] = 1.0f;
|
||||
gstate.boneMatrix[8] = 5.0f;
|
||||
|
||||
gstate.boneMatrix[12] = 1.0f;
|
||||
gstate.boneMatrix[16] = 2.0f;
|
||||
gstate.boneMatrix[20] = 5.0f;
|
||||
|
||||
int vtype = GE_VTYPE_POS_16BIT | GE_VTYPE_NRM_16BIT | GE_VTYPE_WEIGHT_16BIT | (1 << GE_VTYPE_WEIGHTCOUNT_SHIFT);
|
||||
|
||||
dec.Add16(32768 + 16384, 32768 - 16384);
|
||||
dec.Add16(32767, 0, 32768);
|
||||
dec.Add16(32767, 0, 32768);
|
||||
|
||||
for (int jit = 0; jit <= 1; ++jit) {
|
||||
dec.Execute(vtype, 0, jit == 1);
|
||||
dec.AssertFloat("TestVertex16Skin-Nrm", (2.0f * 1.5f + 1.0f * 0.5f) * 32767.0f / 32768.0f, 0.0f, 2.0f * 5.0f * -1.0f);
|
||||
dec.AssertFloat("TestVertex16Skin-Pos", (2.0f * 1.5f + 1.0f * 0.5f) * 32767.0f / 32768.0f, 0.0f, 2.0f * 5.0f * -1.0f);
|
||||
}
|
||||
|
||||
return !dec.HasFailed();
|
||||
}
|
||||
|
||||
static bool TestVertexFloatSkin() {
|
||||
VertexDecoderTestHarness dec;
|
||||
|
||||
g_Config.bSoftwareSkinning = true;
|
||||
for (int i = 0; i < 8 * 12; ++i) {
|
||||
gstate.boneMatrix[i] = 0.0f;
|
||||
}
|
||||
gstate.boneMatrix[0] = 2.0f;
|
||||
gstate.boneMatrix[4] = 1.0f;
|
||||
gstate.boneMatrix[8] = 5.0f;
|
||||
|
||||
gstate.boneMatrix[12] = 1.0f;
|
||||
gstate.boneMatrix[16] = 2.0f;
|
||||
gstate.boneMatrix[20] = 5.0f;
|
||||
|
||||
int vtype = GE_VTYPE_POS_FLOAT | GE_VTYPE_NRM_FLOAT | GE_VTYPE_WEIGHT_FLOAT | (1 << GE_VTYPE_WEIGHTCOUNT_SHIFT);
|
||||
|
||||
dec.AddFloat(1.5f, 0.5f);
|
||||
dec.AddFloat(1.0f, 0, -1.0f);
|
||||
dec.AddFloat(1.0f, 0, -1.0f);
|
||||
|
||||
for (int jit = 0; jit <= 1; ++jit) {
|
||||
dec.Execute(vtype, 0, jit == 1);
|
||||
dec.AssertFloat("TestVertexFloatSkin-Nrm", (2.0f * 1.5f + 1.0f * 0.5f) * 1.0f, 0.0f, 2.0f * 5.0f * -1.0f);
|
||||
dec.AssertFloat("TestVertexFloatSkin-Pos", (2.0f * 1.5f + 1.0f * 0.5f) * 1.0f, 0.0f, 2.0f * 5.0f * -1.0f);
|
||||
}
|
||||
|
||||
return !dec.HasFailed();
|
||||
}
|
||||
|
||||
// TODO: Morph (col, pos, nrm), weights (no skin), morph + weights?
|
||||
|
||||
typedef bool (*VertexTestFunc)();
|
||||
|
||||
static VertexTestFunc vertdecTestFuncs[] = {
|
||||
&TestVertex8,
|
||||
&TestVertex16,
|
||||
&TestVertexFloat,
|
||||
|
||||
&TestVertex8Through,
|
||||
&TestVertex16Through,
|
||||
&TestVertexFloatThrough,
|
||||
|
||||
&TestVertexColor8888,
|
||||
&TestVertexColor4444,
|
||||
&TestVertexColor5551,
|
||||
&TestVertexColor565,
|
||||
|
||||
&TestVertex8Skin,
|
||||
&TestVertex16Skin,
|
||||
&TestVertexFloatSkin,
|
||||
};
|
||||
|
||||
bool TestVertexJit() {
|
||||
VertexDecoderTestHarness dec;
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
/*for (int i = 0; i < 100; ++i) {
|
||||
dec.AddFloat(0.5f, 1.0f, -1.0f);
|
||||
}
|
||||
int vtype = GE_VTYPE_POS_FLOAT;
|
||||
int vtype = GE_VTYPE_POS_FLOAT;*/
|
||||
/*for (int i = 0; i < 100; ++i) {
|
||||
dec.Add16(32767, 0, 32768);
|
||||
}
|
||||
int vtype = GE_VTYPE_POS_16BIT;*/
|
||||
for (int i = 0; i < 100; ++i) {
|
||||
dec.Add8(127, 0, 128);
|
||||
}
|
||||
int vtype = GE_VTYPE_POS_8BIT;
|
||||
double yesJit = dec.ExecuteTimed(vtype, 100, true);
|
||||
double noJit = dec.ExecuteTimed(vtype, 100, false);
|
||||
|
||||
printf("Result: %f, %f, %f\n", dec.GetFloat(), dec.GetFloat(), dec.GetFloat());
|
||||
float x = dec.GetFloat();
|
||||
float y = dec.GetFloat();
|
||||
float z = dec.GetFloat();
|
||||
printf("Result: %f, %f, %f\n", x, y, z);
|
||||
printf("Jit was %fx faster than steps.\n\n", yesJit / noJit);
|
||||
|
||||
return yesJit > noJit;
|
||||
bool pass = true;
|
||||
for (size_t i = 0; i < ARRAY_SIZE(vertdecTestFuncs); ++i) {
|
||||
if (!vertdecTestFuncs[i]()) {
|
||||
pass = false;
|
||||
}
|
||||
}
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user