st/mesa: don't clamp fragment color with integer colorbuffer
[mesa.git] / src / mesa / state_tracker / st_atom_pixeltransfer.c
index 1f833d2821297a5cacf57a8d5680753bb84a6f72..8d2317ea1527921f2eab196686aa82a758849aae 100644 (file)
@@ -84,26 +84,6 @@ make_state_key(struct gl_context *ctx,  struct state_key *key)
 }
 
 
-static struct pipe_resource *
-create_color_map_texture(struct gl_context *ctx)
-{
-   struct st_context *st = st_context(ctx);
-   struct pipe_context *pipe = st->pipe;
-   struct pipe_resource *pt;
-   enum pipe_format format;
-   const uint texSize = 256; /* simple, and usually perfect */
-
-   /* find an RGBA texture format */
-   format = st_choose_format(pipe->screen, GL_RGBA, GL_NONE, GL_NONE,
-                             PIPE_TEXTURE_2D, 0, PIPE_BIND_SAMPLER_VIEW);
-
-   /* create texture for color map/table */
-   pt = st_texture_create(st, PIPE_TEXTURE_2D, format, 0,
-                          texSize, texSize, 1, 1, PIPE_BIND_SAMPLER_VIEW);
-   return pt;
-}
-
-
 /**
  * Update the pixelmap texture with the contents of the R/G/B/A pixel maps.
  */
@@ -136,11 +116,12 @@ load_color_map_texture(struct gl_context *ctx, struct pipe_resource *pt)
       for (j = 0; j < texSize; j++) {
          union util_color uc;
          int k = (i * texSize + j);
-         ubyte r = ctx->PixelMaps.RtoR.Map8[j * rSize / texSize];
-         ubyte g = ctx->PixelMaps.GtoG.Map8[i * gSize / texSize];
-         ubyte b = ctx->PixelMaps.BtoB.Map8[j * bSize / texSize];
-         ubyte a = ctx->PixelMaps.AtoA.Map8[i * aSize / texSize];
-         util_pack_color_ub(r, g, b, a, pt->format, &uc);
+         float rgba[4];
+         rgba[0] = ctx->PixelMaps.RtoR.Map[j * rSize / texSize];
+         rgba[1] = ctx->PixelMaps.GtoG.Map[i * gSize / texSize];
+         rgba[2] = ctx->PixelMaps.BtoB.Map[j * bSize / texSize];
+         rgba[3] = ctx->PixelMaps.AtoA.Map[i * aSize / texSize];
+         util_pack_color(rgba, pt->format, &uc);
          *(dest + k) = uc.ui;
       }
    }
@@ -186,7 +167,7 @@ get_pixel_transfer_program(struct gl_context *ctx, const struct state_key *key)
    inst[ic].TexSrcUnit = 0;
    inst[ic].TexSrcTarget = TEXTURE_2D_INDEX;
    ic++;
-   fp->Base.InputsRead = (1 << FRAG_ATTRIB_TEX0);
+   fp->Base.InputsRead = BITFIELD64_BIT(FRAG_ATTRIB_TEX0);
    fp->Base.OutputsWritten = BITFIELD64_BIT(FRAG_RESULT_COLOR);
    fp->Base.SamplersUsed = 0x1;  /* sampler 0 (bit 0) is used */
 
@@ -219,7 +200,7 @@ get_pixel_transfer_program(struct gl_context *ctx, const struct state_key *key)
 
       /* create the colormap/texture now if not already done */
       if (!st->pixel_xfer.pixelmap_texture) {
-         st->pixel_xfer.pixelmap_texture = create_color_map_texture(ctx);
+         st->pixel_xfer.pixelmap_texture = st_create_color_map_texture(ctx);
          st->pixel_xfer.pixelmap_sampler_view =
             st_create_texture_sampler_view(st->pipe,
                                            st->pixel_xfer.pixelmap_texture);
@@ -286,6 +267,7 @@ get_pixel_transfer_program(struct gl_context *ctx, const struct state_key *key)
    if (!fp->Base.Instructions) {
       _mesa_error(ctx, GL_OUT_OF_MEMORY,
                   "generating pixel transfer program");
+      _mesa_free_parameter_list(params);
       return NULL;
    }