Remove pipe->max_texture_size(), use get_param() instead.

Also, in st_init_limits(), clamp driver's values against Mesa's internal limits.
This commit is contained in:
Brian
2007-11-06 09:41:45 -07:00
parent 24ac9c30eb
commit e2feb80a90
7 changed files with 57 additions and 115 deletions

View File

@@ -117,9 +117,9 @@ struct pipe_context *failover_create( struct pipe_context *hw,
failover->pipe.winsys = hw->winsys; failover->pipe.winsys = hw->winsys;
failover->pipe.destroy = failover_destroy; failover->pipe.destroy = failover_destroy;
failover->pipe.is_format_supported = hw->is_format_supported; 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_name = hw->get_name;
failover->pipe.get_vendor = hw->get_vendor; failover->pipe.get_vendor = hw->get_vendor;
failover->pipe.get_param = hw->get_param;
failover->pipe.draw_arrays = failover_draw_arrays; failover->pipe.draw_arrays = failover_draw_arrays;
failover->pipe.draw_elements = failover_draw_elements; failover->pipe.draw_elements = failover_draw_elements;

View File

@@ -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 static int
i915_get_param(struct pipe_context *pipe, int param) i915_get_param(struct pipe_context *pipe, int param)
{ {
@@ -162,6 +132,12 @@ i915_get_param(struct pipe_context *pipe, int param)
return 0; return 0;
case PIPE_CAP_TEXTURE_SHADOW_MAP: case PIPE_CAP_TEXTURE_SHADOW_MAP:
return 0; 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: default:
return 0; return 0;
} }
@@ -324,7 +300,6 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
i915->pipe.destroy = i915_destroy; i915->pipe.destroy = i915_destroy;
i915->pipe.is_format_supported = i915_is_format_supported; 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.get_param = i915_get_param;
i915->pipe.clear = i915_clear; i915->pipe.clear = i915_clear;

View File

@@ -51,12 +51,6 @@ struct pipe_context {
boolean (*is_format_supported)( struct pipe_context *pipe, boolean (*is_format_supported)( struct pipe_context *pipe,
uint format ); 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_name)( struct pipe_context *pipe );
const char *(*get_vendor)( struct pipe_context *pipe ); const char *(*get_vendor)( struct pipe_context *pipe );

View File

@@ -245,6 +245,9 @@
#define PIPE_CAP_POINT_SPRITE 7 #define PIPE_CAP_POINT_SPRITE 7
#define PIPE_CAP_MAX_RENDER_TARGETS 8 #define PIPE_CAP_MAX_RENDER_TARGETS 8
#define PIPE_CAP_OCCLUSION_QUERY 9 #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 #endif

View File

@@ -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 * 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; return 1;
case PIPE_CAP_TEXTURE_SHADOW_MAP: case PIPE_CAP_TEXTURE_SHADOW_MAP:
return 1; 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: default:
return 0; return 0;
} }
@@ -321,7 +294,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
/* queries */ /* queries */
softpipe->pipe.is_format_supported = softpipe_is_format_supported; 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; softpipe->pipe.get_param = softpipe_get_param;
/* state setters */ /* state setters */

View File

@@ -703,15 +703,15 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
const GLuint unit = 0; const GLuint unit = 0;
struct pipe_context *pipe = ctx->st->pipe; struct pipe_context *pipe = ctx->st->pipe;
GLfloat x0, y0, x1, y1; GLfloat x0, y0, x1, y1;
GLuint maxWidth, maxHeight; GLuint maxSize;
/* limit checks */ /* limit checks */
/* XXX if DrawPixels image is larger than max texture size, break /* XXX if DrawPixels image is larger than max texture size, break
* it up into chunks. * it up into chunks.
*/ */
pipe->max_texture_size(pipe, PIPE_TEXTURE_2D, &maxWidth, &maxHeight, NULL); maxSize = 1 << (pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_2D_LEVELS) - 1);
assert(width <= maxWidth); assert(width <= maxSize);
assert(height <= maxHeight); assert(height <= maxSize);
/* setup state: just scissor */ /* setup state: just scissor */
{ {

View File

@@ -37,57 +37,54 @@
#include "st_extensions.h" #include "st_extensions.h"
/* static int min(int a, int b)
* Compute floor(log_base_2(n)).
* If n < 0 return -1.
*/
static int
logbase2( int n )
{ {
GLint i = 1; return (a < b) ? a : b;
GLint log2 = 0; }
if (n < 0) static int clamp(int a, int min, int max)
return -1; {
if (a < min)
if (n == 0) return min;
return 0; else if (a > max)
return max;
while ( n > i ) { else
i *= 2; return a;
log2++;
}
if (i != n) {
return log2 - 1;
}
else {
return log2;
}
} }
/**
* 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) void st_init_limits(struct st_context *st)
{ {
struct pipe_context *pipe = st->pipe; struct pipe_context *pipe = st->pipe;
GLcontext *ctx = st->ctx; struct gl_constants *c = &st->ctx->Const;
uint w, h, d;
ctx->Const.MaxTextureImageUnits c->MaxTextureLevels
= ctx->Const.MaxTextureCoordUnits = min(pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_2D_LEVELS),
= pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS); MAX_TEXTURE_LEVELS);
pipe->max_texture_size(pipe, PIPE_TEXTURE_2D, &w, &h, &d); c->Max3DTextureLevels
ctx->Const.MaxTextureLevels = logbase2(w) + 1; = min(pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_3D_LEVELS),
ctx->Const.MaxTextureRectSize = w; MAX_3D_TEXTURE_LEVELS);
pipe->max_texture_size(pipe, PIPE_TEXTURE_3D, &w, &h, &d); c->MaxCubeTextureLevels
ctx->Const.Max3DTextureLevels = logbase2(d) + 1; = min(pipe->get_param(pipe, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS),
MAX_CUBE_TEXTURE_LEVELS);
pipe->max_texture_size(pipe, PIPE_TEXTURE_CUBE, &w, &h, &d); c->MaxTextureRectSize
ctx->Const.MaxCubeTextureLevels = logbase2(w) + 1; = min(1 << (c->MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE);
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);
} }