mesa: add numLevels, numSamples to Driver.TestProxyTexImage()

So that the function can work properly with glTexStorage(), where we know
how many mipmap levels there are.  And so we can compute storage for MSAA
textures.

Also, remove the obsolete texture border parameter.

A subsequent patch will update _mesa_test_proxy_teximage() to use these
new parameters.

Reviewed-by: Anuj Phogat <anuj.phogat@gmail.com>
This commit is contained in:
Brian Paul
2016-07-14 14:25:19 -06:00
parent e477d92c94
commit 0ac9f25032
7 changed files with 39 additions and 29 deletions

View File

@@ -101,9 +101,9 @@ make_view(struct gl_context *ctx, struct gl_texture_image *tex_image,
0, internal_format,
GL_NONE, GL_NONE);
if (!ctx->Driver.TestProxyTexImage(ctx, tex_obj->Target, 0, tex_format,
tex_image->Width, tex_image->Height,
tex_image->Depth, 0)) {
if (!ctx->Driver.TestProxyTexImage(ctx, tex_obj->Target, 1, 0, tex_format,
1, tex_image->Width, tex_image->Height,
tex_image->Depth)) {
_mesa_DeleteTextures(1, view_tex_name);
*view_tex_name = 0;
return false;

View File

@@ -308,9 +308,10 @@ struct dd_function_table {
* \return GL_TRUE if the image is OK, GL_FALSE if too large
*/
GLboolean (*TestProxyTexImage)(struct gl_context *ctx, GLenum target,
GLint level, mesa_format format,
GLuint numLevels, GLint level,
mesa_format format, GLuint numSamples,
GLint width, GLint height,
GLint depth, GLint border);
GLint depth);
/*@}*/

View File

@@ -1253,18 +1253,20 @@ error_check_subtexture_dimensions(struct gl_context *ctx, GLuint dims,
* and texturing will effectively be disabled.
*
* \param target any texture target/type
* \param numLevels number of mipmap levels in the texture or 0 if not known
* \param level as passed to glTexImage
* \param format the MESA_FORMAT_x for the tex image
* \param numSamples number of samples per texel
* \param width as passed to glTexImage
* \param height as passed to glTexImage
* \param depth as passed to glTexImage
* \param border as passed to glTexImage
* \return GL_TRUE if the image is acceptable, GL_FALSE if not acceptable.
*/
GLboolean
_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
mesa_format format,
GLint width, GLint height, GLint depth, GLint border)
_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target,
GLuint numLevels, GLint level,
mesa_format format, GLuint numSamples,
GLint width, GLint height, GLint depth)
{
/* We just check if the image size is less than MaxTextureMbytes.
* Some drivers may do more specific checks.
@@ -2949,8 +2951,8 @@ teximage(struct gl_context *ctx, GLboolean compressed, GLuint dims,
/* check that the texture won't take too much memory, etc */
sizeOK = ctx->Driver.TestProxyTexImage(ctx, proxy_target(target),
level, texFormat,
width, height, depth, border);
0, level, texFormat, 1,
width, height, depth);
if (_mesa_is_proxy_texture(target)) {
/* Proxy texture: just clear or set state depending on error checking */
@@ -3646,8 +3648,8 @@ copyteximage(struct gl_context *ctx, GLuint dims,
assert(texFormat != MESA_FORMAT_NONE);
if (!ctx->Driver.TestProxyTexImage(ctx, proxy_target(target),
level, texFormat,
width, height, 1, border)) {
0, level, texFormat, 1,
width, height, 1)) {
_mesa_error(ctx, GL_OUT_OF_MEMORY,
"glCopyTexImage%uD(image too large)", dims);
return;
@@ -5386,8 +5388,8 @@ texture_image_multisample(struct gl_context *ctx, GLuint dims,
dimensionsOK = _mesa_legal_texture_dimensions(ctx, target, 0,
width, height, depth, 0);
sizeOK = ctx->Driver.TestProxyTexImage(ctx, target, 0, texFormat,
width, height, depth, 0);
sizeOK = ctx->Driver.TestProxyTexImage(ctx, target, 0, 0, texFormat,
samples, width, height, depth);
if (_mesa_is_proxy_texture(target)) {
if (samplesOK && dimensionsOK && sizeOK) {

View File

@@ -176,9 +176,10 @@ _mesa_max_texture_levels(struct gl_context *ctx, GLenum target);
extern GLboolean
_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target, GLint level,
mesa_format format,
GLint width, GLint height, GLint depth, GLint border);
_mesa_test_proxy_teximage(struct gl_context *ctx, GLenum target,
GLuint numLevels, GLint level,
mesa_format format, GLuint numSamples,
GLint width, GLint height, GLint depth);
extern GLboolean
_mesa_target_can_be_compressed(const struct gl_context *ctx, GLenum target,

View File

@@ -396,8 +396,8 @@ _mesa_texture_storage(struct gl_context *ctx, GLuint dims,
dimensionsOK = _mesa_legal_texture_dimensions(ctx, target, 0,
width, height, depth, 0);
sizeOK = ctx->Driver.TestProxyTexImage(ctx, target, 0, texFormat,
width, height, depth, 0);
sizeOK = ctx->Driver.TestProxyTexImage(ctx, target, levels, 0, texFormat,
1, width, height, depth);
if (_mesa_is_proxy_texture(target)) {
if (dimensionsOK && sizeOK) {

View File

@@ -714,8 +714,9 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture,
return;
}
sizeOK = ctx->Driver.TestProxyTexImage(ctx, target, 0, texFormat,
width, height, depth, 0);
sizeOK = ctx->Driver.TestProxyTexImage(ctx, target, 1, 0, texFormat,
origTexImage->NumSamples,
width, height, depth);
if (!sizeOK) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glTextureView(invalid texture size)");

View File

@@ -2686,9 +2686,9 @@ st_AllocTextureStorage(struct gl_context *ctx,
static GLboolean
st_TestProxyTexImage(struct gl_context *ctx, GLenum target,
GLint level, mesa_format format,
GLint width, GLint height,
GLint depth, GLint border)
GLuint numLevels, GLint level,
mesa_format format, GLuint numSamples,
GLint width, GLint height, GLint depth)
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
@@ -2710,14 +2710,19 @@ st_TestProxyTexImage(struct gl_context *ctx, GLenum target,
pt.target = gl_target_to_pipe(target);
pt.format = st_mesa_format_to_pipe_format(st, format);
pt.nr_samples = numSamples;
st_gl_texture_dims_to_pipe_dims(target,
width, height, depth,
&pt.width0, &pt.height0,
&pt.depth0, &pt.array_size);
if (level == 0 && (texObj->Sampler.MinFilter == GL_LINEAR ||
texObj->Sampler.MinFilter == GL_NEAREST)) {
if (numLevels > 0) {
/* For immutable textures we know the final number of mip levels */
pt.last_level = numLevels - 1;
}
else if (level == 0 && (texObj->Sampler.MinFilter == GL_LINEAR ||
texObj->Sampler.MinFilter == GL_NEAREST)) {
/* assume just one mipmap level */
pt.last_level = 0;
}
@@ -2730,8 +2735,8 @@ st_TestProxyTexImage(struct gl_context *ctx, GLenum target,
}
else {
/* Use core Mesa fallback */
return _mesa_test_proxy_teximage(ctx, target, level, format,
width, height, depth, border);
return _mesa_test_proxy_teximage(ctx, target, numLevels, level, format,
numSamples, width, height, depth);
}
}