added pipe->max_texture_size() query, use it in st_drawpixels()
authorBrian <brian.paul@tungstengraphics.com>
Fri, 10 Aug 2007 21:47:45 +0000 (15:47 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Fri, 10 Aug 2007 21:48:54 +0000 (15:48 -0600)
src/mesa/pipe/i915simple/i915_context.c
src/mesa/pipe/p_context.h
src/mesa/pipe/softpipe/sp_context.c
src/mesa/state_tracker/st_cb_drawpixels.c

index ee6cfe2ed486bcc45e389ba29c871ff255224dcc..d9fbada1ff6c3b01a51eb5dd61c9e4782a4538a5 100644 (file)
@@ -115,6 +115,35 @@ i915_supported_formats(struct pipe_context *pipe,
 }
 
 
+/**
+ * We might want to return max texture levels instead...
+ */
+static void
+i915_max_texture_size(struct pipe_context *pipe, GLuint textureType,
+                      GLuint *maxWidth, GLuint *maxHeight, GLuint *maxDepth)
+{
+   switch (textureType) {
+   case PIPE_TEXTURE_1D:
+      *maxWidth = 2048;
+      break; 
+   case PIPE_TEXTURE_2D:
+      *maxWidth =
+      *maxHeight = 2048;
+      break; 
+   case PIPE_TEXTURE_3D:
+      *maxWidth =
+      *maxHeight =
+      *maxDepth = 256;
+      break; 
+   case PIPE_TEXTURE_CUBE:
+      *maxWidth =
+      *maxHeight = 2048;
+      break; 
+   default:
+      assert(0);
+   }
+}
+
 
 static void i915_destroy( struct pipe_context *pipe )
 {
@@ -193,6 +222,7 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
 
    i915->pipe.destroy = i915_destroy;
    i915->pipe.supported_formats = i915_supported_formats;
+   i915->pipe.max_texture_size = i915_max_texture_size;
    i915->pipe.draw_vb = i915_draw_vb;
    i915->pipe.draw_vertices = i915_draw_vertices;
    i915->pipe.clear = i915_clear;
index 89d9b36af7a3d4eaa160a21d2a6aa0db05150948..b303cee5ccaa18301ea2cc1cb0a8237723f13634 100644 (file)
@@ -51,6 +51,11 @@ struct pipe_context {
     */
    const GLuint *(*supported_formats)(struct pipe_context *pipe,
                                       GLuint *numFormats);
+   void (*max_texture_size)(struct pipe_context *pipe,
+                            GLuint textureType, /* PIPE_TEXTURE_x */
+                            GLuint *maxWidth,
+                            GLuint *maxHeight,
+                            GLuint *maxDepth);
 
    /*
     * Drawing
index 91b8ae50865524ccdbcb3813e6cdda14fe2e5970..53990637bade6244bdaf6e2147f4a344410651be 100644 (file)
@@ -76,6 +76,33 @@ softpipe_supported_formats(struct pipe_context *pipe, GLuint *numFormats)
 }
 
 
+static void
+softpipe_max_texture_size(struct pipe_context *pipe, GLuint textureType,
+                          GLuint *maxWidth, GLuint *maxHeight,
+                          GLuint *maxDepth)
+{
+   switch (textureType) {
+   case PIPE_TEXTURE_1D:
+      *maxWidth = 1 << (MAX_TEXTURE_LEVELS - 1);
+      break;
+   case PIPE_TEXTURE_2D:
+      *maxWidth =
+      *maxHeight = 1 << (MAX_TEXTURE_LEVELS - 1);
+      break;
+   case PIPE_TEXTURE_3D:
+      *maxWidth =
+      *maxHeight =
+      *maxDepth = 1 << (MAX_3D_TEXTURE_LEVELS - 1);
+      break;
+   case PIPE_TEXTURE_CUBE:
+      *maxWidth =
+      *maxHeight = MAX_TEXTURE_RECT_SIZE;
+      break;
+   default:
+      assert(0);
+   }
+}
+
 
 static void map_surfaces(struct softpipe_context *sp)
 {
@@ -201,8 +228,11 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
    softpipe->pipe.winsys = pipe_winsys;
    softpipe->pipe.destroy = softpipe_destroy;
 
+   /* queries */
    softpipe->pipe.supported_formats = softpipe_supported_formats;
+   softpipe->pipe.max_texture_size = softpipe_max_texture_size;
 
+   /* state setters */
    softpipe->pipe.set_alpha_test_state = softpipe_set_alpha_test_state;
    softpipe->pipe.set_blend_color = softpipe_set_blend_color;
    softpipe->pipe.set_blend_state = softpipe_set_blend_state;
@@ -225,9 +255,11 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
    softpipe->pipe.reset_occlusion_counter = softpipe_reset_occlusion_counter;
    softpipe->pipe.get_occlusion_counter = softpipe_get_occlusion_counter;
 
+   /* textures */
    softpipe->pipe.mipmap_tree_layout = softpipe_mipmap_tree_layout;
    softpipe->pipe.get_tex_surface = softpipe_get_tex_surface;
 
+   /* setup quad rendering stages */
    softpipe->quad.polygon_stipple = sp_quad_polygon_stipple_stage(softpipe);
    softpipe->quad.shade = sp_quad_shade_stage(softpipe);
    softpipe->quad.alpha_test = sp_quad_alpha_test_stage(softpipe);
index a5ba61442943baa95792035af3e6ea3741418933..ce417b9b7eacac76b9cdd8732035951f1700b231 100644 (file)
@@ -250,6 +250,15 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
    struct pipe_context *pipe = ctx->st->pipe;
    struct pipe_mipmap_tree *mt;
    GLfloat x0, y0, x1, y1;
+   GLuint maxWidth, maxHeight;
+
+   /* limit checks */
+   /* XXX if DrawPixels image is larger than max texture size, break
+    * it up into chunks.
+    */
+   pipe->max_texture_size(pipe, PIPE_TEXTURE_2D, &maxWidth, &maxHeight, NULL);
+   assert(width <= maxWidth);
+   assert(height <= maxHeight);
 
    /* setup state: just scissor */
    {