aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/multisample.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-03-25 10:20:34 +0100
committermarha <marha@users.sourceforge.net>2013-03-25 10:20:34 +0100
commit176eab9e8277db1549bfc6c9ae805c4e1858f0b0 (patch)
treea4c8d2d939aa500304d979377e39316b115a8128 /mesalib/src/mesa/main/multisample.c
parent9c17f511266fff48a936633de280f271f0ce0c11 (diff)
downloadvcxsrv-176eab9e8277db1549bfc6c9ae805c4e1858f0b0.tar.gz
vcxsrv-176eab9e8277db1549bfc6c9ae805c4e1858f0b0.tar.bz2
vcxsrv-176eab9e8277db1549bfc6c9ae805c4e1858f0b0.zip
fontconfig mesa pixman xserver git update 25 Mar 2013
xserver commit 2967391c6d35f03121afa8003e0fb94b62495129 pixman commit d8ac35af1208a4fa4d67f03fee10b5449fb8495a fontconfig commit b561ff2016ce84eef3c81f16dfb0481be6a13f9b mesa commit 92b8a37fdfff9e83f39b8885f51ed2f60326ab6a
Diffstat (limited to 'mesalib/src/mesa/main/multisample.c')
-rw-r--r--mesalib/src/mesa/main/multisample.c77
1 files changed, 77 insertions, 0 deletions
diff --git a/mesalib/src/mesa/main/multisample.c b/mesalib/src/mesa/main/multisample.c
index 248494615..b0f45d933 100644
--- a/mesalib/src/mesa/main/multisample.c
+++ b/mesalib/src/mesa/main/multisample.c
@@ -29,6 +29,7 @@
#include "main/multisample.h"
#include "main/mtypes.h"
#include "main/fbobject.h"
+#include "main/glformats.h"
/**
@@ -112,3 +113,79 @@ _mesa_SampleMaski(GLuint index, GLbitfield mask)
FLUSH_VERTICES(ctx, _NEW_MULTISAMPLE);
ctx->Multisample.SampleMaskValue = mask;
}
+
+
+/* Helper for checking a requested sample count against the limit
+ * for a particular (target, internalFormat) pair. The limit imposed,
+ * and the error generated, both depend on which extensions are supported.
+ *
+ * Returns a GL error enum, or GL_NO_ERROR if the requested sample count is
+ * acceptable.
+ */
+GLenum
+_mesa_check_sample_count(struct gl_context *ctx, GLenum target,
+ GLenum internalFormat, GLsizei samples)
+{
+ /* If ARB_internalformat_query is supported, then treat its highest returned sample
+ * count as the absolute maximum for this format; it is allowed to exceed MAX_SAMPLES.
+ *
+ * From the ARB_internalformat_query spec:
+ *
+ * "If <samples is greater than the maximum number of samples supported
+ * for <internalformat> then the error INVALID_OPERATION is generated."
+ */
+ if (ctx->Extensions.ARB_internalformat_query) {
+ GLint buffer[16];
+ int count = ctx->Driver.QuerySamplesForFormat(ctx, target, internalFormat, buffer);
+ int limit = count ? buffer[0] : -1;
+
+ return samples > limit ? GL_INVALID_OPERATION : GL_NO_ERROR;
+ }
+
+ /* If ARB_texture_multisample is supported, we have separate limits,
+ * which may be lower than MAX_SAMPLES:
+ *
+ * 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:
+ *
+ * On p205 of the GL3.1 spec:
+ *
+ * "... or if samples is greater than MAX_SAMPLES, then the error
+ * INVALID_VALUE is generated"
+ */
+ return samples > ctx->Const.MaxSamples ? GL_INVALID_VALUE : GL_NO_ERROR;
+}