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 7e68699d3e976f384ebef1c1386e4f6f1ac79734..d9546a24d2fec47cdbc18b2026a9f405cbed9cbf 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 75573107ff26fc62de37bd36f2388c4d9d01662d..a0c4d72a3c2ab63f9759f1f30ca0d65e3b5358c0 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 f3723eb87e5c7806517745eda78055595890a055..3e3da7cce6f3818497e24f6f4b19eb8beb67618d 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 07b529fc6e465db728b6be3c6b007666d38db495..0d00c7eb6cd97b35afa90bdd021dff8647de2c27 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 d8c0de0ad1a43cc2e76a09f0cf0d23018e239d62..7c816dbc1a77e01c605e873a725778d3a59917b4 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 faaa043a56cc33ebe8cd29fc0696b750591b3316..735d039748a1a2084eac6d105728c2b8da4c99c3 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 6b422acfb6c958463111c7d5f2e4f33fc7087bc8..060e2c8c9877579ae64c8635d6053ff62e0ae8ec 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;
+}