initial texture object, texture format code
authorBrian <brian.paul@tungstengraphics.com>
Fri, 22 Jun 2007 19:37:47 +0000 (13:37 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Fri, 22 Jun 2007 19:37:47 +0000 (13:37 -0600)
src/mesa/pipe/p_context.h
src/mesa/pipe/p_defines.h
src/mesa/pipe/p_state.h
src/mesa/pipe/softpipe/sp_context.c
src/mesa/pipe/softpipe/sp_context.h
src/mesa/pipe/softpipe/sp_state.h
src/mesa/pipe/softpipe/sp_state_sampler.c

index 7e68699..d9546a2 100644 (file)
@@ -100,6 +100,10 @@ struct pipe_context {
                               GLuint unit,
                               const struct pipe_sampler_state * );
 
+   void (*set_texture_state)( struct pipe_context *,
+                              GLuint unit,
+                              struct pipe_texture_object * );
+
    void (*set_viewport)( struct pipe_context *,
                         const struct pipe_viewport * );
 };
index 7557310..a0c4d72 100644 (file)
 #define PIPE_TEX_COMPARE_NONE          0
 #define PIPE_TEX_COMPARE_R_TO_TEXTURE  1
 
+/**
+ * Texture/surface image formats
+ */
+#define PIPE_FORMAT_U_R8_G8_B8_A8   0  /**< ubyte[4] RGBA */
+#define PIPE_FORMAT_U_A8_R8_G8_B8   1  /**< ubyte[4] ARGB */
+#define PIPE_FORMAT_U_R5_G6_B5      2  /**< 5/6/5 RGB */
+#define PIPE_FORMAT_U_L8            3  /**< ubyte luminance */
+#define PIPE_FORMAT_U_A8            4  /**< ubyte alpha */
+#define PIPE_FORMAT_U_I8            5  /**< ubyte intensity */
+#define PIPE_FORMAT_U_L8_A8         6  /**< ubyte luminance, alpha */
+
+#define PIPE_FORMAT_U_Z16           7  /**< ushort Z/depth */
+#define PIPE_FORMAT_F_Z32           8  /**< float Z/depth */
+#define PIPE_FORMAT_YCBCR           9
+#define PIPE_FORMAT_YCBCR_REV      10
+
 #endif
index f3723eb..3e3da7c 100644 (file)
@@ -231,4 +231,18 @@ struct pipe_sampler_state
    GLfloat max_anisotropy;
 };
 
+
+/**
+ * XXX rough approximation...
+ */
+struct pipe_texture_object
+{
+   GLuint format:5;    /**< PIPE_FORMAT_x */
+   GLuint width:13;    /**< 13 bits = 8K max size */
+   GLuint height:13;
+   GLuint depth:13;
+   GLubyte *data;      /**< only valid while buffer mapped? */
+};
+
+
 #endif
index 07b529f..0d00c7e 100644 (file)
@@ -77,6 +77,7 @@ struct pipe_context *softpipe_create( void )
    softpipe->pipe.set_fs_state = softpipe_set_fs_state;
    softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple;
    softpipe->pipe.set_sampler_state = softpipe_set_sampler_state;
+   softpipe->pipe.set_texture_state = softpipe_set_texture_state;
    softpipe->pipe.draw_vb = softpipe_draw_vb;
    softpipe->pipe.clear = softpipe_clear;
 
index d8c0de0..7c816db 100644 (file)
@@ -63,6 +63,7 @@ enum interp_mode {
 #define G_NEW_ALPHA_TEST  0x200
 #define G_NEW_DEPTH_TEST  0x400
 #define G_NEW_SAMPLER     0x800
+#define G_NEW_TEXTURE    0x1000
 
 
 #define PIPE_ATTRIB_MAX 32
@@ -86,6 +87,7 @@ struct softpipe_context {
    struct pipe_scissor_rect scissor;
    struct pipe_poly_stipple poly_stipple;
    struct pipe_sampler_state sampler[PIPE_MAX_SAMPLERS];
+   struct pipe_texture_object *texture[PIPE_MAX_SAMPLERS];
    GLuint dirty;
 
    /* Clip derived state:
index faaa043..735d039 100644 (file)
@@ -63,6 +63,10 @@ void softpipe_set_sampler_state( struct pipe_context *,
                                  GLuint unit,
                                  const struct pipe_sampler_state * );
 
+void softpipe_set_texture_state( struct pipe_context *,
+                                 GLuint unit,
+                                 struct pipe_texture_object * );
+
 void softpipe_set_scissor_rect( struct pipe_context *,
                               const struct pipe_scissor_rect * );
 
index 6b422ac..060e2c8 100644 (file)
@@ -43,7 +43,22 @@ softpipe_set_sampler_state(struct pipe_context *pipe,
 {
    struct softpipe_context *softpipe = softpipe_context(pipe);
 
+   assert(unit < PIPE_MAX_SAMPLERS);
    softpipe->sampler[unit] = *sampler;
 
    softpipe->dirty |= G_NEW_SAMPLER;
 }
+
+
+void
+softpipe_set_texture_state(struct pipe_context *pipe,
+                           GLuint unit,
+                           struct pipe_texture_object *texture)
+{
+   struct softpipe_context *softpipe = softpipe_context(pipe);
+
+   assert(unit < PIPE_MAX_SAMPLERS);
+   softpipe->texture[unit] = texture;  /* ptr, not struct */
+
+   softpipe->dirty |= G_NEW_TEXTURE;
+}