Replace the disable-npots tool with a COGL_DEBUG option
Previously in the tests/tools directory we build a disable-npots library which was used as an LD_PRELOAD to trick Cogl in to thinking there is no NPOT texture extension. This is a little awkward to use so it seems much simpler to just define a COGL_DEBUG option to disable npot textures.
This commit is contained in:
parent
632412c9c8
commit
8112bfc49f
@ -127,6 +127,12 @@ OPT (DISABLE_BLENDING,
|
|||||||
"disable-blending",
|
"disable-blending",
|
||||||
"Disable blending",
|
"Disable blending",
|
||||||
"Disable use of blending")
|
"Disable use of blending")
|
||||||
|
OPT (DISABLE_NPOT_TEXTURES,
|
||||||
|
"Root Cause",
|
||||||
|
"disable-npot-textures",
|
||||||
|
"Disable non-power-of-two textures",
|
||||||
|
"Makes Cogl think that the GL driver doesn't support NPOT textures "
|
||||||
|
"so that it will create sliced textures or textures with waste instead.")
|
||||||
OPT (SHOW_SOURCE,
|
OPT (SHOW_SOURCE,
|
||||||
"Cogl Tracing",
|
"Cogl Tracing",
|
||||||
"show-source",
|
"show-source",
|
||||||
|
@ -69,7 +69,8 @@ static const GDebugKey cogl_behavioural_debug_keys[] = {
|
|||||||
{ "disable-texturing", COGL_DEBUG_DISABLE_TEXTURING},
|
{ "disable-texturing", COGL_DEBUG_DISABLE_TEXTURING},
|
||||||
{ "disable-arbfp", COGL_DEBUG_DISABLE_ARBFP},
|
{ "disable-arbfp", COGL_DEBUG_DISABLE_ARBFP},
|
||||||
{ "disable-glsl", COGL_DEBUG_DISABLE_GLSL},
|
{ "disable-glsl", COGL_DEBUG_DISABLE_GLSL},
|
||||||
{ "disable-blending", COGL_DEBUG_DISABLE_BLENDING}
|
{ "disable-blending", COGL_DEBUG_DISABLE_BLENDING},
|
||||||
|
{ "disable-npot-textures", COGL_DEBUG_DISABLE_NPOT_TEXTURES}
|
||||||
};
|
};
|
||||||
static const int n_cogl_behavioural_debug_keys =
|
static const int n_cogl_behavioural_debug_keys =
|
||||||
G_N_ELEMENTS (cogl_behavioural_debug_keys);
|
G_N_ELEMENTS (cogl_behavioural_debug_keys);
|
||||||
|
@ -55,7 +55,8 @@ typedef enum {
|
|||||||
COGL_DEBUG_SHOW_SOURCE = 1 << 22,
|
COGL_DEBUG_SHOW_SOURCE = 1 << 22,
|
||||||
COGL_DEBUG_DISABLE_BLENDING = 1 << 23,
|
COGL_DEBUG_DISABLE_BLENDING = 1 << 23,
|
||||||
COGL_DEBUG_TEXTURE_PIXMAP = 1 << 24,
|
COGL_DEBUG_TEXTURE_PIXMAP = 1 << 24,
|
||||||
COGL_DEBUG_BITMAP = 1 << 25
|
COGL_DEBUG_BITMAP = 1 << 25,
|
||||||
|
COGL_DEBUG_DISABLE_NPOT_TEXTURES = 1 << 26
|
||||||
} CoglDebugFlags;
|
} CoglDebugFlags;
|
||||||
|
|
||||||
#ifdef COGL_ENABLE_DEBUG
|
#ifdef COGL_ENABLE_DEBUG
|
||||||
|
@ -444,6 +444,12 @@ cogl_get_features (void)
|
|||||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_GLSL))
|
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_GLSL))
|
||||||
ctx->feature_flags &= ~COGL_FEATURE_SHADERS_GLSL;
|
ctx->feature_flags &= ~COGL_FEATURE_SHADERS_GLSL;
|
||||||
|
|
||||||
|
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_NPOT_TEXTURES))
|
||||||
|
ctx->feature_flags &= ~(COGL_FEATURE_TEXTURE_NPOT |
|
||||||
|
COGL_FEATURE_TEXTURE_NPOT_BASIC |
|
||||||
|
COGL_FEATURE_TEXTURE_NPOT_MIPMAP |
|
||||||
|
COGL_FEATURE_TEXTURE_NPOT_REPEAT);
|
||||||
|
|
||||||
return ctx->feature_flags;
|
return ctx->feature_flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,10 +165,6 @@ AC_ARG_WITH([gles],
|
|||||||
# backend specific pkg-config files
|
# backend specific pkg-config files
|
||||||
BACKEND_PC_FILES=""
|
BACKEND_PC_FILES=""
|
||||||
|
|
||||||
# This is only used to decide whether to build tests/tools/disable-npots.la
|
|
||||||
AC_CHECK_LIB(dl, [dlopen], [HAVE_LIBDL=yes], [HAVE_LIBDL=no])
|
|
||||||
AM_CONDITIONAL(HAVE_LIBDL, [test "x$HAVE_LIBDL" = "xyes"])
|
|
||||||
|
|
||||||
dnl === Clutter windowing system backend ======================================
|
dnl === Clutter windowing system backend ======================================
|
||||||
|
|
||||||
AS_CASE([$CLUTTER_FLAVOUR],
|
AS_CASE([$CLUTTER_FLAVOUR],
|
||||||
@ -1110,7 +1106,6 @@ AC_CONFIG_FILES([
|
|||||||
tests/interactive/Makefile
|
tests/interactive/Makefile
|
||||||
tests/interactive/wrapper.sh
|
tests/interactive/wrapper.sh
|
||||||
tests/micro-bench/Makefile
|
tests/micro-bench/Makefile
|
||||||
tests/tools/Makefile
|
|
||||||
|
|
||||||
doc/Makefile
|
doc/Makefile
|
||||||
doc/reference/Makefile
|
doc/reference/Makefile
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
SUBDIRS = accessibility data interactive micro-bench tools
|
SUBDIRS = accessibility data interactive micro-bench
|
||||||
|
|
||||||
if BUILD_TESTS
|
if BUILD_TESTS
|
||||||
SUBDIRS += conform
|
SUBDIRS += conform
|
||||||
endif
|
endif
|
||||||
|
|
||||||
DIST_SUBDIRS = accessibility data conform interactive micro-bench tools
|
DIST_SUBDIRS = accessibility data conform interactive micro-bench
|
||||||
|
|
||||||
EXTRA_DIST = README
|
EXTRA_DIST = README
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ test-report perf-report full-report: ${TEST_PROGS}
|
|||||||
# two textures
|
# two textures
|
||||||
test-report-npot perf-report-npot full-report-npot: ${TEST_PROGS}
|
test-report-npot perf-report-npot full-report-npot: ${TEST_PROGS}
|
||||||
@test -z "${TEST_PROGS}" || { \
|
@test -z "${TEST_PROGS}" || { \
|
||||||
$(top_srcdir)/tests/tools/disable-npots.sh ; \
|
export COGL_DEBUG="$COGL_DEBUG,disable-npot-textures"; \
|
||||||
export GTESTER_LOGDIR=`mktemp -d "$(srcdir)/.testlogs-XXXXXX"` ; \
|
export GTESTER_LOGDIR=`mktemp -d "$(srcdir)/.testlogs-XXXXXX"` ; \
|
||||||
if test -d "$(top_srcdir)/.git"; then \
|
if test -d "$(top_srcdir)/.git"; then \
|
||||||
export REVISION="`git describe`" ; \
|
export REVISION="`git describe`" ; \
|
||||||
|
@ -1,43 +0,0 @@
|
|||||||
include $(top_srcdir)/build/autotools/Makefile.am.silent
|
|
||||||
|
|
||||||
noinst_LTLIBRARIES =
|
|
||||||
|
|
||||||
build_shared_libs =
|
|
||||||
|
|
||||||
if HAVE_LIBDL
|
|
||||||
|
|
||||||
noinst_LTLIBRARIES += libdisable-npots-static.la
|
|
||||||
|
|
||||||
build_shared_libs += libdisable-npots.la
|
|
||||||
|
|
||||||
endif
|
|
||||||
|
|
||||||
libdisable_npots_static_la_SOURCES = disable-npots.c
|
|
||||||
|
|
||||||
libdisable_npots_static_la_LIBADD = -ldl
|
|
||||||
|
|
||||||
INCLUDES = \
|
|
||||||
-I$(top_srcdir)/clutter \
|
|
||||||
-I$(top_srcdir)/clutter/cogl \
|
|
||||||
-I$(top_builddir)/clutter \
|
|
||||||
-I$(top_builddir)/clutter/cogl \
|
|
||||||
$(CLUTTER_CFLAGS) \
|
|
||||||
-D_GNU_SOURCE
|
|
||||||
|
|
||||||
all-local : disable-npots.sh $(build_shared_libs)
|
|
||||||
|
|
||||||
clean-local :
|
|
||||||
$(QUIET_RM)rm -f disable-npots.sh libdisable-npots.la
|
|
||||||
|
|
||||||
disable-npots.sh : $(top_builddir)/tests/tools/disable-npots.sh.in
|
|
||||||
$(QUIET_GEN) \
|
|
||||||
sed 's|--builddir--|'`cd '$(top_builddir)' && pwd`'|' < $< > $@ \
|
|
||||||
&& chmod 755 disable-npots.sh
|
|
||||||
|
|
||||||
# Also put the static library into a shared library. We need to do
|
|
||||||
# this without the automake magic because we don't want it to get
|
|
||||||
# installed
|
|
||||||
libdisable-npots.la : libdisable-npots-static.la
|
|
||||||
$(LINK) -ldl -rpath /nowhere libdisable-npots-static.la
|
|
||||||
|
|
||||||
EXTRA_DIST = README disable-npots.sh.in
|
|
@ -1,2 +0,0 @@
|
|||||||
This is a place holder for tools such as gltrace like libraries
|
|
||||||
|
|
@ -1,156 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file can be build as a shared library and then used as an
|
|
||||||
* LD_PRELOAD to fake a system where NPOTs is not supported. It simply
|
|
||||||
* overrides glGetString and removes the extension strings.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* This is just included to get the right GL header */
|
|
||||||
#include <cogl/cogl.h>
|
|
||||||
|
|
||||||
#include <dlfcn.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
/* If RTLD_NEXT isn't available then try just using NULL */
|
|
||||||
#ifdef RTLD_NEXT
|
|
||||||
#define LIB_HANDLE RTLD_NEXT
|
|
||||||
#else
|
|
||||||
#define LIB_HANDLE NULL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef const GLubyte * (* GetStringFunc) (GLenum name);
|
|
||||||
|
|
||||||
static const char * const bad_strings[]
|
|
||||||
= { "GL_ARB_texture_non_power_of_two",
|
|
||||||
"GL_ARB_texture_rectangle",
|
|
||||||
"GL_EXT_texture_rectangle",
|
|
||||||
NULL };
|
|
||||||
|
|
||||||
static gboolean
|
|
||||||
get_gl_version (const gchar *version_string,
|
|
||||||
int *major_out, int *minor_out)
|
|
||||||
{
|
|
||||||
const char *major_end, *minor_end;
|
|
||||||
int major = 0, minor = 0;
|
|
||||||
|
|
||||||
if (version_string == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* Extract the major number */
|
|
||||||
for (major_end = version_string; *major_end >= '0'
|
|
||||||
&& *major_end <= '9'; major_end++)
|
|
||||||
major = (major * 10) + *major_end - '0';
|
|
||||||
/* If there were no digits or the major number isn't followed by a
|
|
||||||
dot then it is invalid */
|
|
||||||
if (major_end == version_string || *major_end != '.')
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
/* Extract the minor number */
|
|
||||||
for (minor_end = major_end + 1; *minor_end >= '0'
|
|
||||||
&& *minor_end <= '9'; minor_end++)
|
|
||||||
minor = (minor * 10) + *minor_end - '0';
|
|
||||||
/* If there were no digits or there is an unexpected character then
|
|
||||||
it is invalid */
|
|
||||||
if (minor_end == major_end + 1
|
|
||||||
|| (*minor_end && *minor_end != ' ' && *minor_end != '.'))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
*major_out = major;
|
|
||||||
*minor_out = minor;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
const GLubyte *
|
|
||||||
glGetString (GLenum name)
|
|
||||||
{
|
|
||||||
const gchar *ret = NULL;
|
|
||||||
static GetStringFunc func = NULL;
|
|
||||||
static gchar *extensions = NULL;
|
|
||||||
static gchar *version = NULL;
|
|
||||||
|
|
||||||
if (func == NULL
|
|
||||||
&& (func = (GetStringFunc) dlsym (LIB_HANDLE, "glGetString")) == NULL)
|
|
||||||
fprintf (stderr, "dlsym: %s\n", dlerror ());
|
|
||||||
else if (func == glGetString)
|
|
||||||
fprintf (stderr, "dlsym returned the wrapper of glGetString\n");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ret = (const gchar *) (* func) (name);
|
|
||||||
|
|
||||||
if (name == GL_EXTENSIONS)
|
|
||||||
{
|
|
||||||
if (extensions == NULL)
|
|
||||||
{
|
|
||||||
if ((extensions = strdup ((char *) ret)) == NULL)
|
|
||||||
fprintf (stderr, "strdup: %s\n", strerror (errno));
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gchar *dst = extensions, *src = extensions;
|
|
||||||
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
const char * const *str = bad_strings;
|
|
||||||
gchar *end;
|
|
||||||
|
|
||||||
while (isspace (*src))
|
|
||||||
*(dst++) = *(src++);
|
|
||||||
|
|
||||||
if (*src == 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
for (end = src + 1; *end && !isspace (*end); end++);
|
|
||||||
|
|
||||||
while (*str && strncmp ((char *) src, *str, end - src))
|
|
||||||
str++;
|
|
||||||
|
|
||||||
if (*str == NULL)
|
|
||||||
{
|
|
||||||
memcpy (dst, src, end - src);
|
|
||||||
dst += end - src;
|
|
||||||
}
|
|
||||||
|
|
||||||
src = end;
|
|
||||||
}
|
|
||||||
|
|
||||||
*dst = '\0';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = extensions;
|
|
||||||
}
|
|
||||||
else if (name == GL_VERSION)
|
|
||||||
{
|
|
||||||
int gl_major, gl_minor;
|
|
||||||
|
|
||||||
/* If the GL version is >= 2.0 then Cogl will assume it
|
|
||||||
supports NPOT textures anyway so we need to tweak it */
|
|
||||||
if (get_gl_version ((const gchar *) ret,
|
|
||||||
&gl_major, &gl_minor) && gl_major >= 2)
|
|
||||||
{
|
|
||||||
if (version == NULL)
|
|
||||||
{
|
|
||||||
const gchar *tail = strchr (ret, ' ');
|
|
||||||
if (tail)
|
|
||||||
{
|
|
||||||
version = malloc (3 + strlen (tail) + 1);
|
|
||||||
if (version)
|
|
||||||
{
|
|
||||||
strcpy (version + 3, tail);
|
|
||||||
memcpy (version, "1.9", 3);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
version = strdup ("1.9");
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (const GLubyte *) ret;
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
# This script sets up the LD_PRELOAD environment to use
|
|
||||||
# libdisable-npots.la
|
|
||||||
|
|
||||||
# Read the .la file so we can get the library name
|
|
||||||
. "--builddir--/tests/tools/libdisable-npots.la"
|
|
||||||
|
|
||||||
if test -n "$LD_PRELOAD"; then
|
|
||||||
LD_PRELOAD="${LD_PRELOAD}:";
|
|
||||||
fi
|
|
||||||
|
|
||||||
export LD_PRELOAD="${LD_PRELOAD}--builddir--/tests/tools/.libs/${dlname}"
|
|
||||||
|
|
||||||
exec "$@"
|
|
Loading…
x
Reference in New Issue
Block a user