summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-08-10 15:47:45 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-08-10 15:48:54 -0600
commit8fbd81b4ed59e371aa616b87296e4263d8992bff (patch)
tree7344b1d23c68ae266ce3388f65204ab981b88ab1
parent47fc2c4349746997704a7f81dffadd22363e0ff1 (diff)
added pipe->max_texture_size() query, use it in st_drawpixels()
-rw-r--r--src/mesa/pipe/i915simple/i915_context.c30
-rw-r--r--src/mesa/pipe/p_context.h5
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c32
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c9
4 files changed, 76 insertions, 0 deletions
diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c
index ee6cfe2ed4..d9fbada1ff 100644
--- a/src/mesa/pipe/i915simple/i915_context.c
+++ b/src/mesa/pipe/i915simple/i915_context.c
@@ -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;
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index 89d9b36af7..b303cee5cc 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -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
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index 91b8ae5086..53990637ba 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -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);
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index a5ba614429..ce417b9b7e 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -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 */
{