diff options
author | Eric Anholt <[email protected]> | 2019-05-01 14:00:33 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2019-05-13 12:03:05 -0700 |
commit | f33cb272f0890f115c36fb96173123bc699b7b2c (patch) | |
tree | 853d429e345213757c8427388e2ab870a5ea227a /src/mesa | |
parent | ce6dbc0417586cc1ceb015b631384ffdfb22e981 (diff) |
mesa: Replace MaxTextureLevels with MaxTextureSize.
In most places (glGetInteger, max_legal_texture_dimensions), we wanted the
number of pixels, not the number of levels. Number of levels is easily
recovered with util_next_power_of_two() and ffs(). More importantly, for
V3D we want to be able to expose a non-power-of-two maximum texture size
to cover 2x4k displays on HW that can't quite do 8192 wide.
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/common/meta.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915/i830_context.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i915/i915_context.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_context.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv04_context.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nv10_context.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/r200/r200_context.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_context.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c | 2 | ||||
-rw-r--r-- | src/mesa/main/context.c | 10 | ||||
-rw-r--r-- | src/mesa/main/get_hash_params.py | 2 | ||||
-rw-r--r-- | src/mesa/main/mtypes.h | 2 | ||||
-rw-r--r-- | src/mesa/main/teximage.c | 16 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_extensions.c | 11 | ||||
-rw-r--r-- | src/mesa/swrast/s_context.c | 2 |
15 files changed, 29 insertions, 34 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index 3515e312023..302c5fffeb9 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -1245,7 +1245,7 @@ init_temp_texture(struct gl_context *ctx, struct temp_texture *tex) else { /* use 2D texture, NPOT if possible */ tex->Target = GL_TEXTURE_2D; - tex->MaxSize = 1 << (ctx->Const.MaxTextureLevels - 1); + tex->MaxSize = ctx->Const.MaxTextureSize; tex->NPOT = ctx->Extensions.ARB_texture_non_power_of_two; } tex->MinSize = 16; /* 16 x 16 at least */ diff --git a/src/mesa/drivers/dri/i915/i830_context.c b/src/mesa/drivers/dri/i915/i830_context.c index ca00483067a..166c60190b7 100644 --- a/src/mesa/drivers/dri/i915/i830_context.c +++ b/src/mesa/drivers/dri/i915/i830_context.c @@ -104,7 +104,7 @@ i830CreateContext(int api, /* Advertise the full hardware capabilities. The new memory * manager should cope much better with overload situations: */ - ctx->Const.MaxTextureLevels = 12; + ctx->Const.MaxTextureSize = 2048; ctx->Const.Max3DTextureLevels = 9; ctx->Const.MaxCubeTextureLevels = 11; ctx->Const.MaxTextureRectSize = (1 << 11); diff --git a/src/mesa/drivers/dri/i915/i915_context.c b/src/mesa/drivers/dri/i915/i915_context.c index 05334b8dbc3..64843020127 100644 --- a/src/mesa/drivers/dri/i915/i915_context.c +++ b/src/mesa/drivers/dri/i915/i915_context.c @@ -214,7 +214,7 @@ i915CreateContext(int api, /* Advertise the full hardware capabilities. The new memory * manager should cope much better with overload situations: */ - ctx->Const.MaxTextureLevels = 12; + ctx->Const.MaxTextureSize = 2048; ctx->Const.Max3DTextureLevels = 9; ctx->Const.MaxCubeTextureLevels = 12; ctx->Const.MaxTextureRectSize = (1 << 11); diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index f6cf82d6694..c3d4784e94c 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -477,11 +477,11 @@ brw_initialize_context_constants(struct brw_context *brw) ctx->Const.MaxImageUnits = MAX_IMAGE_UNITS; if (devinfo->gen >= 7) { ctx->Const.MaxRenderbufferSize = 16384; - ctx->Const.MaxTextureLevels = MIN2(15 /* 16384 */, MAX_TEXTURE_LEVELS); + ctx->Const.MaxTextureSize = 16384; ctx->Const.MaxCubeTextureLevels = 15; /* 16384 */ } else { ctx->Const.MaxRenderbufferSize = 8192; - ctx->Const.MaxTextureLevels = MIN2(14 /* 8192 */, MAX_TEXTURE_LEVELS); + ctx->Const.MaxTextureSize = 8192; ctx->Const.MaxCubeTextureLevels = 14; /* 8192 */ } ctx->Const.Max3DTextureLevels = 12; /* 2048 */ diff --git a/src/mesa/drivers/dri/nouveau/nv04_context.c b/src/mesa/drivers/dri/nouveau/nv04_context.c index 324595e2403..093c7b85010 100644 --- a/src/mesa/drivers/dri/nouveau/nv04_context.c +++ b/src/mesa/drivers/dri/nouveau/nv04_context.c @@ -157,7 +157,7 @@ nv04_context_create(struct nouveau_screen *screen, gl_api api, goto fail; /* GL constants. */ - ctx->Const.MaxTextureLevels = 11; + ctx->Const.MaxTextureSize = 1024; ctx->Const.MaxTextureCoordUnits = NV04_TEXTURE_UNITS; ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits = NV04_TEXTURE_UNITS; ctx->Const.MaxTextureUnits = NV04_TEXTURE_UNITS; diff --git a/src/mesa/drivers/dri/nouveau/nv10_context.c b/src/mesa/drivers/dri/nouveau/nv10_context.c index be2178fb79e..6af1b1d5a3a 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_context.c +++ b/src/mesa/drivers/dri/nouveau/nv10_context.c @@ -455,7 +455,7 @@ nv10_context_create(struct nouveau_screen *screen, gl_api api, ctx->Extensions.ANGLE_texture_compression_dxt = true; /* GL constants. */ - ctx->Const.MaxTextureLevels = 12; + ctx->Const.MaxTextureSize = 2048; ctx->Const.MaxTextureCoordUnits = NV10_TEXTURE_UNITS; ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits = NV10_TEXTURE_UNITS; ctx->Const.MaxTextureUnits = NV10_TEXTURE_UNITS; diff --git a/src/mesa/drivers/dri/r200/r200_context.c b/src/mesa/drivers/dri/r200/r200_context.c index c97eaa56db1..4f210bf6522 100644 --- a/src/mesa/drivers/dri/r200/r200_context.c +++ b/src/mesa/drivers/dri/r200/r200_context.c @@ -268,7 +268,7 @@ GLboolean r200CreateContext( gl_api api, /* FIXME: When no memory manager is available we should set this * to some reasonable value based on texture memory pool size */ - ctx->Const.MaxTextureLevels = 12; + ctx->Const.MaxTextureSize = 2048; ctx->Const.Max3DTextureLevels = 9; ctx->Const.MaxCubeTextureLevels = 12; ctx->Const.MaxTextureRectSize = 2048; diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index 415810f8bd8..57c7079b2f2 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -230,7 +230,7 @@ r100CreateContext( gl_api api, /* FIXME: When no memory manager is available we should set this * to some reasonable value based on texture memory pool size */ - ctx->Const.MaxTextureLevels = 12; + ctx->Const.MaxTextureSize = 2048; ctx->Const.Max3DTextureLevels = 9; ctx->Const.MaxCubeTextureLevels = 12; ctx->Const.MaxTextureRectSize = 2048; diff --git a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c index 19e62969e5c..8d01e21db72 100644 --- a/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c +++ b/src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c @@ -150,7 +150,7 @@ static void calculate_miptree_layout(radeonContextPtr rmesa, radeon_mipmap_tree { GLuint curOffset, i, face, level; - assert(mt->numLevels <= rmesa->glCtx.Const.MaxTextureLevels); + assert(1 << (mt->numLevels - 1) <= rmesa->glCtx.Const.MaxTextureSize); curOffset = 0; for(face = 0; face < mt->faces; face++) { diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 2c3d9a11ce3..34da16b88f4 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -555,7 +555,7 @@ _mesa_init_constants(struct gl_constants *consts, gl_api api) /* Constants, may be overriden (usually only reduced) by device drivers */ consts->MaxTextureMbytes = MAX_TEXTURE_MBYTES; - consts->MaxTextureLevels = MAX_TEXTURE_LEVELS; + consts->MaxTextureSize = 1 << (MAX_TEXTURE_LEVELS - 1); consts->Max3DTextureLevels = MAX_3D_TEXTURE_LEVELS; consts->MaxCubeTextureLevels = MAX_CUBE_TEXTURE_LEVELS; consts->MaxTextureRectSize = MAX_TEXTURE_RECT_SIZE; @@ -782,7 +782,7 @@ check_context_limits(struct gl_context *ctx) /* Texture size checks */ - assert(ctx->Const.MaxTextureLevels <= MAX_TEXTURE_LEVELS); + assert(ctx->Const.MaxTextureSize <= (1 << (MAX_TEXTURE_LEVELS - 1))); assert(ctx->Const.Max3DTextureLevels <= MAX_3D_TEXTURE_LEVELS); assert(ctx->Const.MaxCubeTextureLevels <= MAX_CUBE_TEXTURE_LEVELS); assert(ctx->Const.MaxTextureRectSize <= MAX_TEXTURE_RECT_SIZE); @@ -792,10 +792,8 @@ check_context_limits(struct gl_context *ctx) assert(MAX_TEXTURE_LEVELS >= MAX_CUBE_TEXTURE_LEVELS); /* Max texture size should be <= max viewport size (render to texture) */ - assert((1U << (ctx->Const.MaxTextureLevels - 1)) - <= ctx->Const.MaxViewportWidth); - assert((1U << (ctx->Const.MaxTextureLevels - 1)) - <= ctx->Const.MaxViewportHeight); + assert(ctx->Const.MaxTextureSize <= ctx->Const.MaxViewportWidth); + assert(ctx->Const.MaxTextureSize <= ctx->Const.MaxViewportHeight); assert(ctx->Const.MaxDrawBuffers <= MAX_DRAW_BUFFERS); diff --git a/src/mesa/main/get_hash_params.py b/src/mesa/main/get_hash_params.py index f7efb81b7c7..85db09f2540 100644 --- a/src/mesa/main/get_hash_params.py +++ b/src/mesa/main/get_hash_params.py @@ -21,7 +21,7 @@ descriptor=[ [ "ALIASED_LINE_WIDTH_RANGE", "CONTEXT_FLOAT2(Const.MinLineWidth), NO_EXTRA" ], [ "MAX_ELEMENTS_VERTICES", "CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA" ], [ "MAX_ELEMENTS_INDICES", "CONTEXT_INT(Const.MaxArrayLockSize), NO_EXTRA" ], - [ "MAX_TEXTURE_SIZE", "LOC_CUSTOM, TYPE_INT, offsetof(struct gl_context, Const.MaxTextureLevels), NO_EXTRA" ], + [ "MAX_TEXTURE_SIZE", "CONTEXT_INT(Const.MaxTextureSize), NO_EXTRA" ], [ "MAX_VIEWPORT_DIMS", "CONTEXT_INT2(Const.MaxViewportWidth), NO_EXTRA" ], [ "PACK_ALIGNMENT", "CONTEXT_INT(Pack.Alignment), NO_EXTRA" ], [ "ALIASED_POINT_SIZE_RANGE", "CONTEXT_FLOAT2(Const.MinPointSize), NO_EXTRA" ], diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 76905f60662..bdb04e085f4 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -3654,7 +3654,7 @@ struct gl_program_constants struct gl_constants { GLuint MaxTextureMbytes; /**< Max memory per image, in MB */ - GLuint MaxTextureLevels; /**< Max mipmap levels. */ + GLuint MaxTextureSize; /**< Max 1D/2D texture size, in pixels*/ GLuint Max3DTextureLevels; /**< Max mipmap levels for 3D textures */ GLuint MaxCubeTextureLevels; /**< Max mipmap levels for cube textures */ GLuint MaxArrayTextureLayers; /**< Max layers in array textures */ diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c index 7d32c7b2db9..36480348943 100644 --- a/src/mesa/main/teximage.c +++ b/src/mesa/main/teximage.c @@ -492,7 +492,7 @@ _mesa_max_texture_levels(const struct gl_context *ctx, GLenum target) case GL_PROXY_TEXTURE_1D: case GL_TEXTURE_2D: case GL_PROXY_TEXTURE_2D: - return ctx->Const.MaxTextureLevels; + return ffs(util_next_power_of_two(ctx->Const.MaxTextureSize)); case GL_TEXTURE_3D: case GL_PROXY_TEXTURE_3D: return ctx->Const.Max3DTextureLevels; @@ -514,7 +514,7 @@ _mesa_max_texture_levels(const struct gl_context *ctx, GLenum target) case GL_TEXTURE_2D_ARRAY_EXT: case GL_PROXY_TEXTURE_2D_ARRAY_EXT: return ctx->Extensions.EXT_texture_array - ? ctx->Const.MaxTextureLevels : 0; + ? ffs(util_next_power_of_two(ctx->Const.MaxTextureSize)) : 0; case GL_TEXTURE_CUBE_MAP_ARRAY: case GL_PROXY_TEXTURE_CUBE_MAP_ARRAY: return _mesa_has_texture_cube_map_array(ctx) @@ -973,8 +973,7 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target, switch (target) { case GL_TEXTURE_1D: case GL_PROXY_TEXTURE_1D: - maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); /* level zero size */ - maxSize >>= level; /* level size */ + maxSize = ctx->Const.MaxTextureSize >> level; if (width < 2 * border || width > 2 * border + maxSize) return GL_FALSE; if (!ctx->Extensions.ARB_texture_non_power_of_two) { @@ -987,8 +986,7 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target, case GL_PROXY_TEXTURE_2D: case GL_TEXTURE_2D_MULTISAMPLE: case GL_PROXY_TEXTURE_2D_MULTISAMPLE: - maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); - maxSize >>= level; + maxSize = ctx->Const.MaxTextureSize >> level; if (width < 2 * border || width > 2 * border + maxSize) return GL_FALSE; if (height < 2 * border || height > 2 * border + maxSize) @@ -1058,8 +1056,7 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target, case GL_TEXTURE_1D_ARRAY_EXT: case GL_PROXY_TEXTURE_1D_ARRAY_EXT: - maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); - maxSize >>= level; + maxSize = ctx->Const.MaxTextureSize >> level; if (width < 2 * border || width > 2 * border + maxSize) return GL_FALSE; if (height < 0 || height > ctx->Const.MaxArrayTextureLayers) @@ -1074,8 +1071,7 @@ _mesa_legal_texture_dimensions(struct gl_context *ctx, GLenum target, case GL_PROXY_TEXTURE_2D_ARRAY_EXT: case GL_TEXTURE_2D_MULTISAMPLE_ARRAY: case GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY: - maxSize = 1 << (ctx->Const.MaxTextureLevels - 1); - maxSize >>= level; + maxSize = ctx->Const.MaxTextureSize >> level; if (width < 2 * border || width > 2 * border + maxSize) return GL_FALSE; if (height < 2 * border || height > 2 * border + maxSize) diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 560dd7b31a4..77cb83d5c57 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -84,9 +84,11 @@ void st_init_limits(struct pipe_screen *screen, bool can_ubo = true; int temp; - c->MaxTextureLevels - = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), - MAX_TEXTURE_LEVELS); + int max_texture_levels = + _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS), + MAX_TEXTURE_LEVELS); + + c->MaxTextureSize = 1 << (max_texture_levels - 1); c->Max3DTextureLevels = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_3D_LEVELS), @@ -96,8 +98,7 @@ void st_init_limits(struct pipe_screen *screen, = _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS), MAX_CUBE_TEXTURE_LEVELS); - c->MaxTextureRectSize - = _min(1 << (c->MaxTextureLevels - 1), MAX_TEXTURE_RECT_SIZE); + c->MaxTextureRectSize = _min(c->MaxTextureSize, MAX_TEXTURE_RECT_SIZE); c->MaxArrayTextureLayers = screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS); diff --git a/src/mesa/swrast/s_context.c b/src/mesa/swrast/s_context.c index 9480d9ec7a5..5506ed51905 100644 --- a/src/mesa/swrast/s_context.c +++ b/src/mesa/swrast/s_context.c @@ -728,7 +728,7 @@ _swrast_CreateContext( struct gl_context *ctx ) assert(ctx->Const.MaxRenderbufferSize <= SWRAST_MAX_WIDTH); /* make sure largest texture image is <= SWRAST_MAX_WIDTH in size */ - assert((1 << (ctx->Const.MaxTextureLevels - 1)) <= SWRAST_MAX_WIDTH); + assert(ctx->Const.MaxTextureSize <= SWRAST_MAX_WIDTH); assert((1 << (ctx->Const.MaxCubeTextureLevels - 1)) <= SWRAST_MAX_WIDTH); assert((1 << (ctx->Const.Max3DTextureLevels - 1)) <= SWRAST_MAX_WIDTH); |