Mesa (gallium-rect-textures): galahad: check resource_create template

Luca Barbieri lb at kemper.freedesktop.org
Thu Aug 19 14:51:49 UTC 2010


Module: Mesa
Branch: gallium-rect-textures
Commit: a3d8cba5574cd901b6beb273945562fc6a16c5fd
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a3d8cba5574cd901b6beb273945562fc6a16c5fd

Author: Luca Barbieri <luca at 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 4117485..1bb5f7b 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);
 




More information about the mesa-commit mailing list