[Mesa-dev] [RFC PATCH 12/26] mesa: implement GetMultisamplefv

Chris Forbes chrisf at ijw.co.nz
Sat Dec 29 04:35:25 PST 2012


Actual sample locations deferred to a driverfunc since only the driver
really knows where they will be.

V2: pass the draw buffer to the driverfunc; don't fallback to pixel
center if driverfunc is missing.

Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
---
 src/mesa/drivers/common/driverfuncs.c |  3 +++
 src/mesa/main/dd.h                    |  8 ++++++++
 src/mesa/main/multisample.c           | 21 +++++++++++++++++++--
 3 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c
index 93fa3c7..5ee4e7c 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -209,6 +209,9 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
 
    /* GL_ARB_texture_storage */
    driver->AllocTextureStorage = _swrast_AllocTextureStorage;
+
+   /* GL_ARB_texture_multisample */
+   driver->GetSampleLocation = NULL;
 }
 
 
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 70c5324..69e0252 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -829,6 +829,14 @@ struct dd_function_table {
     * This should be equivalent to glGetInteger64v(GL_TIMESTAMP);
     */
    uint64_t (*GetTimestamp)(struct gl_context *ctx);
+
+   /**
+    * \name GL_ARB_texture_multisample
+    */
+   void (*GetSampleLocation)(struct gl_context *ctx,
+                             struct gl_framebuffer *fb,
+                             GLuint index,
+                             GLfloat *outValue);
 };
 
 
diff --git a/src/mesa/main/multisample.c b/src/mesa/main/multisample.c
index 0cc8eaf..ee9e263 100644
--- a/src/mesa/main/multisample.c
+++ b/src/mesa/main/multisample.c
@@ -64,8 +64,25 @@ _mesa_init_multisample(struct gl_context *ctx)
 void GLAPIENTRY
 _mesa_GetMultisamplefv(GLenum pname, GLuint index, GLfloat * val)
 {
-   assert(!"Not implemented");
-   // TODO: make this work
+   GET_CURRENT_CONTEXT(ctx);
+
+   switch (pname) {
+   case GL_SAMPLE_POSITION: {
+      int samples = ctx->DrawBuffer->Visual.samples;
+
+      if (index >= samples) {
+         _mesa_error( ctx, GL_INVALID_VALUE, "glGetMultisamplefv(index)" );
+         return;
+      }
+
+      ctx->Driver.GetSampleLocation(ctx, ctx->DrawBuffer, index, val);
+      return;
+   }
+
+   default:
+      _mesa_error( ctx, GL_INVALID_ENUM, "glGetMultisamplefv(pname)" );
+      return;
+   }
 }
 
 void GLAPIENTRY
-- 
1.8.0.3



More information about the mesa-dev mailing list