summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mesa/main/tests/dispatch_sanity.cpp49
1 files changed, 43 insertions, 6 deletions
diff --git a/src/mesa/main/tests/dispatch_sanity.cpp b/src/mesa/main/tests/dispatch_sanity.cpp
index 946eabb7eab..2a5afcd36a4 100644
--- a/src/mesa/main/tests/dispatch_sanity.cpp
+++ b/src/mesa/main/tests/dispatch_sanity.cpp
@@ -82,6 +82,7 @@ public:
struct dd_function_table driver_functions;
struct gl_context share_list;
struct gl_context ctx;
+ _glapi_proc *nop_table;
};
void
@@ -93,6 +94,9 @@ DispatchSanity_test::SetUp()
memset(&ctx, 0, sizeof(ctx));
_mesa_init_driver_functions(&driver_functions);
+
+ const unsigned size = _glapi_get_dispatch_table_size();
+ nop_table = (_glapi_proc *) _glapi_new_nop_table(size);
}
void
@@ -122,11 +126,18 @@ offset_to_proc_name_safe(unsigned offset)
* _glapi_proc *table exist.
*/
static void
-validate_functions(struct gl_context *ctx, const struct function *function_table)
+validate_functions(struct gl_context *ctx, const struct function *function_table,
+ const _glapi_proc *nop_table)
{
_glapi_proc *table = (_glapi_proc *) ctx->Exec;
for (unsigned i = 0; function_table[i].name != NULL; i++) {
+ /* The context version is >= the GL version where the function was
+ * introduced. Therefore, the function cannot be set to the nop
+ * function.
+ */
+ const bool cant_be_nop = ctx->Version >= function_table[i].Version;
+
const int offset = (function_table[i].offset != -1)
? function_table[i].offset
: _glapi_get_proc_offset(function_table[i].name);
@@ -136,32 +147,58 @@ validate_functions(struct gl_context *ctx, const struct function *function_table
ASSERT_EQ(offset,
_glapi_get_proc_offset(function_table[i].name))
<< "Function: " << function_table[i].name;
+ if (cant_be_nop) {
+ EXPECT_NE(nop_table[offset], table[offset])
+ << "Function: " << function_table[i].name
+ << " at offset " << offset;
+ }
+
+ table[offset] = nop_table[offset];
+ }
+}
+
+/* Scan through the table and ensure that there is nothing except
+ * nop functions (as set by validate_functions().
+ */
+static void
+validate_nops(struct gl_context *ctx, const _glapi_proc *nop_table)
+{
+ _glapi_proc *table = (_glapi_proc *) ctx->Exec;
+
+ const unsigned size = _glapi_get_dispatch_table_size();
+ for (unsigned i = 0; i < size; i++) {
+ EXPECT_EQ(nop_table[i], table[i])
+ << "i = " << i << " (" << offset_to_proc_name_safe(i) << ")";
}
}
TEST_F(DispatchSanity_test, GL31_CORE)
{
SetUpCtx(API_OPENGL_CORE, 31);
- validate_functions(&ctx, gl_core_functions_possible);
+ validate_functions(&ctx, gl_core_functions_possible, nop_table);
+ validate_nops(&ctx, nop_table);
}
TEST_F(DispatchSanity_test, GLES11)
{
SetUpCtx(API_OPENGLES, 11);
- validate_functions(&ctx, gles11_functions_possible);
+ validate_functions(&ctx, gles11_functions_possible, nop_table);
+ validate_nops(&ctx, nop_table);
}
TEST_F(DispatchSanity_test, GLES2)
{
SetUpCtx(API_OPENGLES2, 20);
- validate_functions(&ctx, gles2_functions_possible);
+ validate_functions(&ctx, gles2_functions_possible, nop_table);
+ validate_nops(&ctx, nop_table);
}
TEST_F(DispatchSanity_test, GLES3)
{
SetUpCtx(API_OPENGLES2, 30);
- validate_functions(&ctx, gles2_functions_possible);
- validate_functions(&ctx, gles3_functions_possible);
+ validate_functions(&ctx, gles2_functions_possible, nop_table);
+ validate_functions(&ctx, gles3_functions_possible, nop_table);
+ validate_nops(&ctx, nop_table);
}
const struct function gl_core_functions_possible[] = {