summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-11-06 09:41:45 -0700
committerBrian <[email protected]>2007-11-06 09:41:45 -0700
commite2feb80a90f3e9300c70a4a4eb3e966131f5c313 (patch)
treed407028c34268b686e0c5802c07e09bac0d57ece /src/mesa/state_tracker
parent24ac9c30ebfd2edabdd21bfc9cf4e9db21cd10df (diff)
Remove pipe->max_texture_size(), use get_param() instead.
Also, in st_init_limits(), clamp driver's values against Mesa's internal limits.
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c8
-rw-r--r--src/mesa/state_tracker/st_extensions.c73
2 files changed, 39 insertions, 42 deletions
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index fc58035d00b..df41d5ce5b2 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 3f56b537bbc..0707c489a6f 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);
}