swrast: introduce new swrast_texture_image struct
authorBrian Paul <brianp@vmware.com>
Sat, 17 Sep 2011 20:50:48 +0000 (14:50 -0600)
committerBrian Paul <brianp@vmware.com>
Sat, 17 Sep 2011 20:57:40 +0000 (14:57 -0600)
No subclass fields yet.  Subsequent patches will add the fields related
to software rendering that are currently in gl_texture_image.

src/mesa/swrast/s_context.h
src/mesa/swrast/s_texture.c
src/mesa/swrast/swrast.h

index 8d7458c2dd948a0f0c626b477ca7b7a4a96bdd30..687480ed285776ccbc251c13afe21161abcc0c26 100644 (file)
@@ -109,6 +109,35 @@ typedef void (*validate_texture_image_func)(struct gl_context *ctx,
                                _NEW_DEPTH)
 
 
+/**
+ * Subclass of gl_texture_image.
+ * We need extra fields/info to keep tracking of mapped texture buffers,
+ * strides and Fetch/Store functions.
+ */
+struct swrast_texture_image
+{
+   struct gl_texture_image Base;
+
+   /* XXX new members coming soon */
+};
+
+
+/** cast wrapper */
+static INLINE struct swrast_texture_image *
+swrast_texture_image(struct gl_texture_image *img)
+{
+   return (struct swrast_texture_image *) img;
+}
+
+/** cast wrapper */
+static INLINE const struct swrast_texture_image *
+swrast_texture_image_const(const struct gl_texture_image *img)
+{
+   return (const struct swrast_texture_image *) img;
+}
+
+
+
 /**
  * \struct SWcontext
  * \brief  Per-context state that's private to the software rasterizer module.
index 6cc72c582f769c3b5f67dfc453e43d2e920ca689..184fd952dc5f81e367dbdca1cdfefc18e0f545f5 100644 (file)
 
 #include "main/context.h"
 #include "main/fbobject.h"
+#include "main/teximage.h"
 #include "swrast/swrast.h"
 #include "swrast/s_context.h"
 
+
+/**
+ * Allocate a new swrast_texture_image (a subclass of gl_texture_image).
+ * Called via ctx->Driver.NewTextureImage().
+ */
+struct gl_texture_image *
+_swrast_new_texture_image( struct gl_context *ctx )
+{
+   (void) ctx;
+   return (struct gl_texture_image *) CALLOC_STRUCT(swrast_texture_image);
+}
+
+
+/**
+ * Free a swrast_texture_image (a subclass of gl_texture_image).
+ * Called via ctx->Driver.DeleteTextureImage().
+ */
+void
+_swrast_delete_texture_image(struct gl_context *ctx,
+                             struct gl_texture_image *texImage)
+{
+   /* Nothing special for the subclass yet */
+   _mesa_delete_texture_image(ctx, texImage);
+}
+
+
 /**
  * Error checking for debugging only.
  */
index c8b9986356862f08a8f8d885d53f00a735accc96..d732c31ad148f6543c9bb162a0eaaf09e0954ebb 100644 (file)
@@ -182,6 +182,13 @@ _swrast_render_start( struct gl_context *ctx );
 extern void
 _swrast_render_finish( struct gl_context *ctx );
 
+extern struct gl_texture_image *
+_swrast_new_texture_image( struct gl_context *ctx );
+
+extern void
+_swrast_delete_texture_image(struct gl_context *ctx,
+                             struct gl_texture_image *texImage);
+
 extern void
 _swrast_map_teximage(struct gl_context *ctx,
                     struct gl_texture_image *texImage,