Browse Source

GL: properly test both 32bit and 64bit multidraw index offsets.

pull/240/head
Vladimír Vondruš 5 years ago
parent
commit
3751389e92
  1. 54
      src/Magnum/GL/Test/MeshGLTest.cpp

54
src/Magnum/GL/Test/MeshGLTest.cpp

@ -186,8 +186,8 @@ struct MeshGLTest: OpenGLTester {
void multiDraw(); void multiDraw();
void multiDrawSparseArrays(); void multiDrawSparseArrays();
void multiDrawViews(); void multiDrawViews();
void multiDrawIndexed(); template<class T> void multiDrawIndexed();
void multiDrawIndexedSparseArrays(); template<class T> void multiDrawIndexedSparseArrays();
void multiDrawIndexedViews(); void multiDrawIndexedViews();
void multiDrawWrongVertexOffsetSize(); void multiDrawWrongVertexOffsetSize();
void multiDrawIndexedWrongVertexOffsetSize(); void multiDrawIndexedWrongVertexOffsetSize();
@ -288,12 +288,7 @@ const struct {
Vector4 values[4]; Vector4 values[4];
UnsignedInt indices[4]; UnsignedInt indices[4];
UnsignedInt counts[4]; UnsignedInt counts[4];
#ifdef CORRADE_TARGET_32BIT UnsignedInt indexOffsetsInBytes[4];
UnsignedInt
#else
UnsignedLong
#endif
indexOffsetsInBytes[4];
UnsignedInt vertexOffsets[4]; UnsignedInt vertexOffsets[4];
Vector4 expected; Vector4 expected;
} MultiDrawIndexedData[] { } MultiDrawIndexedData[] {
@ -500,10 +495,17 @@ MeshGLTest::MeshGLTest() {
&MeshGLTest::multiDrawViews}, &MeshGLTest::multiDrawViews},
Containers::arraySize(MultiDrawData)); Containers::arraySize(MultiDrawData));
addInstancedTests({&MeshGLTest::multiDrawIndexed, addInstancedTests({
&MeshGLTest::multiDrawIndexedSparseArrays, &MeshGLTest::multiDrawIndexed<UnsignedInt>,
&MeshGLTest::multiDrawIndexedViews}, #ifndef CORRADE_TARGET_32BIT
Containers::arraySize(MultiDrawIndexedData)); &MeshGLTest::multiDrawIndexed<UnsignedLong>,
#endif
&MeshGLTest::multiDrawIndexedSparseArrays<UnsignedInt>,
#ifndef CORRADE_TARGET_32BIT
&MeshGLTest::multiDrawIndexedSparseArrays<UnsignedLong>,
#endif
&MeshGLTest::multiDrawIndexedViews
}, Containers::arraySize(MultiDrawIndexedData));
addTests({ addTests({
&MeshGLTest::multiDrawWrongVertexOffsetSize, &MeshGLTest::multiDrawWrongVertexOffsetSize,
@ -3777,7 +3779,9 @@ void MeshGLTest::multiDrawViews() {
#endif #endif
} }
void MeshGLTest::multiDrawIndexed() { template<class T> void MeshGLTest::multiDrawIndexed() {
setTestCaseTemplateName(Math::TypeTraits<T>::name());
auto&& data = MultiDrawIndexedData[testCaseInstanceId()]; auto&& data = MultiDrawIndexedData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
@ -3831,8 +3835,16 @@ void MeshGLTest::multiDrawIndexed() {
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
/* Converted to either a 32bit or 64bit type */
const T indexOffsetsInBytes[]{
data.indexOffsetsInBytes[0],
data.indexOffsetsInBytes[1],
data.indexOffsetsInBytes[2],
data.indexOffsetsInBytes[3]
};
MultiDrawChecker checker; MultiDrawChecker checker;
MultiDrawShader{data.vertexId, false}.draw(mesh, data.counts, hasBaseVertex ? Containers::arrayView(data.vertexOffsets) : nullptr, data.indexOffsetsInBytes); MultiDrawShader{data.vertexId, false}.draw(mesh, data.counts, hasBaseVertex ? Containers::arrayView(data.vertexOffsets) : nullptr, indexOffsetsInBytes);
Vector4 value = checker.get(); Vector4 value = checker.get();
MAGNUM_VERIFY_NO_GL_ERROR(); MAGNUM_VERIFY_NO_GL_ERROR();
@ -3845,7 +3857,9 @@ void MeshGLTest::multiDrawIndexed() {
#endif #endif
} }
void MeshGLTest::multiDrawIndexedSparseArrays() { template<class T> void MeshGLTest::multiDrawIndexedSparseArrays() {
setTestCaseTemplateName(Math::TypeTraits<T>::name());
auto&& data = MultiDrawIndexedData[testCaseInstanceId()]; auto&& data = MultiDrawIndexedData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
@ -3904,14 +3918,14 @@ void MeshGLTest::multiDrawIndexedSparseArrays() {
struct Command { struct Command {
UnsignedInt count; UnsignedInt count;
UnsignedInt instanceCount; UnsignedInt instanceCount;
UnsignedInt firstIndexInBytes; /* !! */ T firstIndexInBytes; /* !! */
UnsignedInt baseVertex; UnsignedInt baseVertex;
UnsignedInt baseInstance; UnsignedInt baseInstance;
} commands[] { } commands[] {
{data.counts[0], 0, UnsignedInt(data.indexOffsetsInBytes[0]), data.vertexOffsets[0], 0}, {data.counts[0], 0, data.indexOffsetsInBytes[0], data.vertexOffsets[0], 0},
{data.counts[1], 0, UnsignedInt(data.indexOffsetsInBytes[1]), data.vertexOffsets[1], 0}, {data.counts[1], 0, data.indexOffsetsInBytes[1], data.vertexOffsets[1], 0},
{data.counts[2], 0, UnsignedInt(data.indexOffsetsInBytes[2]), data.vertexOffsets[2], 0}, {data.counts[2], 0, data.indexOffsetsInBytes[2], data.vertexOffsets[2], 0},
{data.counts[3], 0, UnsignedInt(data.indexOffsetsInBytes[3]), data.vertexOffsets[3], 0} {data.counts[3], 0, data.indexOffsetsInBytes[3], data.vertexOffsets[3], 0}
}; };
MultiDrawChecker checker; MultiDrawChecker checker;

Loading…
Cancel
Save