Add a failing test

This commit is contained in:
Luke Benstead 2020-10-27 14:37:25 +00:00
parent 0e780ad271
commit 34741420bc
4 changed files with 36 additions and 16 deletions

View File

@ -20,18 +20,6 @@ static PolyList TR_LIST;
static const int STRIDE = sizeof(Vertex) / sizeof(GLuint);
GL_FORCE_INLINE GLboolean isVertex(const Vertex* vertex) {
return (
vertex->flags == PVR_CMD_VERTEX ||
vertex->flags == PVR_CMD_VERTEX_EOL
);
}
GL_FORCE_INLINE GLboolean isVisible(const Vertex* vertex) {
if(!vertex) return GL_FALSE;
return vertex->w >= 0 && vertex->xyz[2] >= -vertex->w;
}
static Vertex* interpolate_vertex(const Vertex* v0, const Vertex* v1, Vertex* out) {
/* If v0 is in front of the near plane, and v1 is behind the near plane, this
* generates a vertex *on* the near plane */

View File

@ -47,6 +47,18 @@ inline ListIterator* _glIteratorBegin(void* src, int n) {
return (n) ? it : NULL;
}
GL_FORCE_INLINE GLboolean isVertex(const Vertex* vertex) {
return (
vertex->flags == PVR_CMD_VERTEX ||
vertex->flags == PVR_CMD_VERTEX_EOL
);
}
GL_FORCE_INLINE GLboolean isVisible(const Vertex* vertex) {
if(!vertex) return GL_FALSE;
return vertex->w >= 0 && vertex->xyz[2] >= -vertex->w;
}
ListIterator* _glIteratorNext(ListIterator* it);
#ifdef __cplusplus

View File

@ -8,8 +8,10 @@ all: rm-elf $(TARGET)
include $(KOS_BASE)/Makefile.rules
.FORCE:
clean:
-rm -f $(TARGET) $(OBJS) romdisk.* test_runner.o test_runner.cpp
-rm -f $(TARGET) $(OBJS) romdisk.* test_runner.*
rm-elf:
-rm -f $(TARGET) romdisk.*
@ -17,7 +19,7 @@ rm-elf:
test_runner.cpp:
$(shell python3 test_generator.py --output=test_runner.cpp $(TESTS))
test_runner.o: test_runner.cpp
test_runner.o: .FORCE test_runner.cpp
$(TARGET): $(OBJS) romdisk.o
kos-c++ -o $(TARGET) $(OBJS) ../libGLdc.a romdisk.o

View File

@ -33,6 +33,10 @@ private:
class NearZClippingTests : public gldc::test::GLdcTestCase {
public:
void test_clipping_100() {
/* When only the first vertex is visible, we still
* end up with 4 elements (3 vertices + 1 header). The
* first vertex should be the same */
VertexBuilder builder;
std::vector<Vertex> list = builder.
@ -42,13 +46,27 @@ public:
add(0, 1, 2, -1).done();
ListIterator* it = _glIteratorBegin(&list[0], list.size());
Vertex* v0 = it->current;
assert_is_not_null(v0);
it = _glIteratorNext(it);
assert_false(isVertex(v0)); // Should be a header
it = _glIteratorNext(it);
assert_is_not_null(it);
Vertex* v1 = it->current;
assert_is_not_null(v1);
it = _glIteratorNext(it);
assert_is_not_null(it);
Vertex* v2 = it->current;
assert_is_not_null(v2);
it = _glIteratorNext(it);
assert_is_not_null(it);
Vertex* v3 = it->current;
assert_is_not_null(v3);
it = _glIteratorNext(it);
assert_is_null(it);
}
void test_clipping_110() {