summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesa/pipe/failover/fo_context.c2
-rw-r--r--src/mesa/pipe/i915simple/i915_context.c37
-rw-r--r--src/mesa/pipe/p_context.h6
-rw-r--r--src/mesa/pipe/p_defines.h5
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c41
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c8
-rw-r--r--src/mesa/state_tracker/st_extensions.c73
7 files changed, 57 insertions, 115 deletions
diff --git a/src/mesa/pipe/failover/fo_context.c b/src/mesa/pipe/failover/fo_context.c
index aa5d0885e6..e18b349ef3 100644
--- a/src/mesa/pipe/failover/fo_context.c
+++ b/src/mesa/pipe/failover/fo_context.c
@@ -117,9 +117,9 @@ struct pipe_context *failover_create( struct pipe_context *hw,
failover->pipe.winsys = hw->winsys;
failover->pipe.destroy = failover_destroy;
failover->pipe.is_format_supported = hw->is_format_supported;
- failover->pipe.max_texture_size = hw->max_texture_size;
failover->pipe.get_name = hw->get_name;
failover->pipe.get_vendor = hw->get_vendor;
+ failover->pipe.get_param = hw->get_param;
failover->pipe.draw_arrays = failover_draw_arrays;
failover->pipe.draw_elements = failover_draw_elements;
diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c
index 6de1e68f73..50503a843a 100644
--- a/src/mesa/pipe/i915simple/i915_context.c
+++ b/src/mesa/pipe/i915simple/i915_context.c
@@ -108,36 +108,6 @@ i915_is_format_supported( struct pipe_context *pipe,
}
-/**
- * We might want to return max texture levels instead...
- */
-static void
-i915_max_texture_size(struct pipe_context *pipe, unsigned textureType,
- unsigned *maxWidth, unsigned *maxHeight, unsigned *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 int
i915_get_param(struct pipe_context *pipe, int param)
{
@@ -162,6 +132,12 @@ i915_get_param(struct pipe_context *pipe, int param)
return 0;
case PIPE_CAP_TEXTURE_SHADOW_MAP:
return 0;
+ case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
+ return 11; /* max 1024x1024 */
+ case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
+ return 8; /* max 128x128x128 */
+ case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
+ return 11; /* max 1024x1024 */
default:
return 0;
}
@@ -324,7 +300,6 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
i915->pipe.destroy = i915_destroy;
i915->pipe.is_format_supported = i915_is_format_supported;
- i915->pipe.max_texture_size = i915_max_texture_size;
i915->pipe.get_param = i915_get_param;
i915->pipe.clear = i915_clear;
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index 4f5e786334..ddc7acc747 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -51,12 +51,6 @@ struct pipe_context {
boolean (*is_format_supported)( struct pipe_context *pipe,
uint format );
- void (*max_texture_size)(struct pipe_context *pipe,
- unsigned textureType, /* PIPE_TEXTURE_x */
- unsigned *maxWidth,
- unsigned *maxHeight,
- unsigned *maxDepth);
-
const char *(*get_name)( struct pipe_context *pipe );
const char *(*get_vendor)( struct pipe_context *pipe );
diff --git a/src/mesa/pipe/p_defines.h b/src/mesa/pipe/p_defines.h
index cc0232cdcd..ca9929bfee 100644
--- a/src/mesa/pipe/p_defines.h
+++ b/src/mesa/pipe/p_defines.h
@@ -245,6 +245,9 @@
#define PIPE_CAP_POINT_SPRITE 7
#define PIPE_CAP_MAX_RENDER_TARGETS 8
#define PIPE_CAP_OCCLUSION_QUERY 9
-#define PIPE_CAP_TEXTURE_SHADOW_MAP 10
+#define PIPE_CAP_TEXTURE_SHADOW_MAP 10
+#define PIPE_CAP_MAX_TEXTURE_2D_LEVELS 11
+#define PIPE_CAP_MAX_TEXTURE_3D_LEVELS 12
+#define PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS 13
#endif
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index effecda87e..954884e7e9 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -83,39 +83,6 @@ softpipe_is_format_supported( struct pipe_context *pipe,
}
-/** XXX remove these? */
-#define MAX_TEXTURE_LEVELS 11
-#define MAX_TEXTURE_RECT_SIZE 2048
-#define MAX_3D_TEXTURE_LEVELS 8
-
-static void
-softpipe_max_texture_size(struct pipe_context *pipe, unsigned textureType,
- unsigned *maxWidth, unsigned *maxHeight,
- unsigned *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);
- }
-}
-
-
/**
* Map any drawing surfaces which aren't already mapped
*/
@@ -297,6 +264,12 @@ static int softpipe_get_param(struct pipe_context *pipe, int param)
return 1;
case PIPE_CAP_TEXTURE_SHADOW_MAP:
return 1;
+ case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
+ return 12; /* max 2Kx2K */
+ case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
+ return 8; /* max 128x128x128 */
+ case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
+ return 12; /* max 2Kx2K */
default:
return 0;
}
@@ -321,7 +294,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
/* queries */
softpipe->pipe.is_format_supported = softpipe_is_format_supported;
- softpipe->pipe.max_texture_size = softpipe_max_texture_size;
+ //softpipe->pipe.max_texture_size = softpipe_max_texture_size;
softpipe->pipe.get_param = softpipe_get_param;
/* state setters */
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index fc58035d00..df41d5ce5b 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -703,15 +703,15 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
const GLuint unit = 0;
struct pipe_context *pipe = ctx->st->pipe;
GLfloat x0, y0, x1, y1;
- GLuint maxWidth, maxHeight;
+ GLuint maxSize;
/* 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);
+ maxSize = 1 << (pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_2D_LEVELS) - 1);
+ assert(width <= maxSize);
+ assert(height <= maxSize);
/* setup state: just scissor */
{
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 3f56b537bb..0707c489a6 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -37,57 +37,54 @@
#include "st_extensions.h"
-/*
- * Compute floor(log_base_2(n)).
- * If n < 0 return -1.
- */
-static int
-logbase2( int n )
+static int min(int a, int b)
{
- GLint i = 1;
- GLint log2 = 0;
-
- if (n < 0)
- return -1;
-
- if (n == 0)
- return 0;
+ return (a < b) ? a : b;
+}
- while ( n > i ) {
- i *= 2;
- log2++;
- }
- if (i != n) {
- return log2 - 1;
- }
- else {
- return log2;
- }
+static int clamp(int a, int min, int max)
+{
+ if (a < min)
+ return min;
+ else if (a > max)
+ return max;
+ else
+ return a;
}
+/**
+ * Query driver to get implementation limits.
+ * Note that we have to limit/clamp against Mesa's internal limits too.
+ */
void st_init_limits(struct st_context *st)
{
struct pipe_context *pipe = st->pipe;
- GLcontext *ctx = st->ctx;
- uint w, h, d;
+ struct gl_constants *c = &st->ctx->Const;
+
+ c->MaxTextureLevels
+ = min(pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_2D_LEVELS),
+ MAX_TEXTURE_LEVELS);
- ctx->Const.MaxTextureImageUnits
- = ctx->Const.MaxTextureCoordUnits
- = pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS);
+ c->Max3DTextureLevels
+ = min(pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_3D_LEVELS),
+ MAX_3D_TEXTURE_LEVELS);
- pipe->max_texture_size(pipe, PIPE_TEXTURE_2D, &w, &h, &d);
- ctx->Const.MaxTextureLevels = logbase2(w) + 1;
- ctx->Const.MaxTextureRectSize = w;
+ c->MaxCubeTextureLevels
+ = min(pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS),
+ MAX_CUBE_TEXTURE_LEVELS);
- pipe->max_texture_size(pipe, PIPE_TEXTURE_3D, &w, &h, &d);
- ctx->Const.Max3DTextureLevels = logbase2(d) + 1;
+ c->MaxTextureRectSize
+ = min(1 << (c->MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE);
- pipe->max_texture_size(pipe, PIPE_TEXTURE_CUBE, &w, &h, &d);
- ctx->Const.MaxCubeTextureLevels = logbase2(w) + 1;
-
- ctx->Const.MaxDrawBuffers = MAX2(1, pipe->get_param(pipe, PIPE_CAP_MAX_RENDER_TARGETS));
+ c->MaxTextureImageUnits
+ = c->MaxTextureCoordUnits
+ = min(pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS),
+ MAX_TEXTURE_IMAGE_UNITS);
+ c->MaxDrawBuffers
+ = clamp(pipe->get_param(pipe, PIPE_CAP_MAX_RENDER_TARGETS),
+ 1, MAX_DRAW_BUFFERS);
}