[Mesa-dev] [PATCH V2 1/3] mesa: allow internalformat_query with multisample texture targets
Chris Forbes
chrisf at ijw.co.nz
Sat Mar 23 18:50:02 PDT 2013
Now that we support ARB_texture_multisample, there are multiple targets
accepted for this query, and they may have target-dependent limits, so
pass the target to the driverfunc.
For example, the sampling hardware may not be able to do general
texelFetch() for some format/sample count combination, but the driver
may still be able to implement a reasonable resolve operation, so it can
be supported for renderbuffers.
V2: - Don't break Gallium compile.
Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
src/mesa/drivers/dri/i965/brw_context.c | 6 ++++--
src/mesa/main/dd.h | 4 +++-
src/mesa/main/formatquery.c | 12 +++++++-----
src/mesa/state_tracker/st_format.c | 6 ++++--
src/mesa/state_tracker/st_format.h | 4 ++--
5 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 72378bc..b8e39ab 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -59,11 +59,13 @@
***************************************/
static size_t
-brw_query_samples_for_format(struct gl_context *ctx, GLenum internalFormat,
- int samples[16])
+brw_query_samples_for_format(struct gl_context *ctx, GLenum target,
+ GLenum internalFormat, int samples[16])
{
struct intel_context *intel = intel_context(ctx);
+ (void) target;
+
switch (intel->gen) {
case 7:
samples[0] = 8;
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 4860d4d..8f3cd3d 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -195,9 +195,10 @@ struct dd_function_table {
GLenum srcFormat, GLenum srcType );
/**
- * Determine sample counts support for a particular format
+ * Determine sample counts support for a particular target and format
*
* \param ctx GL context
+ * \param target GL target enum
* \param internalFormat GL format enum
* \param samples Buffer to hold the returned sample counts.
* Drivers \b must \b not return more than 16 counts.
@@ -207,6 +208,7 @@ struct dd_function_table {
* \c internaFormat is not renderable, zero is returned.
*/
size_t (*QuerySamplesForFormat)(struct gl_context *ctx,
+ GLenum target,
GLenum internalFormat,
int samples[16]);
diff --git a/src/mesa/main/formatquery.c b/src/mesa/main/formatquery.c
index bd895e8..78c5fbe 100644
--- a/src/mesa/main/formatquery.c
+++ b/src/mesa/main/formatquery.c
@@ -59,9 +59,10 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
case GL_TEXTURE_2D_MULTISAMPLE:
case GL_TEXTURE_2D_MULTISAMPLE_ARRAY:
- /* Mesa does not currently support GL_ARB_texture_multisample, so these
- * enums are not valid on this implementation either.
- */
+ /* These enums are only valid if ARB_texture_multisample is supported */
+ if (_mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_texture_multisample)
+ break;
+
default:
_mesa_error(ctx, GL_INVALID_ENUM,
"glGetInternalformativ(target=%s)",
@@ -96,7 +97,8 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
switch (pname) {
case GL_SAMPLES:
- count = ctx->Driver.QuerySamplesForFormat(ctx, internalformat, buffer);
+ count = ctx->Driver.QuerySamplesForFormat(ctx, target,
+ internalformat, buffer);
break;
case GL_NUM_SAMPLE_COUNTS: {
/* The driver can return 0, and we should pass that along to the
@@ -115,7 +117,7 @@ _mesa_GetInternalformativ(GLenum target, GLenum internalformat, GLenum pname,
* returned."
*/
const size_t num_samples =
- ctx->Driver.QuerySamplesForFormat(ctx, internalformat, buffer);
+ ctx->Driver.QuerySamplesForFormat(ctx, target, internalformat, buffer);
/* QuerySamplesForFormat writes some stuff to buffer, so we have to
* separately over-write it with the requested value.
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 5fd44e7..a15706a 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -1769,13 +1769,15 @@ st_ChooseTextureFormat(struct gl_context *ctx, GLenum target,
* Called via ctx->Driver.ChooseTextureFormat().
*/
size_t
-st_QuerySamplesForFormat(struct gl_context *ctx, GLenum internalFormat,
- int samples[16])
+st_QuerySamplesForFormat(struct gl_context *ctx, GLenum target,
+ GLenum internalFormat, int samples[16])
{
struct st_context *st = st_context(ctx);
enum pipe_format format;
unsigned i, bind, num_sample_counts = 0;
+ (void) target;
+
if (_mesa_is_depth_or_stencil_format(internalFormat))
bind = PIPE_BIND_DEPTH_STENCIL;
else
diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h
index 3db409b..0a1c18d 100644
--- a/src/mesa/state_tracker/st_format.h
+++ b/src/mesa/state_tracker/st_format.h
@@ -67,8 +67,8 @@ st_ChooseTextureFormat(struct gl_context * ctx, GLenum target,
GLenum format, GLenum type);
size_t
-st_QuerySamplesForFormat(struct gl_context *ctx, GLenum internalFormat,
- int samples[16]);
+st_QuerySamplesForFormat(struct gl_context *ctx, GLenum target,
+ GLenum internalFormat, int samples[16]);
/* can we use a sampler view to translate these formats
only used to make TFP so far */
--
1.8.2
More information about the mesa-dev
mailing list