#include "main/mtypes.h"
#include "program/prog_execute.h"
#include "swrast.h"
+#include "s_fragprog.h"
#include "s_span.h"
GLfloat *texelOut);
-typedef void (*StoreTexelFunc)(struct swrast_texture_image *texImage,
- GLint col, GLint row, GLint img,
- const void *texel);
-
/**
* Subclass of gl_texture_image.
* We need extra fields/info to keep tracking of mapped texture buffers,
- * strides and Fetch/Store functions.
+ * strides and Fetch functions.
*/
struct swrast_texture_image
{
GLubyte *Buffer;
FetchTexelFunc FetchTexel;
- StoreTexelFunc Store;
};
}
+/**
+ * Subclass of gl_renderbuffer with extra fields needed for software
+ * rendering.
+ */
+struct swrast_renderbuffer
+{
+ struct gl_renderbuffer Base;
+
+ GLubyte *Buffer; /**< The malloc'd memory for buffer */
+
+ /** These fields are only valid while buffer is mapped for rendering */
+ GLubyte *Map;
+ GLint RowStride; /**< in bytes */
+
+ /** For span rendering */
+ GLenum ColorType;
+};
+
+
+/** cast wrapper */
+static inline struct swrast_renderbuffer *
+swrast_renderbuffer(struct gl_renderbuffer *img)
+{
+ return (struct swrast_renderbuffer *) img;
+}
+
+
+
/**
* \struct SWcontext
* \brief Per-context state that's private to the software rasterizer module.
/** State used during execution of fragment programs */
struct gl_program_machine FragProgMachine;
+ /** Temporary arrays for stencil operations. To avoid large stack
+ * allocations.
+ */
+ struct {
+ GLubyte *buf1, *buf2, *buf3, *buf4;
+ } stencil_temp;
+
} SWcontext;
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->RowStride * bpp;
- return (GLubyte *) rb->Data + y * rowStride + x * bpp;
+ const GLint rowStride = srb->RowStride;
+ assert(x >= 0);
+ assert(y >= 0);
+ /* NOTE: using <= only because of s_tritemp.h which gets a pixel
+ * address but doesn't necessarily access it.
+ */
+ assert(x <= (GLint) rb->Width);
+ assert(y <= (GLint) rb->Height);
+ assert(srb->Map);
+ return (GLubyte *) srb->Map + y * rowStride + x * bpp;
}