mesa: change _mesa_format_to_type_and_comps() format parameter type
[mesa.git] / src / mesa / state_tracker / st_atom_pixeltransfer.c
index 76356bbad76dd1ccde565fa0589cf99f20b20956..eff3666ca88a691cbed1cd107d2f1ae6a3c5d27c 100644 (file)
 #include "st_format.h"
 #include "st_program.h"
 #include "st_texture.h"
+#include "st_inlines.h"
 
 #include "pipe/p_screen.h"
 #include "pipe/p_context.h"
-#include "pipe/p_inlines.h"
 #include "util/u_pack_color.h"
 
 
@@ -77,7 +77,7 @@ is_identity(const GLfloat m[16])
    GLuint i;
    for (i = 0; i < 16; i++) {
       const int row = i % 4, col = i / 4;
-      const float val = (row == col);
+      const float val = (GLfloat)(row == col);
       if (m[i] != val)
          return GL_FALSE;
    }
@@ -122,11 +122,11 @@ create_color_map_texture(GLcontext *ctx)
    const uint texSize = 256; /* simple, and usually perfect */
 
    /* find an RGBA texture format */
-   format = st_choose_format(pipe, GL_RGBA, PIPE_TEXTURE);
+   format = st_choose_format(pipe, GL_RGBA, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER);
 
    /* create texture for color map/table */
    pt = st_texture_create(ctx->st, PIPE_TEXTURE_2D, format, 0,
-                          texSize, texSize, 1, 0);
+                          texSize, texSize, 1, PIPE_TEXTURE_USAGE_SAMPLER);
    return pt;
 }
 
@@ -139,7 +139,7 @@ load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt)
 {
    struct pipe_context *pipe = ctx->st->pipe;
    struct pipe_screen *screen = pipe->screen;
-   struct pipe_surface *surface;
+   struct pipe_transfer *transfer;
    const GLuint rSize = ctx->PixelMaps.RtoR.Size;
    const GLuint gSize = ctx->PixelMaps.GtoG.Size;
    const GLuint bSize = ctx->PixelMaps.BtoB.Size;
@@ -148,8 +148,10 @@ load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt)
    uint *dest;
    uint i, j;
 
-   surface = screen->get_tex_surface(screen, pt, 0, 0, 0);
-   dest = (uint *) pipe_surface_map(surface);
+   transfer = st_cond_flush_get_tex_transfer(st_context(ctx),
+                                            pt, 0, 0, 0, PIPE_TRANSFER_WRITE,
+                                            0, 0, texSize, texSize);
+   dest = (uint *) screen->transfer_map(screen, transfer);
 
    /* Pack four 1D maps into a 2D texture:
     * R map is placed horizontally, indexed by S, in channel 0
@@ -168,9 +170,8 @@ load_color_map_texture(GLcontext *ctx, struct pipe_texture *pt)
       }
    }
 
-   pipe_surface_unmap(surface);
-   pipe_surface_reference(&surface, NULL);
-   pipe->texture_update(pipe, pt, 0, 0x1);
+   screen->transfer_unmap(screen, transfer);
+   screen->tex_transfer_destroy(transfer);
 }
 
 
@@ -211,7 +212,7 @@ get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key)
    inst[ic].TexSrcTarget = TEXTURE_2D_INDEX;
    ic++;
    fp->Base.InputsRead = (1 << FRAG_ATTRIB_TEX0);
-   fp->Base.OutputsWritten = (1 << FRAG_RESULT_COLR);
+   fp->Base.OutputsWritten = (1 << FRAG_RESULT_COLOR);
    fp->Base.SamplersUsed = 0x1;  /* sampler 0 (bit 0) is used */
 
    if (key->scaleAndBias) {
@@ -399,7 +400,7 @@ get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key)
    {
       struct prog_instruction *last = &inst[ic - 1];
       last->DstReg.File = PROGRAM_OUTPUT;
-      last->DstReg.Index = FRAG_RESULT_COLR;
+      last->DstReg.Index = FRAG_RESULT_COLOR;
    }
 
    /* END; */
@@ -463,10 +464,10 @@ update_pixel_transfer(struct st_context *st)
 
 
 const struct st_tracked_state st_update_pixel_transfer = {
-   .name = "st_update_pixel_transfer",
-   .dirty = {
-      .mesa = _NEW_PIXEL | _NEW_COLOR_MATRIX,
-      .st  = 0,
+   "st_update_pixel_transfer",                         /* name */
+   {                                                   /* dirty */
+      _NEW_PIXEL | _NEW_COLOR_MATRIX,                  /* mesa */
+      0,                                               /* st */
    },
-   .update = update_pixel_transfer
+   update_pixel_transfer                               /* update */
 };