Module: Mesa
Branch: master
Commit: ccd08643577988d416b339b84fe7bfda6fb77ef6
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=ccd08643577988d416b339b84fe7bfda6fb77ef6

Author: Luca Barbieri <l...@luca-barbieri.com>
Date:   Thu Aug 19 01:38:33 2010 +0200

galahad: check resource_create template

---

 src/gallium/drivers/galahad/glhd_screen.c |   29 +++++++++++++++++++++++++++++
 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 e1a1b59..2d7383a 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);
 

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to