mesa: implement GetMultisamplefv
authorChris Forbes <chrisf@ijw.co.nz>
Sun, 25 Nov 2012 07:23:32 +0000 (20:23 +1300)
committerChris Forbes <chrisf@ijw.co.nz>
Fri, 1 Mar 2013 22:35:13 +0000 (11:35 +1300)
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.
    - rename GetSampleLocation to GetSamplePosition
    - invert y sample position for winsys FBOs, at Paul's suggestion

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/drivers/common/driverfuncs.c
src/mesa/main/dd.h
src/mesa/main/multisample.c

index 43c9de97f5048fb0c80e2a98fcc9c331ffebd8d7..731d46658d081e1bfe0cd682f5b26768876cc905 100644 (file)
@@ -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->GetSamplePosition = NULL;
 }
 
 
index 9c818ccd86aea812d425d3ff7ddb1df09dd727b9..4907116261702a1f41d2494d0f460df8e938bec1 100644 (file)
@@ -833,6 +833,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 (*GetSamplePosition)(struct gl_context *ctx,
+                             struct gl_framebuffer *fb,
+                             GLuint index,
+                             GLfloat *outValue);
 };
 
 
index 0687cd042d7354ca51bf3d9ba18f0fe89b19d18c..2d3a35ef38993cb14ffd122b6cc8147218b61276 100644 (file)
@@ -28,6 +28,7 @@
 #include "main/macros.h"
 #include "main/multisample.h"
 #include "main/mtypes.h"
+#include "main/fbobject.h"
 
 
 /**
@@ -65,8 +66,28 @@ _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: {
+      if (index >= ctx->DrawBuffer->Visual.samples) {
+         _mesa_error( ctx, GL_INVALID_VALUE, "glGetMultisamplefv(index)" );
+         return;
+      }
+
+      ctx->Driver.GetSamplePosition(ctx, ctx->DrawBuffer, index, val);
+
+      /* winsys FBOs are upside down */
+      if (_mesa_is_winsys_fbo(ctx->DrawBuffer))
+         val[1] = 1 - val[1];
+
+      return;
+   }
+
+   default:
+      _mesa_error( ctx, GL_INVALID_ENUM, "glGetMultisamplefv(pname)" );
+      return;
+   }
 }
 
 void GLAPIENTRY