(y * rb->RowStride + x) * _mesa_get_format_bytes(rb->Format));
}
-/**********************************************************************
- * Functions for buffers of 1 X GLubyte values.
- * Typically stencil.
+/* GetRow() implementation for formats where DataType matches the rb->Format.
*/
-
static void
-get_row_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
+get_row_generic(struct gl_context *ctx, struct gl_renderbuffer *rb,
+ GLuint count, GLint x, GLint y, void *values)
{
- const GLubyte *src = (const GLubyte *) rb->Data + y * rb->RowStride + x;
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- memcpy(values, src, count * sizeof(GLubyte));
+ void *src = rb->GetPointer(ctx, rb, x, y);
+ memcpy(values, src, count * _mesa_get_format_bytes(rb->Format));
}
+/**********************************************************************
+ * Functions for buffers of 1 X GLubyte values.
+ * Typically stencil.
+ */
static void
get_values_ubyte(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
*/
static void
-get_row_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const void *src = rb->GetPointer(ctx, rb, x, y);
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT);
- memcpy(values, src, count * sizeof(GLushort));
-}
-
-
-static void
get_values_ushort(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLint x[], const GLint y[], void *values)
{
*/
static void
-get_row_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const void *src = rb->GetPointer(ctx, rb, x, y);
- ASSERT(rb->DataType == GL_UNSIGNED_INT ||
- rb->DataType == GL_UNSIGNED_INT_24_8_EXT);
- memcpy(values, src, count * sizeof(GLuint));
-}
-
-
-static void
get_values_uint(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLint x[], const GLint y[], void *values)
{
*/
static void
-get_row_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const GLubyte *src = (const GLubyte *) (rb->Data +
- 4 * (y * rb->RowStride + x));
- ASSERT(rb->DataType == GL_UNSIGNED_BYTE);
- ASSERT(rb->Format == MESA_FORMAT_RGBA8888);
- memcpy(values, src, 4 * count * sizeof(GLubyte));
-}
-
-
-static void
get_values_ubyte4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLint x[], const GLint y[], void *values)
{
*/
static void
-get_row_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
- GLint x, GLint y, void *values)
-{
- const GLshort *src = (const GLshort *) (rb->Data +
- 4 * (y * rb->RowStride + x));
- ASSERT(rb->DataType == GL_UNSIGNED_SHORT || rb->DataType == GL_SHORT);
- memcpy(values, src, 4 * count * sizeof(GLshort));
-}
-
-
-static void
get_values_ushort4(struct gl_context *ctx, struct gl_renderbuffer *rb, GLuint count,
const GLint x[], const GLint y[], void *values)
{
_mesa_set_renderbuffer_accessors(struct gl_renderbuffer *rb)
{
rb->GetPointer = get_pointer_generic;
+ rb->GetRow = get_row_generic;
switch (rb->Format) {
case MESA_FORMAT_RGB888:
case MESA_FORMAT_RGBA8888:
rb->DataType = GL_UNSIGNED_BYTE;
- rb->GetRow = get_row_ubyte4;
rb->GetValues = get_values_ubyte4;
rb->PutRow = put_row_ubyte4;
rb->PutRowRGB = put_row_rgb_ubyte4;
case MESA_FORMAT_SIGNED_RGBA_16:
rb->DataType = GL_SHORT;
- rb->GetRow = get_row_ushort4;
rb->GetValues = get_values_ushort4;
rb->PutRow = put_row_ushort4;
rb->PutRowRGB = put_row_rgb_ushort4;
#if 0
case MESA_FORMAT_A8:
rb->DataType = GL_UNSIGNED_BYTE;
- rb->GetRow = get_row_alpha8;
rb->GetValues = get_values_alpha8;
rb->PutRow = put_row_alpha8;
rb->PutRowRGB = NULL;
case MESA_FORMAT_S8:
rb->DataType = GL_UNSIGNED_BYTE;
- rb->GetRow = get_row_ubyte;
rb->GetValues = get_values_ubyte;
rb->PutRow = put_row_ubyte;
rb->PutRowRGB = NULL;
case MESA_FORMAT_Z16:
rb->DataType = GL_UNSIGNED_SHORT;
- rb->GetRow = get_row_ushort;
rb->GetValues = get_values_ushort;
rb->PutRow = put_row_ushort;
rb->PutRowRGB = NULL;
case MESA_FORMAT_X8_Z24:
case MESA_FORMAT_Z24_X8:
rb->DataType = GL_UNSIGNED_INT;
- rb->GetRow = get_row_uint;
rb->GetValues = get_values_uint;
rb->PutRow = put_row_uint;
rb->PutRowRGB = NULL;
case MESA_FORMAT_Z24_S8:
case MESA_FORMAT_S8_Z24:
rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
- rb->GetRow = get_row_uint;
rb->GetValues = get_values_uint;
rb->PutRow = put_row_uint;
rb->PutRowRGB = NULL;