static inline GLubyte *
_swrast_pixel_address(struct gl_renderbuffer *rb, GLint x, GLint y)
{
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
const GLint bpp = _mesa_get_format_bytes(rb->Format);
- const GLint rowStride = rb->RowStrideBytes;
+ const GLint rowStride = srb->RowStride;
assert(x >= 0);
assert(y >= 0);
/* NOTE: using <= only because of s_tritemp.h which gets a pixel
*/
assert(x <= (GLint) rb->Width);
assert(y <= (GLint) rb->Height);
- assert(rb->Map);
- return (GLubyte *) rb->Map + y * rowStride + x * bpp;
+ assert(srb->Map);
+ return (GLubyte *) srb->Map + y * rowStride + x * bpp;
}
{
struct gl_framebuffer *fb = ctx->ReadBuffer;
struct gl_renderbuffer *rb;
+ struct swrast_renderbuffer *srb;
switch (type) {
case GL_COLOR:
return NULL;
}
- if (!rb || rb->Map) {
+ srb = swrast_renderbuffer(rb);
+
+ if (!srb || srb->Map) {
/* no buffer, or buffer is mapped already, we're done */
return NULL;
}
ctx->Driver.MapRenderbuffer(ctx, rb,
0, 0, rb->Width, rb->Height,
GL_MAP_READ_BIT,
- &rb->Map, &rb->RowStrideBytes);
+ &srb->Map, &srb->RowStride);
return rb;
}
swrast_render_finish(ctx);
if (rb) {
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
ctx->Driver.UnmapRenderbuffer(ctx, rb);
- rb->Map = NULL;
+ srb->Map = NULL;
}
}
GLuint count, const GLint x[], const GLint y[],
GLuint zbuffer[])
{
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
const GLint w = rb->Width, h = rb->Height;
const GLubyte *map = _swrast_pixel_address(rb, 0, 0);
GLuint i;
if (rb->Format == MESA_FORMAT_Z32) {
- const GLint rowStride = rb->RowStrideBytes;
+ const GLint rowStride = srb->RowStride;
for (i = 0; i < count; i++) {
if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) {
zbuffer[i] = *((GLuint *) (map + y[i] * rowStride + x[i] * 4));
}
else {
const GLint bpp = _mesa_get_format_bytes(rb->Format);
- const GLint rowStride = rb->RowStrideBytes;
+ const GLint rowStride = srb->RowStride;
for (i = 0; i < count; i++) {
if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) {
const GLubyte *src = map + y[i] * rowStride+ x[i] * bpp;
GLuint count, const GLint x[], const GLint y[],
const GLuint zvalues[], const GLubyte mask[])
{
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
const GLint w = rb->Width, h = rb->Height;
GLubyte *map = _swrast_pixel_address(rb, 0, 0);
GLuint i;
if (rb->Format == MESA_FORMAT_Z32) {
- const GLuint rowStride = rb->RowStrideBytes;
+ const GLuint rowStride = srb->RowStride;
for (i = 0; i < count; i++) {
if (mask[i] && x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) {
GLuint *dst = (GLuint *) (map + y[i] * rowStride + x[i] * 4);
else {
gl_pack_uint_z_func packZ = _mesa_get_pack_uint_z_func(rb->Format);
const GLint bpp = _mesa_get_format_bytes(rb->Format);
- const GLint rowStride = rb->RowStrideBytes;
+ const GLint rowStride = srb->RowStride;
for (i = 0; i < count; i++) {
if (mask[i] && x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) {
void *dst = map + y[i] * rowStride + x[i] * bpp;
const GLenum type = GL_UNSIGNED_INT_24_8;
struct gl_renderbuffer *rb =
ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
GLubyte *src, *dst;
GLint srcRowStride, dstRowStride;
GLint i;
srcRowStride = _mesa_image_row_stride(unpack, width, format, type);
dst = _swrast_pixel_address(rb, x, y);
- dstRowStride = rb->RowStrideBytes;
+ dstRowStride = srb->RowStride;
for (i = 0; i < height; i++) {
_mesa_pack_uint_24_8_depth_stencil_row(rb->Format, width,
#include "main/formats.h"
#include "main/mtypes.h"
#include "main/renderbuffer.h"
+#include "swrast/s_context.h"
#include "swrast/s_renderbuffer.h"
GLenum internalFormat,
GLuint width, GLuint height)
{
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
+
switch (internalFormat) {
case GL_RGB:
case GL_R3_G3_B2:
}
/* free old buffer storage */
- if (rb->Buffer) {
- free(rb->Buffer);
- rb->Buffer = NULL;
+ if (srb->Buffer) {
+ free(srb->Buffer);
+ srb->Buffer = NULL;
}
- rb->RowStrideBytes = width * _mesa_get_format_bytes(rb->Format);
+ srb->RowStride = width * _mesa_get_format_bytes(rb->Format);
if (width > 0 && height > 0) {
/* allocate new buffer storage */
- rb->Buffer = malloc(width * height * _mesa_get_format_bytes(rb->Format));
+ srb->Buffer = malloc(width * height
+ * _mesa_get_format_bytes(rb->Format));
- if (rb->Buffer == NULL) {
+ if (srb->Buffer == NULL) {
rb->Width = 0;
rb->Height = 0;
_mesa_error(ctx, GL_OUT_OF_MEMORY,
static void
soft_renderbuffer_delete(struct gl_renderbuffer *rb)
{
- if (rb->Buffer) {
- free(rb->Buffer);
- rb->Buffer = NULL;
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
+
+ if (srb->Buffer) {
+ free(srb->Buffer);
+ srb->Buffer = NULL;
}
- free(rb);
+ free(srb);
}
GLubyte **out_map,
GLint *out_stride)
{
- GLubyte *map = rb->Buffer;
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
+ GLubyte *map = srb->Buffer;
int cpp = _mesa_get_format_bytes(rb->Format);
int stride = rb->Width * cpp;
struct gl_renderbuffer *
_swrast_new_soft_renderbuffer(struct gl_context *ctx, GLuint name)
{
- struct gl_renderbuffer *rb = _mesa_new_renderbuffer(ctx, name);
- if (rb) {
- rb->AllocStorage = soft_renderbuffer_storage;
- rb->Delete = soft_renderbuffer_delete;
+ struct swrast_renderbuffer *srb = CALLOC_STRUCT(swrast_renderbuffer);
+ if (srb) {
+ _mesa_init_renderbuffer(&srb->Base, name);
+ srb->Base.AllocStorage = soft_renderbuffer_storage;
+ srb->Base.Delete = soft_renderbuffer_delete;
}
- return rb;
+ return &srb->Base;
}
GLuint n, GLint x, GLint y,
GLvoid *rgba)
{
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
GLenum dstType = GL_FLOAT;
const GLint bufWidth = (GLint) rb->Width;
const GLint bufHeight = (GLint) rb->Height;
rb->_BaseFormat == GL_LUMINANCE_ALPHA ||
rb->_BaseFormat == GL_ALPHA);
- assert(rb->Map);
+ assert(srb->Map);
src = _swrast_pixel_address(rb, x + skip, y);
GLuint count, const GLint x[], const GLint y[],
GLubyte stencil[])
{
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
const GLint w = rb->Width, h = rb->Height;
const GLubyte *map = _swrast_pixel_address(rb, 0, 0);
GLuint i;
if (rb->Format == MESA_FORMAT_S8) {
- const GLint rowStride = rb->RowStrideBytes;
+ const GLint rowStride = srb->RowStride;
for (i = 0; i < count; i++) {
if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) {
stencil[i] = *(map + y[i] * rowStride + x[i]);
}
else {
const GLint bpp = _mesa_get_format_bytes(rb->Format);
- const GLint rowStride = rb->RowStrideBytes;
+ const GLint rowStride = srb->RowStride;
for (i = 0; i < count; i++) {
if (x[i] >= 0 && y[i] >= 0 && x[i] < w && y[i] < h) {
const GLubyte *src = map + y[i] * rowStride + x[i] * bpp;
update_wrapper(struct gl_context *ctx, struct gl_renderbuffer_attachment *att)
{
struct gl_renderbuffer *rb = att->Renderbuffer;
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
struct swrast_texture_image *swImage;
gl_format format;
GLuint zOffset;
*/
if (att->Texture->Target == GL_TEXTURE_3D ||
att->Texture->Target == GL_TEXTURE_2D_ARRAY_EXT) {
- rb->Buffer = swImage->Buffer +
+ srb->Buffer = swImage->Buffer +
swImage->ImageOffsets[zOffset] * _mesa_get_format_bytes(format);
}
else {
- rb->Buffer = swImage->Buffer;
+ srb->Buffer = swImage->Buffer;
}
}
{
struct gl_texture_object *texObj = fb->Attachment[buffer].Texture;
struct gl_renderbuffer *rb = fb->Attachment[buffer].Renderbuffer;
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
if (texObj) {
const GLuint level = fb->Attachment[buffer].TextureLevel;
/* XXX we'll eventually call _swrast_map_teximage() here */
swImage->Map = swImage->Buffer;
- if (rb) {
- rb->Map = swImage->Buffer;
- rb->RowStrideBytes = swImage->RowStride *
+ if (srb) {
+ srb->Map = swImage->Buffer;
+ srb->RowStride = swImage->RowStride *
_mesa_get_format_bytes(swImage->Base.TexFormat);
}
}
}
else if (rb) {
/* Map ordinary renderbuffer */
- ctx->Driver.MapRenderbuffer(ctx, rb,
- 0, 0, rb->Width, rb->Height,
- GL_MAP_READ_BIT | GL_MAP_WRITE_BIT,
- &rb->Map, &rb->RowStrideBytes);
- assert(rb->Map);
+ ctx->Driver.MapRenderbuffer(ctx, rb,
+ 0, 0, rb->Width, rb->Height,
+ GL_MAP_READ_BIT | GL_MAP_WRITE_BIT,
+ &srb->Map, &srb->RowStride);
+ assert(srb->Map);
}
}
{
struct gl_texture_object *texObj = fb->Attachment[buffer].Texture;
struct gl_renderbuffer *rb = fb->Attachment[buffer].Renderbuffer;
+ struct swrast_renderbuffer *srb = swrast_renderbuffer(rb);
if (texObj) {
const GLuint level = fb->Attachment[buffer].TextureLevel;
ctx->Driver.UnmapRenderbuffer(ctx, rb);
}
- rb->Map = NULL;
+ srb->Map = NULL;
}