mesa: use _mesa_check_sample_count() for multisample textures

Extends _mesa_check_sample_count() to properly support the
TEXTURE_2D_MULTISAMPLE and TEXTURE_2D_MULTISAMPLE_ARRAY targets, which
have subtly different limits than renderbuffers.

This resolves the remaining TODO in the implementation of
TexImage*DMultisample.

V2: - Don't introduce spurious block.
    - Do this in multisample.c instead.
    - Fix typo in error message.
    - Inline spec quotes

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
Chris Forbes
2013-03-03 21:46:12 +13:00
parent 90b5a2425a
commit 2405da174e
2 changed files with 33 additions and 30 deletions
+26 -3
View File
@@ -142,19 +142,42 @@ _mesa_check_sample_count(struct gl_context *ctx, GLenum target,
return samples > limit ? GL_INVALID_OPERATION : GL_NO_ERROR;
}
/* If ARB_texture_multisample is supported, we have separate limits for
* integer formats.
/* If ARB_texture_multisample is supported, we have separate limits,
* which may be lower than MAX_SAMPLES:
*
* From the ARB_texture_multisample spec:
* From the ARB_texture_multisample spec, when describing the operation
* of RenderbufferStorageMultisample:
*
* "If <internalformat> is a signed or unsigned integer format and
* <samples> is greater than the value of MAX_INTEGER_SAMPLES, then the
* error INVALID_OPERATION is generated"
*
* And when describing the operation of TexImage*Multisample:
*
* "The error INVALID_OPERATION may be generated if any of the following are true:
*
* * <internalformat> is a depth/stencil-renderable format and <samples>
* is greater than the value of MAX_DEPTH_TEXTURE_SAMPLES
* * <internalformat> is a color-renderable format and <samples> is
* grater than the value of MAX_COLOR_TEXTURE_SAMPLES
* * <internalformat> is a signed or unsigned integer format and
* <samples> is greater than the value of MAX_INTEGER_SAMPLES
*/
if (ctx->Extensions.ARB_texture_multisample) {
if (_mesa_is_enum_format_integer(internalFormat))
return samples > ctx->Const.MaxIntegerSamples ? GL_INVALID_OPERATION : GL_NO_ERROR;
if (target == GL_TEXTURE_2D_MULTISAMPLE ||
target == GL_TEXTURE_2D_MULTISAMPLE_ARRAY) {
if (_mesa_is_depth_or_stencil_format(internalFormat))
return samples > ctx->Const.MaxDepthTextureSamples
? GL_INVALID_OPERATION : GL_NO_ERROR;
else
return samples > ctx->Const.MaxColorTextureSamples
? GL_INVALID_OPERATION : GL_NO_ERROR;
}
}
/* No more specific limit is available, so just use MAX_SAMPLES:
+7 -27
View File
@@ -40,6 +40,7 @@
#include "imports.h"
#include "macros.h"
#include "mfeatures.h"
#include "multisample.h"
#include "state.h"
#include "texcompress.h"
#include "texcompress_cpal.h"
@@ -4199,6 +4200,7 @@ teximagemultisample(GLuint dims, GLenum target, GLsizei samples,
struct gl_texture_image *texImage;
GLboolean sizeOK, dimensionsOK;
gl_format texFormat;
GLenum sample_count_error;
GET_CURRENT_CONTEXT(ctx);
@@ -4225,34 +4227,12 @@ teximagemultisample(GLuint dims, GLenum target, GLsizei samples,
return;
}
if (_mesa_is_enum_format_integer(internalformat)) {
if (samples > ctx->Const.MaxIntegerSamples) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glTexImage%uDMultisample(samples>GL_MAX_INTEGER_SAMPLES)",
dims);
return;
}
sample_count_error = _mesa_check_sample_count(ctx, target,
internalformat, samples);
if (sample_count_error != GL_NO_ERROR) {
_mesa_error(ctx, sample_count_error, "glTexImage%uDMultisample(samples)", dims);
return;
}
else if (_mesa_is_depth_or_stencil_format(internalformat)) {
if (samples > ctx->Const.MaxDepthTextureSamples) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glTexImage%uDMultisample(samples>GL_MAX_DEPTH_TEXTURE_SAMPLES)",
dims);
return;
}
}
else {
if (samples > ctx->Const.MaxColorTextureSamples) {
_mesa_error(ctx, GL_INVALID_OPERATION,
"glTexImage%uDMultisample(samples>GL_MAX_COLOR_TEXTURE_SAMPLES)",
dims);
return;
}
}
/* TODO: should ask the driver for the exact limit for this internalformat
* once IDR's internalformat_query bits land
*/
texObj = _mesa_get_current_tex_object(ctx, target);
texImage = _mesa_get_tex_image(ctx, texObj, 0, 0);