struct dd_function_table driver_functions;
struct gl_context share_list;
struct gl_context ctx;
+ _glapi_proc *nop_table;
};
void
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
* _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);
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[] = {