st/mesa: Make st_cb_accum.h FEATURE_accum aware.
[mesa.git] / src / mesa / state_tracker / st_cb_accum.c
index 3d1d0f71d531b7d211e9c44ac0d5ba4747aa06dd..425e7987d33e410032cada99a622bac1773455ee 100644 (file)
 #include "main/image.h"
 #include "main/macros.h"
 
+#include "st_debug.h"
 #include "st_context.h"
 #include "st_cb_accum.h"
 #include "st_cb_fbo.h"
-#include "st_draw.h"
-#include "st_public.h"
-#include "st_format.h"
 #include "st_texture.h"
-#include "st_inlines.h"
 #include "pipe/p_context.h"
 #include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
 #include "util/u_tile.h"
 
 
+#if FEATURE_accum
+
 /**
  * For hardware that supports deep color buffers, we could accelerate
  * most/all the accum operations with blending/texturing.
@@ -130,20 +129,23 @@ accum_accum(struct st_context *st, GLfloat value,
             struct st_renderbuffer *color_strb)
 {
    struct pipe_context *pipe = st->pipe;
-   struct pipe_screen *screen = pipe->screen;
    struct pipe_transfer *color_trans;
    size_t stride = acc_strb->stride;
    GLubyte *data = acc_strb->data;
    GLfloat *buf;
 
-   color_trans = st_cond_flush_get_tex_transfer(st, color_strb->texture,
+   if (ST_DEBUG & DEBUG_FALLBACK)
+      debug_printf("%s: fallback processing\n", __FUNCTION__);
+
+   color_trans = pipe_get_transfer(st->pipe,
+                                               color_strb->texture,
                                                0, 0, 0,
                                                PIPE_TRANSFER_READ, xpos, ypos,
                                                width, height);
 
-   buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
+   buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
 
-   pipe_get_tile_rgba(color_trans, 0, 0, width, height, buf);
+   pipe_get_tile_rgba(pipe, color_trans, 0, 0, width, height, buf);
 
    switch (acc_strb->format) {
    case PIPE_FORMAT_R16G16B16A16_SNORM:
@@ -163,8 +165,8 @@ accum_accum(struct st_context *st, GLfloat value,
       _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
    }
 
-   _mesa_free(buf);
-   screen->tex_transfer_destroy(color_trans);
+   free(buf);
+   pipe->transfer_destroy(pipe, color_trans);
 }
 
 
@@ -175,20 +177,23 @@ accum_load(struct st_context *st, GLfloat value,
            struct st_renderbuffer *color_strb)
 {
    struct pipe_context *pipe = st->pipe;
-   struct pipe_screen *screen = pipe->screen;
    struct pipe_transfer *color_trans;
    size_t stride = acc_strb->stride;
    GLubyte *data = acc_strb->data;
    GLfloat *buf;
 
-   color_trans = st_cond_flush_get_tex_transfer(st, color_strb->texture,
+
+   if (ST_DEBUG & DEBUG_FALLBACK)
+      debug_printf("%s: fallback processing\n", __FUNCTION__);
+
+   color_trans = pipe_get_transfer(st->pipe, color_strb->texture,
                                                0, 0, 0,
                                                PIPE_TRANSFER_READ, xpos, ypos,
                                                width, height);
 
-   buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
+   buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
 
-   pipe_get_tile_rgba(color_trans, 0, 0, width, height, buf);
+   pipe_get_tile_rgba(pipe, color_trans, 0, 0, width, height, buf);
 
    switch (acc_strb->format) {
    case PIPE_FORMAT_R16G16B16A16_SNORM:
@@ -208,8 +213,8 @@ accum_load(struct st_context *st, GLfloat value,
       _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
    }
 
-   _mesa_free(buf);
-   screen->tex_transfer_destroy(color_trans);
+   free(buf);
+   pipe->transfer_destroy(pipe, color_trans);
 }
 
 
@@ -219,30 +224,32 @@ accum_return(GLcontext *ctx, GLfloat value,
              struct st_renderbuffer *acc_strb,
              struct st_renderbuffer *color_strb)
 {
-   struct pipe_context *pipe = ctx->st->pipe;
-   struct pipe_screen *screen = pipe->screen;
-   const GLubyte *colormask = ctx->Color.ColorMask;
+   struct pipe_context *pipe = st_context(ctx)->pipe;
+   const GLubyte *colormask = ctx->Color.ColorMask[0];
    enum pipe_transfer_usage usage;
    struct pipe_transfer *color_trans;
    size_t stride = acc_strb->stride;
    const GLubyte *data = acc_strb->data;
    GLfloat *buf;
 
-   buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat));
+   if (ST_DEBUG & DEBUG_FALLBACK)
+      debug_printf("%s: fallback processing\n", __FUNCTION__);
+
+   buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
 
    if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3])
       usage = PIPE_TRANSFER_READ_WRITE;
    else
       usage = PIPE_TRANSFER_WRITE;
    
-   color_trans = st_cond_flush_get_tex_transfer(st_context(ctx),
+   color_trans = pipe_get_transfer(st_context(ctx)->pipe,
                                                color_strb->texture, 0, 0, 0,
                                                usage,
                                                xpos, ypos,
                                                width, height);
 
    if (usage & PIPE_TRANSFER_READ)
-      pipe_get_tile_rgba(color_trans, 0, 0, width, height, buf);
+      pipe_get_tile_rgba(pipe, color_trans, 0, 0, width, height, buf);
 
    switch (acc_strb->format) {
    case PIPE_FORMAT_R16G16B16A16_SNORM:
@@ -271,17 +278,17 @@ accum_return(GLcontext *ctx, GLfloat value,
       _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
    }
 
-   pipe_put_tile_rgba(color_trans, 0, 0, width, height, buf);
+   pipe_put_tile_rgba(pipe, color_trans, 0, 0, width, height, buf);
 
-   _mesa_free(buf);
-   screen->tex_transfer_destroy(color_trans);
+   free(buf);
+   pipe->transfer_destroy(pipe, color_trans);
 }
 
 
 static void
 st_Accum(GLcontext *ctx, GLenum op, GLfloat value)
 {
-   struct st_context *st = ctx->st;
+   struct st_context *st = st_context(ctx);
    struct st_renderbuffer *acc_strb
      = st_renderbuffer(ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer);
    struct st_renderbuffer *color_strb
@@ -295,9 +302,6 @@ st_Accum(GLcontext *ctx, GLenum op, GLfloat value)
    if(!acc_strb->data)
       return;
    
-   /* make sure color bufs aren't cached */
-   st_flush( st, PIPE_FLUSH_RENDER_CACHE, NULL );
-
    switch (op) {
    case GL_ADD:
       if (value != 0.0F) {
@@ -331,3 +335,5 @@ void st_init_accum_functions(struct dd_function_table *functions)
 {
    functions->Accum = st_Accum;
 }
+
+#endif /* FEATURE_accum */