diff options
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/acc2.c | 319 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_framebuffer.c | 28 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_bitmap.c | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_blit.c | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_clear.c | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_strings.c | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_texture.c | 4 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_framebuffer.c | 15 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_gen_mipmap.c | 6 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_public.h | 5 |
10 files changed, 38 insertions, 347 deletions
diff --git a/src/mesa/state_tracker/acc2.c b/src/mesa/state_tracker/acc2.c deleted file mode 100644 index fa5de2b764c..00000000000 --- a/src/mesa/state_tracker/acc2.c +++ /dev/null @@ -1,319 +0,0 @@ -/************************************************************************** - * - * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sub license, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial portions - * of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR - * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - **************************************************************************/ - - /* - * Authors: - * Brian Paul - */ - -#include "main/imports.h" -#include "main/image.h" -#include "main/macros.h" - -#include "st_context.h" -#include "st_cb_accum.h" -#include "st_cb_fbo.h" -#include "st_draw.h" -#include "st_format.h" -#include "pipe/p_context.h" -#include "pipe/p_defines.h" -#include "pipe/p_inlines.h" -#include "util/p_tile.h" - - -#define UNCLAMPED_FLOAT_TO_SHORT(us, f) \ - us = ( (short) ( CLAMP((f), -1.0, 1.0) * 32767.0F) ) - - -/** - * For hardware that supports deep color buffers, we could accelerate - * most/all the accum operations with blending/texturing. - * For now, just use the get/put_tile() functions and do things in software. - */ - - -static void -acc_get_tile_rgba(struct pipe_context *pipe, struct pipe_surface *acc_ps, - uint x, uint y, uint w, uint h, float *p) -{ - const enum pipe_format f = acc_ps->format; - const int cpp = acc_ps->cpp; - - acc_ps->format = PIPE_FORMAT_R16G16B16A16_SNORM; - acc_ps->cpp = 8; - - pipe_get_tile_rgba(pipe, acc_ps, x, y, w, h, p); - - acc_ps->format = f; - acc_ps->cpp = cpp; -} - - -static void -acc_put_tile_rgba(struct pipe_context *pipe, struct pipe_surface *acc_ps, - uint x, uint y, uint w, uint h, const float *p) -{ - enum pipe_format f = acc_ps->format; - const int cpp = acc_ps->cpp; - - acc_ps->format = PIPE_FORMAT_R16G16B16A16_SNORM; - acc_ps->cpp = 8; - - pipe_put_tile_rgba(pipe, acc_ps, x, y, w, h, p); - - acc_ps->format = f; - acc_ps->cpp = cpp; -} - - - -void -st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) -{ - struct pipe_context *pipe = ctx->st->pipe; - struct st_renderbuffer *acc_strb = st_renderbuffer(rb); - struct pipe_surface *acc_ps = acc_strb->surface; - const GLint xpos = ctx->DrawBuffer->_Xmin; - const GLint ypos = ctx->DrawBuffer->_Ymin; - const GLint width = ctx->DrawBuffer->_Xmax - xpos; - const GLint height = ctx->DrawBuffer->_Ymax - ypos; - const GLfloat r = ctx->Accum.ClearColor[0]; - const GLfloat g = ctx->Accum.ClearColor[1]; - const GLfloat b = ctx->Accum.ClearColor[2]; - const GLfloat a = ctx->Accum.ClearColor[3]; - GLfloat *accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - int i; - -#if 1 - GLvoid *map; - - map = pipe_surface_map(acc_ps); - switch (acc_strb->format) { - case PIPE_FORMAT_R16G16B16A16_SNORM: - { - GLshort r = FLOAT_TO_SHORT(ctx->Accum.ClearColor[0]); - GLshort g = FLOAT_TO_SHORT(ctx->Accum.ClearColor[1]); - GLshort b = FLOAT_TO_SHORT(ctx->Accum.ClearColor[2]); - GLshort a = FLOAT_TO_SHORT(ctx->Accum.ClearColor[3]); - int i, j; - for (i = 0; i < height; i++) { - GLshort *dst = ((GLshort *) map - + ((ypos + i) * acc_ps->pitch + xpos) * 4); - for (j = 0; j < width; j++) { - dst[0] = r; - dst[1] = g; - dst[2] = b; - dst[3] = a; - dst += 4; - } - } - } - break; - default: - _mesa_problem(ctx, "unexpected format in st_clear_accum_buffer()"); - } - - pipe_surface_unmap(acc_ps); - -#else - for (i = 0; i < width * height; i++) { - accBuf[i*4+0] = r; - accBuf[i*4+1] = g; - accBuf[i*4+2] = b; - accBuf[i*4+3] = a; - } - - acc_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); -#endif -} - - -/** For ADD/MULT */ -static void -accum_mad(struct pipe_context *pipe, GLfloat scale, GLfloat bias, - GLint xpos, GLint ypos, GLint width, GLint height, - struct pipe_surface *acc_ps) -{ - GLfloat *accBuf; - GLint i; - - accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - - pipe_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); - - for (i = 0; i < 4 * width * height; i++) { - accBuf[i] = accBuf[i] * scale + bias; - } - - pipe_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); - - free(accBuf); -} - - -static void -accum_accum(struct pipe_context *pipe, GLfloat value, - GLint xpos, GLint ypos, GLint width, GLint height, - struct pipe_surface *acc_ps, - struct pipe_surface *color_ps) -{ - GLfloat *colorBuf, *accBuf; - GLint i; - - colorBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - - pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, colorBuf); - acc_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); - - for (i = 0; i < 4 * width * height; i++) { - accBuf[i] = accBuf[i] + colorBuf[i] * value; - } - - acc_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf); - - free(colorBuf); - free(accBuf); -} - - -static void -accum_load(struct pipe_context *pipe, GLfloat value, - GLint xpos, GLint ypos, GLint width, GLint height, - struct pipe_surface *acc_ps, - struct pipe_surface *color_ps) -{ - GLfloat *buf; - GLint i; - - buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - - pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, buf); - - for (i = 0; i < 4 * width * height; i++) { - buf[i] = buf[i] * value; - } - - acc_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, buf); - - free(buf); -} - - -static void -accum_return(GLcontext *ctx, GLfloat value, - GLint xpos, GLint ypos, GLint width, GLint height, - struct pipe_surface *acc_ps, - struct pipe_surface *color_ps) -{ - struct pipe_context *pipe = ctx->st->pipe; - const GLubyte *colormask = ctx->Color.ColorMask; - GLfloat *abuf, *cbuf = NULL; - GLint i, ch; - - abuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - - acc_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, abuf); - - if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3]) { - cbuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); - pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, cbuf); - } - - for (i = 0; i < width * height; i++) { - for (ch = 0; ch < 4; ch++) { - if (colormask[ch]) { - GLfloat val = abuf[i * 4 + ch] * value; - abuf[i * 4 + ch] = CLAMP(val, 0.0, 1.0); - } - else { - abuf[i * 4 + ch] = cbuf[i * 4 + ch]; - } - } - } - - pipe_put_tile_rgba(pipe, color_ps, xpos, ypos, width, height, abuf); - - free(abuf); - if (cbuf) - free(cbuf); -} - - -static void -st_Accum(GLcontext *ctx, GLenum op, GLfloat value) -{ - struct st_context *st = ctx->st; - struct pipe_context *pipe = st->pipe; - struct st_renderbuffer *acc_strb - = st_renderbuffer(ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer); - struct st_renderbuffer *color_strb - = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer); - struct pipe_surface *acc_ps = acc_strb->surface; - struct pipe_surface *color_ps = color_strb->surface; - - const GLint xpos = ctx->DrawBuffer->_Xmin; - const GLint ypos = ctx->DrawBuffer->_Ymin; - const GLint width = ctx->DrawBuffer->_Xmax - xpos; - const GLint height = ctx->DrawBuffer->_Ymax - ypos; - - /* make sure color bufs aren't cached */ - pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL); - - switch (op) { - case GL_ADD: - if (value != 0.0F) { - accum_mad(pipe, 1.0, value, xpos, ypos, width, height, acc_ps); - } - break; - case GL_MULT: - if (value != 1.0F) { - accum_mad(pipe, value, 0.0, xpos, ypos, width, height, acc_ps); - } - break; - case GL_ACCUM: - if (value != 0.0F) { - accum_accum(pipe, value, xpos, ypos, width, height, acc_ps, color_ps); - } - break; - case GL_LOAD: - accum_load(pipe, value, xpos, ypos, width, height, acc_ps, color_ps); - break; - case GL_RETURN: - accum_return(ctx, value, xpos, ypos, width, height, acc_ps, color_ps); - break; - default: - assert(0); - } -} - - - -void st_init_accum_functions(struct dd_function_table *functions) -{ - functions->Accum = st_Accum; -} diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 2916886610d..ca1a719a9ac 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -95,7 +95,7 @@ update_framebuffer_state( struct st_context *st ) struct pipe_framebuffer_state *framebuffer = &st->state.framebuffer; struct gl_framebuffer *fb = st->ctx->DrawBuffer; struct st_renderbuffer *strb; - GLuint i, j; + GLuint i; memset(framebuffer, 0, sizeof(*framebuffer)); @@ -108,20 +108,18 @@ update_framebuffer_state( struct st_context *st ) * to determine which surfaces to draw to */ framebuffer->num_cbufs = 0; - for (j = 0; j < MAX_DRAW_BUFFERS; j++) { - for (i = 0; i < fb->_NumColorDrawBuffers[j]; i++) { - strb = st_renderbuffer(fb->_ColorDrawBuffers[j][i]); - - /*printf("--------- framebuffer surface rtt %p\n", strb->rtt);*/ - if (strb->rtt) { - /* rendering to a GL texture, may have to update surface */ - update_renderbuffer_surface(st, strb); - } + for (i = 0; i < fb->_NumColorDrawBuffers; i++) { + strb = st_renderbuffer(fb->_ColorDrawBuffers[i]); - if (strb->surface) { - framebuffer->cbufs[framebuffer->num_cbufs] = strb->surface; - framebuffer->num_cbufs++; - } + /*printf("--------- framebuffer surface rtt %p\n", strb->rtt);*/ + if (strb->rtt) { + /* rendering to a GL texture, may have to update surface */ + update_renderbuffer_surface(st, strb); + } + + if (strb->surface) { + framebuffer->cbufs[framebuffer->num_cbufs] = strb->surface; + framebuffer->num_cbufs++; } } @@ -146,7 +144,7 @@ update_framebuffer_state( struct st_context *st ) cso_set_framebuffer(st->cso_context, framebuffer); - if (fb->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT) { + if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) { if (st->frontbuffer_status == FRONT_STATUS_COPY_OF_BACK) { /* XXX copy back buf to front? */ } diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 694104f9cfb..3d508227e12 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -779,7 +779,7 @@ st_destroy_bitmap(struct st_context *st) } if (st->bitmap.vbuf) { - pipe_buffer_destroy(pipe->screen, st->bitmap.vbuf); + pipe_buffer_reference(pipe->screen, &st->bitmap.vbuf, NULL); st->bitmap.vbuf = NULL; } diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c index 327bafeb986..28526234720 100644 --- a/src/mesa/state_tracker/st_cb_blit.c +++ b/src/mesa/state_tracker/st_cb_blit.c @@ -79,7 +79,7 @@ st_BlitFramebuffer(GLcontext *ctx, struct st_renderbuffer *srcRb = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer); struct st_renderbuffer *dstRb = - st_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]); + st_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]); struct pipe_surface *srcSurf = srcRb->surface; struct pipe_surface *dstSurf = dstRb->surface; diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index bc3055c3fdf..1412a3761f1 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -116,7 +116,7 @@ st_destroy_clear(struct st_context *st) st->clear.vs = NULL; } if (st->clear.vbuf) { - pipe_buffer_destroy(pipe->screen, st->clear.vbuf); + pipe_buffer_reference(pipe->screen, &st->clear.vbuf, NULL); st->clear.vbuf = NULL; } } diff --git a/src/mesa/state_tracker/st_cb_strings.c b/src/mesa/state_tracker/st_cb_strings.c index 066124f8f30..09545aa8fb8 100644 --- a/src/mesa/state_tracker/st_cb_strings.c +++ b/src/mesa/state_tracker/st_cb_strings.c @@ -40,7 +40,7 @@ #include "st_context.h" #include "st_cb_strings.h" -#define ST_VERSION_STRING "0.1" +#define ST_VERSION_STRING "0.2" static const GLubyte * st_get_string(GLcontext * ctx, GLenum name) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 0b2b639a5bd..d08229b57a3 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -749,8 +749,8 @@ st_GetTexImage(GLcontext * ctx, GLenum target, GLint level, static void st_GetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level, GLvoid *pixels, - const struct gl_texture_object *texObj, - const struct gl_texture_image *texImage) + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) { st_get_tex_image(ctx, target, level, 0, 0, pixels, (struct gl_texture_object *) texObj, diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c index 6ee1777fb7a..6fd731d209d 100644 --- a/src/mesa/state_tracker/st_framebuffer.c +++ b/src/mesa/state_tracker/st_framebuffer.c @@ -153,9 +153,9 @@ void st_resize_framebuffer( struct st_framebuffer *stfb, } -void st_unreference_framebuffer( struct st_framebuffer **stfb ) +void st_unreference_framebuffer( struct st_framebuffer *stfb ) { - _mesa_unreference_framebuffer((struct gl_framebuffer **) stfb); + _mesa_unreference_framebuffer((struct gl_framebuffer **) &stfb); } @@ -176,7 +176,9 @@ st_set_framebuffer_surface(struct st_framebuffer *stfb, assert(surfIndex < BUFFER_COUNT); strb = st_renderbuffer(stfb->Base.Attachment[surfIndex].Renderbuffer); - assert(strb); + + /* fail */ + if (!strb) return; /* replace the renderbuffer's surface/texture pointers */ pipe_surface_reference( &strb->surface, surf ); @@ -302,3 +304,10 @@ void *st_framebuffer_private( struct st_framebuffer *stfb ) return stfb->Private; } +void st_get_framebuffer_dimensions( struct st_framebuffer *stfb, + uint *width, + uint *height) +{ + *width = stfb->Base.Width; + *height = stfb->Base.Height; +} diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index b9d114b1c97..a15faf732ca 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -138,11 +138,11 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target, _mesa_generate_mipmap_level(target, datatype, comps, 0 /*border*/, pt->width[srcLevel], pt->height[srcLevel], pt->depth[srcLevel], - srcSurf->stride, /* stride in bytes */ srcData, + srcSurf->stride, /* stride in bytes */ pt->width[dstLevel], pt->height[dstLevel], pt->depth[dstLevel], - dstSurf->stride, /* stride in bytes */ - dstData); + dstData, + dstSurf->stride); /* stride in bytes */ pipe_buffer_unmap(pipe->screen, srcSurf->buffer); pipe_buffer_unmap(pipe->screen, dstSurf->buffer); diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h index 5cfb2e41f24..6ef30f44032 100644 --- a/src/mesa/state_tracker/st_public.h +++ b/src/mesa/state_tracker/st_public.h @@ -75,6 +75,9 @@ void st_resize_framebuffer( struct st_framebuffer *stfb, void st_set_framebuffer_surface(struct st_framebuffer *stfb, uint surfIndex, struct pipe_surface *surf); +void st_get_framebuffer_dimensions( struct st_framebuffer *stfb, + uint *width, uint *height); + struct pipe_surface *st_get_framebuffer_surface(struct st_framebuffer *stfb, uint surfIndex); @@ -83,7 +86,7 @@ struct pipe_texture *st_get_framebuffer_texture(struct st_framebuffer *stfb, void *st_framebuffer_private( struct st_framebuffer *stfb ); -void st_unreference_framebuffer( struct st_framebuffer **stfb ); +void st_unreference_framebuffer( struct st_framebuffer *stfb ); void st_make_current(struct st_context *st, struct st_framebuffer *draw, |