i965/vs: Add support for emitting DPH opcodes.
[mesa.git] / src / mesa / swrast / s_context.h
index 0a383aa3bff089e5d81bd48d886255ade33f7a96..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
 {
@@ -142,13 +140,12 @@ struct swrast_texture_image
    GLint RowStride;            /**< Padded width in units of texels */
    GLuint *ImageOffsets;        /**< if 3D texture: array [Depth] of offsets to
                                      each 2D slice in 'Data', in texels */
-   GLubyte *Data;              /**< Image data, accessed via FetchTexel() */
+   GLubyte *Map;               /**< Pointer to mapped image memory */
 
    /** Malloc'd texture memory */
    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,9 +460,18 @@ _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;
-   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;
 }