Also, in st_init_limits(), clamp driver's values against Mesa's internal limits.
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;
}
-/**
- * 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)
{
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;
}
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;
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 );
#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
}
-/** 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
*/
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;
}
/* 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 */
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 */
{
#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);
}