summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2012-07-06 10:37:52 +0100
committerJosé Fonseca <[email protected]>2012-07-06 20:22:29 +0100
commitff8ddf399adb58d7c33863ec9c6eeaa7aed71599 (patch)
tree48ecb28ea95602e46c59155fa73f44cba4913ae0
parentf8e13e6d699b7251994cb367bf0609c54dccd87d (diff)
galahad: More detailed resource checks.
-rw-r--r--src/gallium/drivers/galahad/glhd_context.h3
-rw-r--r--src/gallium/drivers/galahad/glhd_screen.c80
2 files changed, 64 insertions, 19 deletions
diff --git a/src/gallium/drivers/galahad/glhd_context.h b/src/gallium/drivers/galahad/glhd_context.h
index 58ced834505..53d450fd742 100644
--- a/src/gallium/drivers/galahad/glhd_context.h
+++ b/src/gallium/drivers/galahad/glhd_context.h
@@ -60,6 +60,9 @@ do { \
debug_printf("\n"); \
} while (0)
+#define glhd_check(fmt, value, expr) \
+ ((value expr) ? (void)0 : debug_printf("galahad: %s:%u: Expected `%s %s`, got %s == " fmt "\n", __FUNCTION__, __LINE__, #value, #expr, #value, value))
+
#define glhd_error(...) \
glhd_warn(__VA_ARGS__);
diff --git a/src/gallium/drivers/galahad/glhd_screen.c b/src/gallium/drivers/galahad/glhd_screen.c
index 022a0096664..309e55d3b47 100644
--- a/src/gallium/drivers/galahad/glhd_screen.c
+++ b/src/gallium/drivers/galahad/glhd_screen.c
@@ -144,8 +144,68 @@ galahad_screen_resource_create(struct pipe_screen *_screen,
struct pipe_screen *screen = glhd_screen->screen;
struct pipe_resource *result;
- if (templat->target >= PIPE_MAX_TEXTURE_TYPES)
+ glhd_check("%u", templat->width0, >= 1);
+ glhd_check("%u", templat->height0, >= 1);
+ glhd_check("%u", templat->depth0, >= 1);
+ glhd_check("%u", templat->array_size, >= 1);
+
+ if (templat->target == PIPE_BUFFER) {
+ glhd_check("%u", templat->last_level, == 0);
+ glhd_check("%u", templat->height0, == 1);
+ glhd_check("%u", templat->depth0, == 1);
+ glhd_check("%u", templat->array_size, == 1);
+ } else if (templat->target == PIPE_TEXTURE_1D) {
+ unsigned max_texture_2d_levels = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS);
+ glhd_check("%u", templat->last_level, < max_texture_2d_levels);
+ glhd_check("%u", templat->width0, <= (1 << (max_texture_2d_levels - 1)));
+ glhd_check("%u", templat->height0, == 1);
+ glhd_check("%u", templat->depth0, == 1);
+ glhd_check("%u", templat->array_size, == 1);
+ } else if (templat->target == PIPE_TEXTURE_2D) {
+ unsigned max_texture_2d_levels = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS);
+ glhd_check("%u", templat->last_level, < max_texture_2d_levels);
+ glhd_check("%u", templat->width0, <= (1 << (max_texture_2d_levels - 1)));
+ glhd_check("%u", templat->height0, <= (1 << (max_texture_2d_levels - 1)));
+ glhd_check("%u", templat->depth0, == 1);
+ glhd_check("%u", templat->array_size, == 1);
+ } else if (templat->target == PIPE_TEXTURE_CUBE) {
+ unsigned max_texture_cube_levels = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS);
+ glhd_check("%u", templat->last_level, < max_texture_cube_levels);
+ glhd_check("%u", templat->width0, <= (1 << (max_texture_cube_levels - 1)));
+ glhd_check("%u", templat->height0, == templat->width0);
+ glhd_check("%u", templat->depth0, == 1);
+ glhd_check("%u", templat->array_size, == 6);
+ } else if (templat->target == PIPE_TEXTURE_RECT) {
+ unsigned max_texture_2d_levels = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS);
+ glhd_check("%u", templat->last_level, == 0);
+ glhd_check("%u", templat->width0, <= (1 << (max_texture_2d_levels - 1)));
+ glhd_check("%u", templat->height0, <= (1 << (max_texture_2d_levels - 1)));
+ glhd_check("%u", templat->depth0, == 1);
+ glhd_check("%u", templat->array_size, == 1);
+ } else if (templat->target == PIPE_TEXTURE_3D) {
+ unsigned max_texture_3d_levels = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS);
+ glhd_check("%u", templat->last_level, < max_texture_3d_levels);
+ glhd_check("%u", templat->width0, <= (1 << (max_texture_3d_levels - 1)));
+ glhd_check("%u", templat->height0, <= (1 << (max_texture_3d_levels - 1)));
+ glhd_check("%u", templat->depth0, <= (1 << (max_texture_3d_levels - 1)));
+ glhd_check("%u", templat->array_size, == 1);
+ } else if (templat->target == PIPE_TEXTURE_1D_ARRAY) {
+ unsigned max_texture_2d_levels = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS);
+ glhd_check("%u", templat->last_level, < max_texture_2d_levels);
+ glhd_check("%u", templat->width0, <= (1 << (max_texture_2d_levels - 1)));
+ glhd_check("%u", templat->height0, == 1);
+ glhd_check("%u", templat->depth0, == 1);
+ glhd_check("%u", templat->array_size, <= screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS));
+ } else if (templat->target == PIPE_TEXTURE_2D_ARRAY) {
+ unsigned max_texture_2d_levels = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS);
+ glhd_check("%u", templat->last_level, < max_texture_2d_levels);
+ glhd_check("%u", templat->width0, <= (1 << (max_texture_2d_levels - 1)));
+ glhd_check("%u", templat->height0, <= (1 << (max_texture_2d_levels - 1)));
+ glhd_check("%u", templat->depth0, == 1);
+ glhd_check("%u", templat->array_size, <= screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS));
+ } else {
glhd_warn("Received bogus resource target %d", templat->target);
+ }
if(templat->target != PIPE_TEXTURE_RECT && templat->target != PIPE_BUFFER && !screen->get_param(screen, PIPE_CAP_NPOT_TEXTURES))
{
@@ -153,24 +213,6 @@ galahad_screen_resource_create(struct pipe_screen *_screen,
glhd_warn("Requested NPOT (%ux%u) non-rectangle texture without NPOT support", templat->width0, templat->height0);
}
- if(templat->target == PIPE_TEXTURE_RECT && templat->last_level)
- glhd_warn("Rectangle textures cannot have mipmaps, but last_level = %u", templat->last_level);
-
- if(templat->target == PIPE_BUFFER && templat->last_level)
- glhd_warn("Buffers cannot have mipmaps, but last_level = %u", templat->last_level);
-
- if(templat->target != PIPE_TEXTURE_3D && templat->depth0 != 1)
- glhd_warn("Only 3D textures can have depth != 1, but received target %u and depth %u", templat->target, templat->depth0);
-
- if(templat->target == PIPE_TEXTURE_1D && templat->height0 != 1)
- glhd_warn("1D textures must have height 1 but got asked for height %u", templat->height0);
-
- if(templat->target == PIPE_BUFFER && templat->height0 != 1)
- glhd_warn("Buffers must have height 1 but got asked for height %u", templat->height0);
-
- if(templat->target == PIPE_TEXTURE_CUBE && templat->width0 != templat->height0)
- glhd_warn("Cube maps must be square, but got asked for %ux%u", templat->width0, templat->height0);
-
result = screen->resource_create(screen,
templat);