[Mesa-dev] [PATCH V2 09/22] mesa: implement GetMultisamplefv
Chris Forbes
chrisf at ijw.co.nz
Mon Feb 4 21:48:43 PST 2013
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 at ijw.co.nz>
---
src/mesa/drivers/common/driverfuncs.c | 3 +++
src/mesa/main/dd.h | 8 ++++++++
src/mesa/main/multisample.c | 25 +++++++++++++++++++++++--
3 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c
index aab61e1..bafde7a 100644
--- a/src/mesa/drivers/common/driverfuncs.c
+++ b/src/mesa/drivers/common/driverfuncs.c
@@ -208,6 +208,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;
}
diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 9a75fd9..65d358f 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -831,6 +831,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);
};
diff --git a/src/mesa/main/multisample.c b/src/mesa/main/multisample.c
index 25c20e3..0ac90bc 100644
--- a/src/mesa/main/multisample.c
+++ b/src/mesa/main/multisample.c
@@ -28,6 +28,7 @@
#include "main/macros.h"
#include "main/multisample.h"
#include "main/mtypes.h"
+#include "main/fbobject.h"
/**
@@ -64,8 +65,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
--
1.8.1.2
More information about the mesa-dev
mailing list