mesa/tests: Sanity check the ES2 dispatch table
[mesa.git] / src / mesa / swrast / s_context.h
index 36ab86a5e848fbd9a339d86a1c654976f28e554d..18353c4167b399b0ea24f711224cdba6fa299c64 100644 (file)
 #include "main/mtypes.h"
 #include "program/prog_execute.h"
 #include "swrast.h"
+#include "s_fragprog.h"
 #include "s_span.h"
 
 
 typedef void (*texture_sample_func)(struct gl_context *ctx,
+                                    const struct gl_sampler_object *samp,
                                     const struct gl_texture_object *tObj,
                                     GLuint n, const GLfloat texcoords[][4],
                                     const GLfloat lambda[], GLfloat rgba[][4]);
@@ -120,14 +122,10 @@ typedef void (*FetchTexelFunc)(const struct swrast_texture_image *texImage,
                                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
 {
@@ -148,7 +146,6 @@ struct swrast_texture_image
    GLubyte *Buffer;
 
    FetchTexelFunc FetchTexel;
-   StoreTexelFunc Store;
 };
 
 
@@ -167,6 +164,34 @@ swrast_texture_image_const(const struct gl_texture_image *img)
 }
 
 
+/**
+ * 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.
@@ -282,6 +307,13 @@ typedef struct
    /** 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;
 
 
@@ -428,8 +460,9 @@ _swrast_unmap_renderbuffers(struct gl_context *ctx);
 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;
+   const GLint rowStride = srb->RowStride;
    assert(x >= 0);
    assert(y >= 0);
    /* NOTE: using <= only because of s_tritemp.h which gets a pixel
@@ -437,8 +470,8 @@ _swrast_pixel_address(struct gl_renderbuffer *rb, GLint x, GLint y)
     */
    assert(x <= (GLint) rb->Width);
    assert(y <= (GLint) rb->Height);
-   assert(rb->Data);
-   return (GLubyte *) rb->Data + y * rowStride + x * bpp;
+   assert(srb->Map);
+   return (GLubyte *) srb->Map + y * rowStride + x * bpp;
 }