summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/galahad/glhd_screen.c
diff options
context:
space:
mode:
authorLuca Barbieri <[email protected]>2010-08-19 01:38:33 +0200
committerLuca Barbieri <[email protected]>2010-08-20 12:04:10 +0200
commitccd08643577988d416b339b84fe7bfda6fb77ef6 (patch)
tree75ff5f61eb035f803d6cfca3edda7fa31109578f /src/gallium/drivers/galahad/glhd_screen.c
parent7f15dca6d963b0a69131e8761c477064dba49307 (diff)
galahad: check resource_create template
Diffstat (limited to 'src/gallium/drivers/galahad/glhd_screen.c')
-rw-r--r--src/gallium/drivers/galahad/glhd_screen.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/gallium/drivers/galahad/glhd_screen.c b/src/gallium/drivers/galahad/glhd_screen.c
index e1a1b59f203..2d7383acba2 100644
--- a/src/gallium/drivers/galahad/glhd_screen.c
+++ b/src/gallium/drivers/galahad/glhd_screen.c
@@ -30,6 +30,7 @@
#include "pipe/p_screen.h"
#include "pipe/p_state.h"
#include "util/u_memory.h"
+#include "util/u_math.h"
#include "glhd_public.h"
#include "glhd_screen.h"
@@ -134,6 +135,34 @@ 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_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))
+ {
+ if(!util_is_pot(templat->width0) || !util_is_pot(templat->height0))
+ glhd_warn("Requested NPOT (%ux%u) non-rectangle texture without NPOT support", templat->width0, templat->height0);
+ }
+
+ /* TODO: allow this for OpenCL flexible sampling */
+ 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);