diff options
author | Michal Krol <[email protected]> | 2010-03-10 15:49:30 +0100 |
---|---|---|
committer | Michal Krol <[email protected]> | 2010-03-10 15:49:30 +0100 |
commit | 3ce4375912c8ea488460e593e07c5bb15b92dca9 (patch) | |
tree | 1011fa439bd829fd46a44fd99478135848800e73 /src/mesa/state_tracker | |
parent | f59f28093ea827bd234d8e1a36bdd56a9fce5f09 (diff) | |
parent | 9b348d0ed125a22be3f318ac60cef6f201edfdab (diff) |
Merge branch 'master' into gallium-sampler-view
Conflicts:
src/gallium/auxiliary/Makefile
src/gallium/auxiliary/SConscript
src/gallium/auxiliary/tgsi/tgsi_exec.c
src/gallium/auxiliary/util/u_blitter.c
src/gallium/drivers/i915/i915_context.h
src/gallium/drivers/i965/brw_context.h
src/gallium/drivers/llvmpipe/lp_context.h
src/gallium/drivers/nv50/nv50_context.h
src/gallium/drivers/nv50/nv50_state_validate.c
src/gallium/drivers/nv50/nv50_tex.c
src/gallium/drivers/r300/r300_blit.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/softpipe/sp_context.h
src/gallium/drivers/svga/svga_context.h
src/gallium/drivers/svga/svga_pipe_sampler.c
Diffstat (limited to 'src/mesa/state_tracker')
25 files changed, 319 insertions, 429 deletions
diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 6a7ebff6cad..7806df4a531 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -143,7 +143,7 @@ void st_validate_state( struct st_context *st ) if (state->st == 0) return; - /*_mesa_printf("%s %x/%x\n", __FUNCTION__, state->mesa, state->st);*/ + /*printf("%s %x/%x\n", __FUNCTION__, state->mesa, state->st);*/ if (1) { /* Debug version which enforces various sanity checks on the @@ -158,17 +158,17 @@ void st_validate_state( struct st_context *st ) const struct st_tracked_state *atom = atoms[i]; struct st_state_flags generated; - /*_mesa_printf("atom %s %x/%x\n", atom->name, atom->dirty.mesa, atom->dirty.st);*/ + /*printf("atom %s %x/%x\n", atom->name, atom->dirty.mesa, atom->dirty.st);*/ if (!(atom->dirty.mesa || atom->dirty.st) || !atom->update) { - _mesa_printf("malformed atom %s\n", atom->name); + printf("malformed atom %s\n", atom->name); assert(0); } if (check_state(state, &atom->dirty)) { atoms[i]->update( st ); - /*_mesa_printf("after: %x\n", atom->dirty.mesa);*/ + /*printf("after: %x\n", atom->dirty.mesa);*/ } accumulate_state(&examined, &atom->dirty); @@ -181,7 +181,7 @@ void st_validate_state( struct st_context *st ) assert(!check_state(&examined, &generated)); prev = *state; } - /*_mesa_printf("\n");*/ + /*printf("\n");*/ } else { diff --git a/src/mesa/state_tracker/st_atom_clip.c b/src/mesa/state_tracker/st_atom_clip.c index 23d709b814c..80c0e921398 100644 --- a/src/mesa/state_tracker/st_atom_clip.c +++ b/src/mesa/state_tracker/st_atom_clip.c @@ -35,6 +35,8 @@ #include "pipe/p_context.h" #include "st_atom.h" +#include "cso_cache/cso_context.h" + /* Second state atom for user clip planes: */ @@ -56,7 +58,7 @@ static void update_clip( struct st_context *st ) if (memcmp(&clip, &st->state.clip, sizeof(clip)) != 0) { st->state.clip = clip; - st->pipe->set_clip_state(st->pipe, &clip); + cso_set_clip(st->cso_context, &clip); } } diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c index 1be72e729e4..33e43ddcc4c 100644 --- a/src/mesa/state_tracker/st_cb_accum.c +++ b/src/mesa/state_tracker/st_cb_accum.c @@ -143,7 +143,7 @@ accum_accum(struct st_context *st, GLfloat value, 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); @@ -165,7 +165,7 @@ accum_accum(struct st_context *st, GLfloat value, _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()"); } - _mesa_free(buf); + free(buf); screen->tex_transfer_destroy(color_trans); } @@ -192,7 +192,7 @@ accum_load(struct st_context *st, GLfloat value, 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); @@ -214,7 +214,7 @@ accum_load(struct st_context *st, GLfloat value, _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()"); } - _mesa_free(buf); + free(buf); screen->tex_transfer_destroy(color_trans); } @@ -237,7 +237,7 @@ accum_return(GLcontext *ctx, GLfloat value, if (ST_DEBUG & DEBUG_FALLBACK) debug_printf("%s: fallback processing\n", __FUNCTION__); - buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); + buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3]) usage = PIPE_TRANSFER_READ_WRITE; @@ -282,7 +282,7 @@ accum_return(GLcontext *ctx, GLfloat value, pipe_put_tile_rgba(color_trans, 0, 0, width, height, buf); - _mesa_free(buf); + free(buf); screen->tex_transfer_destroy(color_trans); } diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 25430bba77d..f326601c3be 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -440,6 +440,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, cso_save_viewport(cso); cso_save_fragment_shader(cso); cso_save_vertex_shader(cso); + cso_save_vertex_elements(cso); /* rasterizer state: just scissor */ st->bitmap.rasterizer.scissor = ctx->Scissor.Enabled; @@ -481,15 +482,20 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, struct pipe_viewport_state vp; vp.scale[0] = 0.5f * width; vp.scale[1] = height * (invert ? -0.5f : 0.5f); - vp.scale[2] = 1.0f; + vp.scale[2] = 0.5f; vp.scale[3] = 1.0f; vp.translate[0] = 0.5f * width; vp.translate[1] = 0.5f * height; - vp.translate[2] = 0.0f; + vp.translate[2] = 0.5f; vp.translate[3] = 0.0f; cso_set_viewport(cso, &vp); } + cso_set_vertex_elements(cso, 3, st->velems_util_draw); + + /* convert Z from [0,1] to [-1,-1] to match viewport Z scale/bias */ + z = z * 2.0 - 1.0; + /* draw textured quad */ offset = setup_bitmap_vertex_data(st, x, y, width, height, z, color); @@ -506,6 +512,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, cso_restore_viewport(cso); cso_restore_fragment_shader(cso); cso_restore_vertex_shader(cso); + cso_restore_vertex_elements(cso); } @@ -536,9 +543,29 @@ reset_cache(struct st_context *st) st->bitmap.tex_format, 0, BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT, 1, PIPE_TEXTURE_USAGE_SAMPLER); +} + +/** Print bitmap image to stdout (debug) */ +static void +print_cache(const struct bitmap_cache *cache) +{ + int i, j, k; + + for (i = 0; i < BITMAP_CACHE_HEIGHT; i++) { + k = BITMAP_CACHE_WIDTH * (BITMAP_CACHE_HEIGHT - i - 1); + for (j = 0; j < BITMAP_CACHE_WIDTH; j++) { + if (cache->buffer[k]) + printf("X"); + else + printf(" "); + k++; + } + printf("\n"); + } } + static void create_cache_trans(struct st_context *st) { @@ -588,6 +615,8 @@ st_flush_bitmap_cache(struct st_context *st) * So unmap and release the texture transfer before drawing. */ if (cache->trans) { + if (0) + print_cache(cache); screen->transfer_unmap(screen, cache->trans); cache->buffer = NULL; @@ -815,7 +844,7 @@ st_destroy_bitmap(struct st_context *st) screen->tex_transfer_destroy(cache->trans); } pipe_texture_reference(&st->bitmap.cache->texture, NULL); - _mesa_free(st->bitmap.cache); + free(st->bitmap.cache); st->bitmap.cache = NULL; } } diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c index f1b4f11c050..b55a085cc7c 100644 --- a/src/mesa/state_tracker/st_cb_bufferobjects.c +++ b/src/mesa/state_tracker/st_cb_bufferobjects.c @@ -80,7 +80,7 @@ st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj) if (st_obj->buffer) pipe_buffer_reference(&st_obj->buffer, NULL); - _mesa_free(st_obj); + free(st_obj); } @@ -377,7 +377,7 @@ st_copy_buffer_subdata(GLcontext *ctx, PIPE_BUFFER_USAGE_CPU_WRITE); if (srcPtr && dstPtr) - _mesa_memcpy(dstPtr + writeOffset, srcPtr + readOffset, size); + memcpy(dstPtr + writeOffset, srcPtr + readOffset, size); pipe_buffer_unmap(pipe->screen, srcObj->buffer); pipe_buffer_unmap(pipe->screen, dstObj->buffer); diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 898c32293d1..de86062fc40 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -62,11 +62,9 @@ st_init_clear(struct st_context *st) { struct pipe_context *pipe = st->pipe; - memset(&st->clear.raster, 0, sizeof(st->clear.raster)); - st->clear.raster.gl_rasterization_rules = 1; + memset(&st->clear, 0, sizeof(st->clear)); - /* rasterizer state: bypass vertex shader, clipping and viewport */ - st->clear.raster.bypass_vs_clip_and_viewport = 1; + st->clear.raster.gl_rasterization_rules = 1; /* fragment shader state: color pass-through program */ st->clear.fs = @@ -104,9 +102,7 @@ st_destroy_clear(struct st_context *st) /** * Draw a screen-aligned quadrilateral. - * Coords are window coords with y=0=bottom. These will be passed - * through unmodified to the rasterizer as we have set - * rasterizer->bypass_vs_clip_and_viewport. + * Coords are clip coords with y=0=bottom. */ static void draw_quad(GLcontext *ctx, @@ -192,18 +188,13 @@ clear_with_quad(GLcontext *ctx, GLboolean color, GLboolean depth, GLboolean stencil) { struct st_context *st = ctx->st; - const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin; - const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax; - GLfloat y0, y1; - - if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) { - y0 = (GLfloat) (ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymax); - y1 = (GLfloat) (ctx->DrawBuffer->Height - ctx->DrawBuffer->_Ymin); - } - else { - y0 = (GLfloat) ctx->DrawBuffer->_Ymin; - y1 = (GLfloat) ctx->DrawBuffer->_Ymax; - } + const struct gl_framebuffer *fb = ctx->DrawBuffer; + const GLfloat fb_width = (GLfloat) fb->Width; + const GLfloat fb_height = (GLfloat) fb->Height; + const GLfloat x0 = (GLfloat) ctx->DrawBuffer->_Xmin / fb_width * 2.0f - 1.0f; + const GLfloat x1 = (GLfloat) ctx->DrawBuffer->_Xmax / fb_width * 2.0f - 1.0f; + const GLfloat y0 = (GLfloat) ctx->DrawBuffer->_Ymin / fb_height * 2.0f - 1.0f; + const GLfloat y1 = (GLfloat) ctx->DrawBuffer->_Ymax / fb_height * 2.0f - 1.0f; /* printf("%s %s%s%s %f,%f %f,%f\n", __FUNCTION__, @@ -218,8 +209,11 @@ clear_with_quad(GLcontext *ctx, cso_save_stencil_ref(st->cso_context); cso_save_depth_stencil_alpha(st->cso_context); cso_save_rasterizer(st->cso_context); + cso_save_viewport(st->cso_context); + cso_save_clip(st->cso_context); cso_save_fragment_shader(st->cso_context); cso_save_vertex_shader(st->cso_context); + cso_save_vertex_elements(st->cso_context); /* blend state: RGBA masking */ { @@ -271,8 +265,26 @@ clear_with_quad(GLcontext *ctx, cso_set_depth_stencil_alpha(st->cso_context, &depth_stencil); } + cso_set_vertex_elements(st->cso_context, 2, st->velems_util_draw); + cso_set_rasterizer(st->cso_context, &st->clear.raster); + /* viewport state: viewport matching window dims */ + { + const GLboolean invert = (st_fb_orientation(fb) == Y_0_TOP); + struct pipe_viewport_state vp; + vp.scale[0] = 0.5f * fb_width; + vp.scale[1] = fb_height * (invert ? -0.5f : 0.5f); + vp.scale[2] = 1.0f; + vp.scale[3] = 1.0f; + vp.translate[0] = 0.5f * fb_width; + vp.translate[1] = 0.5f * fb_height; + vp.translate[2] = 0.0f; + vp.translate[3] = 0.0f; + cso_set_viewport(st->cso_context, &vp); + } + + cso_set_clip(st->cso_context, &st->clear.clip); cso_set_fragment_shader_handle(st->cso_context, st->clear.fs); cso_set_vertex_shader_handle(st->cso_context, st->clear.vs); @@ -284,8 +296,11 @@ clear_with_quad(GLcontext *ctx, cso_restore_stencil_ref(st->cso_context); cso_restore_depth_stencil_alpha(st->cso_context); cso_restore_rasterizer(st->cso_context); + cso_restore_viewport(st->cso_context); + cso_restore_clip(st->cso_context); cso_restore_fragment_shader(st->cso_context); cso_restore_vertex_shader(st->cso_context); + cso_restore_vertex_elements(st->cso_context); } diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c index 4c02e01e5b1..d542c996d07 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -319,7 +319,7 @@ make_texture(struct st_context *st, pipeFormat = st_mesa_format_to_pipe_format(mformat); assert(pipeFormat); - cpp = st_sizeof_format(pipeFormat); + cpp = util_format_get_blocksize(pipeFormat); pixels = _mesa_map_pbo_source(ctx, unpack, pixels); if (!pixels) @@ -529,6 +529,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, cso_save_sampler_textures(cso); cso_save_fragment_shader(cso); cso_save_vertex_shader(cso); + cso_save_vertex_elements(cso); /* rasterizer state: just scissor */ { @@ -572,15 +573,17 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, struct pipe_viewport_state vp; vp.scale[0] = 0.5f * w; vp.scale[1] = -0.5f * h; - vp.scale[2] = 1.0f; + vp.scale[2] = 0.5f; vp.scale[3] = 1.0f; vp.translate[0] = 0.5f * w; vp.translate[1] = 0.5f * h; - vp.translate[2] = 0.0f; + vp.translate[2] = 0.5f; vp.translate[3] = 0.0f; cso_set_viewport(cso, &vp); } + cso_set_vertex_elements(cso, 3, st->velems_util_draw); + /* texture state: */ if (st->pixel_xfer.pixelmap_enabled) { struct pipe_texture *textures[2]; @@ -601,6 +604,9 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, y0 = (GLfloat) y; y1 = y + height * ctx->Pixel.ZoomY; + /* convert Z from [0,1] to [-1,-1] to match viewport Z scale/bias */ + z = z * 2.0 - 1.0; + draw_quad(ctx, x0, y0, z, x1, y1, color, invertTex, (GLfloat) width / pt->width0, (GLfloat) height / pt->height0); @@ -612,6 +618,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, cso_restore_sampler_textures(cso); cso_restore_fragment_shader(cso); cso_restore_vertex_shader(cso); + cso_restore_vertex_elements(cso); } @@ -710,7 +717,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, memcpy(dest, sValues, spanWidth); } break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: if (format == GL_DEPTH_STENCIL) { uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4); GLint k; @@ -728,7 +735,7 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y, } } break; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: if (format == GL_DEPTH_STENCIL) { uint *dest = (uint *) (stmap + spanY * pt->stride + spanX*4); GLint k; @@ -828,7 +835,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, ubyte *buffer; int i; - buffer = _mesa_malloc(width * height * sizeof(ubyte)); + buffer = malloc(width * height * sizeof(ubyte)); if (!buffer) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCopyPixels(stencil)"); return; @@ -876,7 +883,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, src = buffer + i * width; switch (ptDraw->texture->format) { - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: { uint *dst4 = (uint *) dst; int j; @@ -887,7 +894,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, } } break; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: { uint *dst4 = (uint *) dst; int j; @@ -907,7 +914,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, } } - _mesa_free(buffer); + free(buffer); /* unmap the stencil buffer */ screen->transfer_unmap(screen, ptDraw); @@ -1089,19 +1096,19 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy, if (type == GL_COLOR) { /* alternate path using get/put_tile() */ - GLfloat *buf = (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); + GLfloat *buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); pipe_get_tile_rgba(ptRead, 0, 0, width, height, buf); pipe_put_tile_rgba(ptTex, 0, 0, width, height, buf); - _mesa_free(buf); + free(buf); } else { /* GL_DEPTH */ - GLuint *buf = (GLuint *) _mesa_malloc(width * height * sizeof(GLuint)); + GLuint *buf = (GLuint *) malloc(width * height * sizeof(GLuint)); pipe_get_tile_z(ptRead, 0, 0, width, height, buf); pipe_put_tile_z(ptTex, 0, 0, width, height, buf); - _mesa_free(buf); + free(buf); } screen->tex_transfer_destroy(ptRead); diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c index 4638879fc2b..00e9d1dccbd 100644 --- a/src/mesa/state_tracker/st_cb_fbo.c +++ b/src/mesa/state_tracker/st_cb_fbo.c @@ -55,25 +55,6 @@ /** - * Compute the renderbuffer's Red/Green/EtcBit fields from the pipe format. - */ -static int -init_renderbuffer_bits(struct st_renderbuffer *strb, - enum pipe_format pipeFormat) -{ - struct pipe_format_info info; - - if (!st_get_format_info( pipeFormat, &info )) { - assert( 0 ); - } - - strb->Base.Format = info.mesa_format; - strb->Base.DataType = st_format_datatype(pipeFormat); - - return info.size; -} - -/** * gl_renderbuffer::AllocStorage() * This is called to allocate the original drawing surface, and * during window resize. @@ -83,33 +64,34 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height) { - struct pipe_context *pipe = ctx->st->pipe; + struct pipe_screen *screen = ctx->st->pipe->screen; struct st_renderbuffer *strb = st_renderbuffer(rb); enum pipe_format format; if (strb->format != PIPE_FORMAT_NONE) format = strb->format; else - format = st_choose_renderbuffer_format(pipe->screen, internalFormat); + format = st_choose_renderbuffer_format(screen, internalFormat); /* init renderbuffer fields */ strb->Base.Width = width; strb->Base.Height = height; - init_renderbuffer_bits(strb, format); + strb->Base.Format = st_pipe_format_to_mesa_format(format); + strb->Base.DataType = st_format_datatype(format); strb->defined = GL_FALSE; /* undefined contents now */ - if(strb->software) { + if (strb->software) { size_t size; - _mesa_free(strb->data); + free(strb->data); assert(strb->format != PIPE_FORMAT_NONE); strb->stride = util_format_get_stride(strb->format, width); size = util_format_get_2d_size(strb->format, strb->stride, height); - strb->data = _mesa_malloc(size); + strb->data = malloc(size); return strb->data != NULL; } @@ -149,16 +131,15 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb, PIPE_BUFFER_USAGE_CPU_WRITE); #endif - strb->texture = pipe->screen->texture_create( pipe->screen, - &template ); + strb->texture = screen->texture_create(screen, &template); if (!strb->texture) return FALSE; - strb->surface = pipe->screen->get_tex_surface( pipe->screen, - strb->texture, - 0, 0, 0, - surface_usage ); + strb->surface = screen->get_tex_surface(screen, + strb->texture, + 0, 0, 0, + surface_usage); if (strb->surface) { assert(strb->surface->texture); assert(strb->surface->format); @@ -181,8 +162,8 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb) ASSERT(strb); pipe_surface_reference(&strb->surface, NULL); pipe_texture_reference(&strb->texture, NULL); - _mesa_free(strb->data); - _mesa_free(strb); + free(strb->data); + free(strb); } @@ -251,18 +232,19 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw) _mesa_init_renderbuffer(&strb->Base, 0); strb->Base.ClassID = 0x4242; /* just a unique value */ strb->Base.NumSamples = samples; + strb->Base.Format = st_pipe_format_to_mesa_format(format); + strb->Base.DataType = st_format_datatype(format); strb->format = format; - init_renderbuffer_bits(strb, format); strb->software = sw; switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: case PIPE_FORMAT_B8G8R8A8_UNORM: - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: case PIPE_FORMAT_B8G8R8X8_UNORM: - case PIPE_FORMAT_A1R5G5B5_UNORM: - case PIPE_FORMAT_A4R4G4B4_UNORM: - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: strb->Base.InternalFormat = GL_RGBA; break; case PIPE_FORMAT_Z16_UNORM: @@ -271,10 +253,10 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw) case PIPE_FORMAT_Z32_UNORM: strb->Base.InternalFormat = GL_DEPTH_COMPONENT32; break; - case PIPE_FORMAT_S8Z24_UNORM: case PIPE_FORMAT_Z24S8_UNORM: - case PIPE_FORMAT_X8Z24_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: case PIPE_FORMAT_Z24X8_UNORM: + case PIPE_FORMAT_X8Z24_UNORM: strb->Base.InternalFormat = GL_DEPTH24_STENCIL8_EXT; break; case PIPE_FORMAT_S8_UNORM: @@ -286,7 +268,7 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw) default: _mesa_problem(NULL, "Unexpected format in st_new_renderbuffer_fb"); - _mesa_free(strb); + free(strb); return NULL; } @@ -397,7 +379,8 @@ st_render_texture(GLcontext *ctx, PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE); - init_renderbuffer_bits(strb, pt->format); + strb->Base.Format = st_pipe_format_to_mesa_format(pt->format); + strb->Base.DataType = st_format_datatype(pt->format); /* printf("RENDER TO TEXTURE obj=%p pt=%p surf=%p %d x %d\n", @@ -427,17 +410,12 @@ st_finish_render_texture(GLcontext *ctx, st_flush( ctx->st, PIPE_FLUSH_RENDER_CACHE, NULL ); - if (strb->surface) - pipe_surface_reference( &strb->surface, NULL ); - strb->rtt = NULL; /* printf("FINISH RENDER TO TEXTURE surf=%p\n", strb->surface); */ - _mesa_reference_renderbuffer(&att->Renderbuffer, NULL); - /* restore previous framebuffer state */ st_invalidate_state(ctx, _NEW_BUFFERS); } diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c index edf26473d45..37b1fb55f4a 100644 --- a/src/mesa/state_tracker/st_cb_feedback.c +++ b/src/mesa/state_tracker/st_cb_feedback.c @@ -83,7 +83,6 @@ feedback_vertex(GLcontext *ctx, const struct draw_context *draw, const struct st_context *st = ctx->st; GLfloat win[4]; const GLfloat *color, *texcoord; - const GLfloat ci = 0; GLuint slot; /* Recall that Y=0=Top of window for Gallium wincoords */ @@ -109,7 +108,7 @@ feedback_vertex(GLcontext *ctx, const struct draw_context *draw, else texcoord = ctx->Current.Attrib[VERT_ATTRIB_TEX0]; - _mesa_feedback_vertex(ctx, win, color, ci, texcoord); + _mesa_feedback_vertex(ctx, win, color, texcoord); } diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c index 573c78336c4..1329f807bc9 100644 --- a/src/mesa/state_tracker/st_cb_flush.c +++ b/src/mesa/state_tracker/st_cb_flush.c @@ -102,10 +102,6 @@ void st_flush( struct st_context *st, uint pipeFlushFlags, util_gen_mipmap_flush(st->gen_mipmap); st->pipe->flush( st->pipe, pipeFlushFlags, fence ); - - if ((pipeFlushFlags & PIPE_FLUSH_FRAME) && - is_front_buffer_dirty(st)) - display_front_buffer(st); } @@ -139,6 +135,10 @@ static void st_glFlush(GLcontext *ctx) * problems that need to be fixed elsewhere. */ st_flush(st, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, NULL); + + if (is_front_buffer_dirty(st)) { + display_front_buffer(st); + } } @@ -150,6 +150,10 @@ static void st_glFinish(GLcontext *ctx) struct st_context *st = ctx->st; st_finish(st); + + if (is_front_buffer_dirty(st)) { + display_front_buffer(st); + } } diff --git a/src/mesa/state_tracker/st_cb_queryobj.c b/src/mesa/state_tracker/st_cb_queryobj.c index dc40c5d269d..c66729b1244 100644 --- a/src/mesa/state_tracker/st_cb_queryobj.c +++ b/src/mesa/state_tracker/st_cb_queryobj.c @@ -69,7 +69,7 @@ st_DeleteQuery(GLcontext *ctx, struct gl_query_object *q) stq->pq = NULL; } - _mesa_free(stq); + free(stq); } diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c index 4692891c8aa..752b411b5fc 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -101,7 +101,7 @@ rastpos_line( struct draw_stage *stage, struct prim_header *prim ) static void rastpos_destroy(struct draw_stage *stage) { - _mesa_free(stage); + free(stage); } diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c index 6b1fdf3ecd0..952d9ce9156 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -108,7 +108,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, memcpy(sValues, src, width); } break; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: if (format == GL_DEPTH_STENCIL) { const uint *src = (uint *) (stmap + srcY * pt->stride); const GLfloat scale = 1.0f / (0xffffff); @@ -126,7 +126,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y, } } break; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: if (format == GL_DEPTH_STENCIL) { const uint *src = (uint *) (stmap + srcY * pt->stride); const GLfloat scale = 1.0f / (0xffffff); @@ -214,15 +214,15 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb, if (ctx->_ImageTransferState) return GL_FALSE; - if (strb->format == PIPE_FORMAT_A8R8G8B8_UNORM && + if (strb->format == PIPE_FORMAT_B8G8R8A8_UNORM && format == GL_RGBA && type == GL_UNSIGNED_BYTE) { combo = A8R8G8B8_UNORM_TO_RGBA_UBYTE; } - else if (strb->format == PIPE_FORMAT_A8R8G8B8_UNORM && + else if (strb->format == PIPE_FORMAT_B8G8R8A8_UNORM && format == GL_RGB && type == GL_UNSIGNED_BYTE) { combo = A8R8G8B8_UNORM_TO_RGB_UBYTE; } - else if (strb->format == PIPE_FORMAT_A8R8G8B8_UNORM && + else if (strb->format == PIPE_FORMAT_B8G8R8A8_UNORM && format == GL_BGRA && type == GL_UNSIGNED_INT_8_8_8_8_REV) { combo = A8R8G8B8_UNORM_TO_BGRA_UINT; } @@ -429,8 +429,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const GLint dstStride = _mesa_image_row_stride(&clippedPacking, width, format, type); - if (trans->texture->format == PIPE_FORMAT_S8Z24_UNORM || - trans->texture->format == PIPE_FORMAT_X8Z24_UNORM) { + if (trans->texture->format == PIPE_FORMAT_Z24S8_UNORM || + trans->texture->format == PIPE_FORMAT_Z24X8_UNORM) { if (format == GL_DEPTH_COMPONENT) { for (i = 0; i < height; i++) { GLuint ztemp[MAX_WIDTH]; @@ -461,8 +461,8 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, } } } - else if (trans->texture->format == PIPE_FORMAT_Z24S8_UNORM || - trans->texture->format == PIPE_FORMAT_Z24X8_UNORM) { + else if (trans->texture->format == PIPE_FORMAT_S8Z24_UNORM || + trans->texture->format == PIPE_FORMAT_X8Z24_UNORM) { if (format == GL_DEPTH_COMPONENT) { for (i = 0; i < height; i++) { GLuint ztemp[MAX_WIDTH]; diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 13f050900a6..c849132e74c 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1319,7 +1319,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, else { /* RGBA format */ GLfloat *tempSrc = - (GLfloat *) _mesa_malloc(width * height * 4 * sizeof(GLfloat)); + (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat)); if (tempSrc && texDest) { const GLint dims = 2; @@ -1359,7 +1359,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level, } if (tempSrc) - _mesa_free(tempSrc); + free(tempSrc); } st_texture_image_unmap(ctx->st, stImage); @@ -1717,19 +1717,16 @@ copy_image_data_to_texture(struct st_context *st, st_texture_image_copy(st->pipe, stObj->pt, dstLevel, /* dest texture, level */ stImage->pt, /* src texture */ - stImage->face - ); + stImage->face); pipe_texture_reference(&stImage->pt, NULL); } else if (stImage->base.Data) { /* More straightforward upload. */ - st_teximage_flush_before_map(st, stObj->pt, stImage->face, dstLevel, PIPE_TRANSFER_WRITE); - st_texture_image_data(st, stObj->pt, stImage->face, diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 5b3987d73ae..09f891d691a 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -141,6 +141,14 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) for (i = 0; i < PIPE_MAX_SAMPLERS; i++) st->state.sampler_list[i] = &st->state.samplers[i]; + for (i = 0; i < 3; i++) { + memset(&st->velems_util_draw[i], 0, sizeof(struct pipe_vertex_element)); + st->velems_util_draw[i].src_offset = i * 4 * sizeof(float); + st->velems_util_draw[i].instance_divisor = 0; + st->velems_util_draw[i].vertex_buffer_index = 0; + st->velems_util_draw[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; + } + /* we want all vertex data to be placed in buffer objects */ vbo_use_buffer_objects(ctx); @@ -222,7 +230,7 @@ static void st_destroy_context_priv( struct st_context *st ) st->default_texture = NULL; } - _mesa_free( st ); + free( st ); } @@ -257,14 +265,15 @@ void st_destroy_context( struct st_context *st ) pipe->destroy( pipe ); - _mesa_free(ctx); + free(ctx); } GLboolean st_make_current(struct st_context *st, struct st_framebuffer *draw, - struct st_framebuffer *read) + struct st_framebuffer *read, + void *winsys_drawable_handle ) { /* Call this periodically to detect when the user has begun using * GL rendering from multiple threads. @@ -272,10 +281,13 @@ st_make_current(struct st_context *st, _glapi_check_multithread(); if (st) { - if (!_mesa_make_current(st->ctx, &draw->Base, &read->Base)) + if (!_mesa_make_current(st->ctx, &draw->Base, &read->Base)) { + st->pipe->priv = NULL; return GL_FALSE; + } _mesa_check_init_viewport(st->ctx, draw->InitWidth, draw->InitHeight); + st->pipe->priv = winsys_drawable_handle; return GL_TRUE; } diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 50e98d7146a..6622361a7e3 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -166,6 +166,7 @@ struct st_context struct { struct pipe_rasterizer_state raster; struct pipe_viewport_state viewport; + struct pipe_clip_state clip; void *vs; void *fs; float vertices[4][2][4]; /**< vertex pos + color */ @@ -173,6 +174,9 @@ struct st_context unsigned vbuf_slot; } clear; + /** used for anything using util_draw_vertex_buffer */ + struct pipe_vertex_element velems_util_draw[3]; + void *passthrough_fs; /**< simple pass-through frag shader */ struct gen_mipmap_state *gen_mipmap; @@ -239,7 +243,7 @@ st_fb_orientation(const struct gl_framebuffer *fb) /** clear-alloc a struct-sized object, with casting */ -#define ST_CALLOC_STRUCT(T) (struct T *) _mesa_calloc(sizeof(struct T)) +#define ST_CALLOC_STRUCT(T) (struct T *) calloc(1, sizeof(struct T)) extern int diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 4b48c168e9c..8a6e1ed4662 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -57,6 +57,7 @@ #include "pipe/p_defines.h" #include "util/u_inlines.h" #include "util/u_format.h" +#include "cso_cache/cso_context.h" static GLuint double_types[4] = { @@ -183,7 +184,7 @@ st_pipe_vertex_format(GLenum type, GLuint size, GLenum format, /* this is an odd-ball case */ assert(type == GL_UNSIGNED_BYTE); assert(normalized); - return PIPE_FORMAT_B8G8R8A8_UNORM; + return PIPE_FORMAT_A8R8G8B8_UNORM; } if (normalized) { @@ -368,7 +369,6 @@ setup_interleaved_attribs(GLcontext *ctx, (unsigned) (arrays[mesaAttr]->Ptr - offset0); velements[attr].instance_divisor = 0; velements[attr].vertex_buffer_index = 0; - velements[attr].nr_components = arrays[mesaAttr]->Size; velements[attr].src_format = st_pipe_vertex_format(arrays[mesaAttr]->Type, arrays[mesaAttr]->Size, @@ -458,7 +458,6 @@ setup_non_interleaved_attribs(GLcontext *ctx, vbuffer[attr].max_index = max_index; velements[attr].instance_divisor = 0; velements[attr].vertex_buffer_index = attr; - velements[attr].nr_components = arrays[mesaAttr]->Size; velements[attr].src_format = st_pipe_vertex_format(arrays[mesaAttr]->Type, arrays[mesaAttr]->Size, @@ -564,6 +563,7 @@ st_draw_vbo(GLcontext *ctx, (void) check_uniforms; #endif + memset(velements, 0, sizeof(struct pipe_vertex_element) * vpv->num_inputs); /* * Setup the vbuffer[] and velements[] arrays. */ @@ -596,14 +596,13 @@ st_draw_vbo(GLcontext *ctx, for (i = 0; i < num_velements; i++) { printf("vlements[%d].vbuffer_index = %u\n", i, velements[i].vertex_buffer_index); printf("vlements[%d].src_offset = %u\n", i, velements[i].src_offset); - printf("vlements[%d].nr_comps = %u\n", i, velements[i].nr_components); printf("vlements[%d].format = %s\n", i, util_format_name(velements[i].src_format)); } } #endif pipe->set_vertex_buffers(pipe, num_vbuffers, vbuffer); - pipe->set_vertex_elements(pipe, num_velements, velements); + cso_set_vertex_elements(ctx->st->cso_context, num_velements, velements); if (num_vbuffers == 0 || num_velements == 0) return; diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index 087f2f22bbf..26a5b3fcd63 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -178,7 +178,6 @@ st_feedback_draw_vbo(GLcontext *ctx, vbuffers[attr].max_index = max_index; velements[attr].instance_divisor = 0; velements[attr].vertex_buffer_index = attr; - velements[attr].nr_components = arrays[mesaAttr]->Size; velements[attr].src_format = st_pipe_vertex_format(arrays[mesaAttr]->Type, arrays[mesaAttr]->Size, diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index d5f58546613..e03dd30f0f5 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -137,6 +137,9 @@ void st_init_limits(struct st_context *st) /* XXX separate query for early function return? */ st->ctx->Shader.EmitContReturn = screen->get_param(screen, PIPE_CAP_TGSI_CONT_SUPPORTED); + + /* Quads always follow GL provoking rules. */ + c->QuadsFollowProvokingVertexConvention = GL_FALSE; } @@ -270,28 +273,28 @@ void st_init_extensions(struct st_context *st) /* GL_EXT_packed_depth_stencil requires both the ability to render to * a depth/stencil buffer and texture from depth/stencil source. */ - if (screen->is_format_supported(screen, PIPE_FORMAT_Z24S8_UNORM, + if (screen->is_format_supported(screen, PIPE_FORMAT_S8Z24_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0) && - screen->is_format_supported(screen, PIPE_FORMAT_Z24S8_UNORM, + screen->is_format_supported(screen, PIPE_FORMAT_S8Z24_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER, 0)) { ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; } - else if (screen->is_format_supported(screen, PIPE_FORMAT_S8Z24_UNORM, + else if (screen->is_format_supported(screen, PIPE_FORMAT_Z24S8_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0) && - screen->is_format_supported(screen, PIPE_FORMAT_S8Z24_UNORM, + screen->is_format_supported(screen, PIPE_FORMAT_Z24S8_UNORM, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER, 0)) { ctx->Extensions.EXT_packed_depth_stencil = GL_TRUE; } /* sRGB support */ - if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SRGB, + if (screen->is_format_supported(screen, PIPE_FORMAT_A8B8G8R8_SRGB, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER, 0) || - screen->is_format_supported(screen, PIPE_FORMAT_A8R8G8B8_SRGB, + screen->is_format_supported(screen, PIPE_FORMAT_B8G8R8A8_SRGB, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER, 0)) { ctx->Extensions.EXT_texture_sRGB = GL_TRUE; @@ -299,17 +302,21 @@ void st_init_extensions(struct st_context *st) /* s3tc support */ if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA, - PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_SAMPLER, 0)) { + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_SAMPLER, 0) && + (ctx->Mesa_DXTn || + screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA, + PIPE_TEXTURE_2D, + PIPE_TEXTURE_USAGE_RENDER_TARGET, 0))) { ctx->Extensions.EXT_texture_compression_s3tc = GL_TRUE; ctx->Extensions.S3_s3tc = GL_TRUE; } /* ycbcr support */ - if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR, + if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER, 0) || - screen->is_format_supported(screen, PIPE_FORMAT_YCBCR_REV, + screen->is_format_supported(screen, PIPE_FORMAT_YUYV, PIPE_TEXTURE_2D, PIPE_TEXTURE_USAGE_SAMPLER, 0)) { ctx->Extensions.MESA_ycbcr_texture = GL_TRUE; diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c index 851c16f83cc..9ae0c9f9bab 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -1,7 +1,7 @@ /************************************************************************** * * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. - * Copyright (c) 2008 VMware, Inc. + * Copyright (c) 2008-2010 VMware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -28,7 +28,7 @@ /** - * Texture Image-related functions. + * Mesa / Gallium format conversion and format selection code. * \author Brian Paul */ @@ -59,151 +59,69 @@ format_max_bits(enum pipe_format format) return size; } -static GLuint -format_size(enum pipe_format format) -{ - return - util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0) + - util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 1) + - util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 2) + - util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3) + - util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0) + - util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1); -} -/* - * XXX temporary here +/** + * Return basic GL datatype for the given gallium format. */ -GLboolean -st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo) +GLenum +st_format_datatype(enum pipe_format format) { const struct util_format_description *desc; desc = util_format_description(format); assert(desc); - if (desc->layout == UTIL_FORMAT_LAYOUT_ARITH || - desc->layout == UTIL_FORMAT_LAYOUT_ARRAY) { -#if 0 - printf("%s\n", util_format_name( format ) ); -#endif - - /* Data type */ - if (format == PIPE_FORMAT_A1R5G5B5_UNORM || format == PIPE_FORMAT_R5G6B5_UNORM) { - pinfo->datatype = GL_UNSIGNED_SHORT; + if (desc->layout == UTIL_FORMAT_LAYOUT_PLAIN) { + if (format == PIPE_FORMAT_B5G5R5A1_UNORM || + format == PIPE_FORMAT_B5G6R5_UNORM) { + return GL_UNSIGNED_SHORT; } - else if (format == PIPE_FORMAT_S8Z24_UNORM || - format == PIPE_FORMAT_Z24S8_UNORM) { - pinfo->datatype = GL_UNSIGNED_INT_24_8; + else if (format == PIPE_FORMAT_Z24S8_UNORM || + format == PIPE_FORMAT_S8Z24_UNORM) { + return GL_UNSIGNED_INT_24_8; } else { const GLuint size = format_max_bits(format); if (size == 8) { if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED) - pinfo->datatype = GL_UNSIGNED_BYTE; + return GL_UNSIGNED_BYTE; else - pinfo->datatype = GL_BYTE; + return GL_BYTE; } else if (size == 16) { if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED) - pinfo->datatype = GL_UNSIGNED_SHORT; + return GL_UNSIGNED_SHORT; else - pinfo->datatype = GL_SHORT; + return GL_SHORT; } else { assert( size <= 32 ); if (desc->channel[0].type == UTIL_FORMAT_TYPE_UNSIGNED) - pinfo->datatype = GL_UNSIGNED_INT; + return GL_UNSIGNED_INT; else - pinfo->datatype = GL_INT; + return GL_INT; } } - - /* Component bits */ - pinfo->red_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 0); - pinfo->green_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 1); - pinfo->blue_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 2); - pinfo->alpha_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_RGB, 3); - pinfo->depth_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0); - pinfo->stencil_bits = util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1); - pinfo->luminance_bits = 0; - pinfo->intensity_bits = 0; - - /* Format size */ - pinfo->size = format_size(format) / 8; - - /* Luminance & Intensity bits */ - if (desc->swizzle[0] == UTIL_FORMAT_SWIZZLE_X && - desc->swizzle[1] == UTIL_FORMAT_SWIZZLE_X && - desc->swizzle[2] == UTIL_FORMAT_SWIZZLE_X) { - if (desc->swizzle[3] == UTIL_FORMAT_SWIZZLE_X) { - pinfo->intensity_bits = pinfo->red_bits; - } - else { - pinfo->luminance_bits = pinfo->red_bits; - } - pinfo->red_bits = 0; - } - - pinfo->mesa_format = st_pipe_format_to_mesa_format(format); } - else if (desc->layout == UTIL_FORMAT_LAYOUT_YUV) { - pinfo->mesa_format = MESA_FORMAT_YCBCR; - pinfo->datatype = GL_UNSIGNED_SHORT; - pinfo->size = 2; /* two bytes per "texel" */ + else if (format == PIPE_FORMAT_UYVY) { + return GL_UNSIGNED_SHORT; + } + else if (format == PIPE_FORMAT_YUYV) { + return GL_UNSIGNED_SHORT; } else { /* compressed format? */ assert(0); } -#if 0 - printf( - "ST_FORMAT: R(%u), G(%u), B(%u), A(%u), Z(%u), S(%u)\n", - pinfo->red_bits, - pinfo->green_bits, - pinfo->blue_bits, - pinfo->alpha_bits, - pinfo->depth_bits, - pinfo->stencil_bits ); -#endif - - pinfo->format = format; - - return GL_TRUE; -} - - -/** - * Return bytes per pixel for the given format. - */ -GLuint -st_sizeof_format(enum pipe_format format) -{ - struct pipe_format_info info; - if (!st_get_format_info( format, &info )) { - assert( 0 ); - return 0; - } - return info.size; + assert(0); + return GL_NONE; } /** - * Return bytes per pixel for the given format. + * Translate Mesa format to Gallium format. */ -GLenum -st_format_datatype(enum pipe_format format) -{ - struct pipe_format_info info; - if (!st_get_format_info( format, &info )) { - assert( 0 ); - return 0; - } - return info.datatype; -} - - enum pipe_format st_mesa_format_to_pipe_format(gl_format mesaFormat) { @@ -211,17 +129,17 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) /* fix this */ case MESA_FORMAT_ARGB8888_REV: case MESA_FORMAT_ARGB8888: - return PIPE_FORMAT_A8R8G8B8_UNORM; + return PIPE_FORMAT_B8G8R8A8_UNORM; case MESA_FORMAT_XRGB8888: - return PIPE_FORMAT_X8R8G8B8_UNORM; + return PIPE_FORMAT_B8G8R8X8_UNORM; case MESA_FORMAT_ARGB1555: - return PIPE_FORMAT_A1R5G5B5_UNORM; + return PIPE_FORMAT_B5G5R5A1_UNORM; case MESA_FORMAT_ARGB4444: - return PIPE_FORMAT_A4R4G4B4_UNORM; + return PIPE_FORMAT_B4G4R4A4_UNORM; case MESA_FORMAT_RGB565: - return PIPE_FORMAT_R5G6B5_UNORM; + return PIPE_FORMAT_B5G6R5_UNORM; case MESA_FORMAT_AL88: - return PIPE_FORMAT_A8L8_UNORM; + return PIPE_FORMAT_L8A8_UNORM; case MESA_FORMAT_A8: return PIPE_FORMAT_A8_UNORM; case MESA_FORMAT_L8: @@ -233,11 +151,11 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) case MESA_FORMAT_Z32: return PIPE_FORMAT_Z32_UNORM; case MESA_FORMAT_Z24_S8: - return PIPE_FORMAT_Z24S8_UNORM; - case MESA_FORMAT_S8_Z24: return PIPE_FORMAT_S8Z24_UNORM; + case MESA_FORMAT_S8_Z24: + return PIPE_FORMAT_Z24S8_UNORM; case MESA_FORMAT_YCBCR: - return PIPE_FORMAT_YCBCR; + return PIPE_FORMAT_UYVY; #if FEATURE_texture_s3tc case MESA_FORMAT_RGB_DXT1: return PIPE_FORMAT_DXT1_RGB; @@ -260,15 +178,15 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) #endif #if FEATURE_EXT_texture_sRGB case MESA_FORMAT_SLA8: - return PIPE_FORMAT_A8L8_SRGB; + return PIPE_FORMAT_L8A8_SRGB; case MESA_FORMAT_SL8: return PIPE_FORMAT_L8_SRGB; case MESA_FORMAT_SRGB8: return PIPE_FORMAT_R8G8B8_SRGB; case MESA_FORMAT_SRGBA8: - return PIPE_FORMAT_R8G8B8A8_SRGB; + return PIPE_FORMAT_A8B8G8R8_SRGB; case MESA_FORMAT_SARGB8: - return PIPE_FORMAT_A8R8G8B8_SRGB; + return PIPE_FORMAT_B8G8R8A8_SRGB; #endif default: assert(0); @@ -277,25 +195,28 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) } +/** + * Translate Gallium format to Mesa format. + */ gl_format -st_pipe_format_to_mesa_format(enum pipe_format pipeFormat) +st_pipe_format_to_mesa_format(enum pipe_format format) { - switch (pipeFormat) { - case PIPE_FORMAT_A8R8G8B8_UNORM: + switch (format) { + case PIPE_FORMAT_B8G8R8A8_UNORM: return MESA_FORMAT_ARGB8888; - case PIPE_FORMAT_X8R8G8B8_UNORM: + case PIPE_FORMAT_B8G8R8X8_UNORM: return MESA_FORMAT_XRGB8888; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: return MESA_FORMAT_ARGB8888_REV; - case PIPE_FORMAT_B8G8R8X8_UNORM: + case PIPE_FORMAT_X8R8G8B8_UNORM: return MESA_FORMAT_XRGB8888_REV; - case PIPE_FORMAT_A1R5G5B5_UNORM: + case PIPE_FORMAT_B5G5R5A1_UNORM: return MESA_FORMAT_ARGB1555; - case PIPE_FORMAT_A4R4G4B4_UNORM: + case PIPE_FORMAT_B4G4R4A4_UNORM: return MESA_FORMAT_ARGB4444; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: return MESA_FORMAT_RGB565; - case PIPE_FORMAT_A8L8_UNORM: + case PIPE_FORMAT_L8A8_UNORM: return MESA_FORMAT_AL88; case PIPE_FORMAT_A8_UNORM: return MESA_FORMAT_A8; @@ -303,25 +224,29 @@ st_pipe_format_to_mesa_format(enum pipe_format pipeFormat) return MESA_FORMAT_L8; case PIPE_FORMAT_I8_UNORM: return MESA_FORMAT_I8; + case PIPE_FORMAT_S8_UNORM: + return MESA_FORMAT_S8; + + case PIPE_FORMAT_R16G16B16A16_SNORM: + return MESA_FORMAT_SIGNED_RGBA_16; + case PIPE_FORMAT_Z16_UNORM: return MESA_FORMAT_Z16; case PIPE_FORMAT_Z32_UNORM: return MESA_FORMAT_Z32; - case PIPE_FORMAT_Z24X8_UNORM: - return MESA_FORMAT_Z24_X8; - case PIPE_FORMAT_Z24S8_UNORM: + case PIPE_FORMAT_S8Z24_UNORM: return MESA_FORMAT_Z24_S8; case PIPE_FORMAT_X8Z24_UNORM: + return MESA_FORMAT_Z24_X8; + case PIPE_FORMAT_Z24X8_UNORM: return MESA_FORMAT_X8_Z24; - case PIPE_FORMAT_S8Z24_UNORM: + case PIPE_FORMAT_Z24S8_UNORM: return MESA_FORMAT_S8_Z24; - case PIPE_FORMAT_S8_UNORM: - return MESA_FORMAT_S8; - case PIPE_FORMAT_YCBCR: + case PIPE_FORMAT_UYVY: return MESA_FORMAT_YCBCR; - case PIPE_FORMAT_R16G16B16A16_SNORM: - return MESA_FORMAT_SIGNED_RGBA_16; + case PIPE_FORMAT_YUYV: + return MESA_FORMAT_YCBCR_REV; #if FEATURE_texture_s3tc case PIPE_FORMAT_DXT1_RGB: @@ -343,21 +268,22 @@ st_pipe_format_to_mesa_format(enum pipe_format pipeFormat) return MESA_FORMAT_SRGBA_DXT5; #endif #endif + #if FEATURE_EXT_texture_sRGB - case PIPE_FORMAT_A8L8_SRGB: + case PIPE_FORMAT_L8A8_SRGB: return MESA_FORMAT_SLA8; case PIPE_FORMAT_L8_SRGB: return MESA_FORMAT_SL8; case PIPE_FORMAT_R8G8B8_SRGB: return MESA_FORMAT_SRGB8; - case PIPE_FORMAT_R8G8B8A8_SRGB: + case PIPE_FORMAT_A8B8G8R8_SRGB: return MESA_FORMAT_SRGBA8; - case PIPE_FORMAT_A8R8G8B8_SRGB: + case PIPE_FORMAT_B8G8R8A8_SRGB: return MESA_FORMAT_SARGB8; #endif default: assert(0); - return 0; + return MESA_FORMAT_NONE; } } @@ -372,10 +298,10 @@ default_rgba_format(struct pipe_screen *screen, unsigned geom_flags) { static const enum pipe_format colorFormats[] = { - PIPE_FORMAT_A8R8G8B8_UNORM, PIPE_FORMAT_B8G8R8A8_UNORM, - PIPE_FORMAT_R8G8B8A8_UNORM, - PIPE_FORMAT_R5G6B5_UNORM + PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_A8B8G8R8_UNORM, + PIPE_FORMAT_B5G6R5_UNORM }; uint i; for (i = 0; i < Elements(colorFormats); i++) { @@ -396,13 +322,13 @@ default_rgb_format(struct pipe_screen *screen, unsigned geom_flags) { static const enum pipe_format colorFormats[] = { - PIPE_FORMAT_X8R8G8B8_UNORM, PIPE_FORMAT_B8G8R8X8_UNORM, - PIPE_FORMAT_R8G8B8X8_UNORM, - PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_X8R8G8B8_UNORM, + PIPE_FORMAT_X8B8G8R8_UNORM, PIPE_FORMAT_B8G8R8A8_UNORM, - PIPE_FORMAT_R8G8B8A8_UNORM, - PIPE_FORMAT_R5G6B5_UNORM + PIPE_FORMAT_A8R8G8B8_UNORM, + PIPE_FORMAT_A8B8G8R8_UNORM, + PIPE_FORMAT_B5G6R5_UNORM }; uint i; for (i = 0; i < Elements(colorFormats); i++) { @@ -423,9 +349,9 @@ default_srgba_format(struct pipe_screen *screen, unsigned geom_flags) { static const enum pipe_format colorFormats[] = { - PIPE_FORMAT_A8R8G8B8_SRGB, PIPE_FORMAT_B8G8R8A8_SRGB, - PIPE_FORMAT_R8G8B8A8_SRGB, + PIPE_FORMAT_A8R8G8B8_SRGB, + PIPE_FORMAT_A8B8G8R8_SRGB, }; uint i; for (i = 0; i < Elements(colorFormats); i++) { @@ -467,8 +393,8 @@ default_depth_format(struct pipe_screen *screen, static const enum pipe_format zFormats[] = { PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_Z32_UNORM, - PIPE_FORMAT_S8Z24_UNORM, - PIPE_FORMAT_Z24S8_UNORM + PIPE_FORMAT_Z24S8_UNORM, + PIPE_FORMAT_S8Z24_UNORM }; uint i; for (i = 0; i < Elements(zFormats); i++) { @@ -513,13 +439,13 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_RGBA4: case GL_RGBA2: - if (screen->is_format_supported( screen, PIPE_FORMAT_A4R4G4B4_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_A4R4G4B4_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_B4G4R4A4_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_B4G4R4A4_UNORM; return default_rgba_format( screen, target, tex_usage, geom_flags ); case GL_RGB5_A1: - if (screen->is_format_supported( screen, PIPE_FORMAT_A1R5G5B5_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_A1R5G5B5_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_B5G5R5A1_UNORM; return default_rgba_format( screen, target, tex_usage, geom_flags ); case GL_RGB8: @@ -531,10 +457,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_RGB5: case GL_RGB4: case GL_R3_G3_B2: - if (screen->is_format_supported( screen, PIPE_FORMAT_R5G6B5_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_R5G6B5_UNORM; - if (screen->is_format_supported( screen, PIPE_FORMAT_A1R5G5B5_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_A1R5G5B5_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_B5G6R5_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_B5G6R5_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_B5G5R5A1_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_B5G5R5A1_UNORM; return default_rgba_format( screen, target, tex_usage, geom_flags ); case GL_ALPHA: @@ -567,8 +493,8 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_LUMINANCE12_ALPHA12: case GL_LUMINANCE16_ALPHA16: case GL_COMPRESSED_LUMINANCE_ALPHA: - if (screen->is_format_supported( screen, PIPE_FORMAT_A8L8_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_A8L8_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_L8A8_UNORM; return default_rgba_format( screen, target, tex_usage, geom_flags ); case GL_INTENSITY: @@ -582,13 +508,13 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, return default_rgba_format( screen, target, tex_usage, geom_flags ); case GL_YCBCR_MESA: - if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR, + if (screen->is_format_supported(screen, PIPE_FORMAT_UYVY, target, tex_usage, geom_flags)) { - return PIPE_FORMAT_YCBCR; + return PIPE_FORMAT_UYVY; } - if (screen->is_format_supported(screen, PIPE_FORMAT_YCBCR_REV, + if (screen->is_format_supported(screen, PIPE_FORMAT_YUYV, target, tex_usage, geom_flags)) { - return PIPE_FORMAT_YCBCR_REV; + return PIPE_FORMAT_YUYV; } return PIPE_FORMAT_NONE; @@ -620,10 +546,10 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, return PIPE_FORMAT_Z16_UNORM; /* fall-through */ case GL_DEPTH_COMPONENT24: - if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_S8Z24_UNORM; if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags )) return PIPE_FORMAT_Z24S8_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_S8Z24_UNORM; /* fall-through */ case GL_DEPTH_COMPONENT32: if (screen->is_format_supported( screen, PIPE_FORMAT_Z32_UNORM, target, tex_usage, geom_flags )) @@ -639,18 +565,18 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_STENCIL_INDEX16_EXT: if (screen->is_format_supported( screen, PIPE_FORMAT_S8_UNORM, target, tex_usage, geom_flags )) return PIPE_FORMAT_S8_UNORM; - if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_S8Z24_UNORM; if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags )) return PIPE_FORMAT_Z24S8_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_S8Z24_UNORM; return PIPE_FORMAT_NONE; case GL_DEPTH_STENCIL_EXT: case GL_DEPTH24_STENCIL8_EXT: - if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) - return PIPE_FORMAT_S8Z24_UNORM; if (screen->is_format_supported( screen, PIPE_FORMAT_Z24S8_UNORM, target, tex_usage, geom_flags )) return PIPE_FORMAT_Z24S8_UNORM; + if (screen->is_format_supported( screen, PIPE_FORMAT_S8Z24_UNORM, target, tex_usage, geom_flags )) + return PIPE_FORMAT_S8Z24_UNORM; return PIPE_FORMAT_NONE; case GL_SRGB_EXT: @@ -673,8 +599,8 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_SLUMINANCE8_ALPHA8_EXT: case GL_COMPRESSED_SLUMINANCE_EXT: case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT: - if (screen->is_format_supported( screen, PIPE_FORMAT_A8L8_SRGB, target, tex_usage, geom_flags )) - return PIPE_FORMAT_A8L8_SRGB; + if (screen->is_format_supported( screen, PIPE_FORMAT_L8A8_SRGB, target, tex_usage, geom_flags )) + return PIPE_FORMAT_L8A8_SRGB; return default_srgba_format( screen, target, tex_usage, geom_flags ); case GL_SLUMINANCE_EXT: @@ -726,82 +652,6 @@ st_choose_renderbuffer_format(struct pipe_screen *screen, } -static gl_format -translate_gallium_format_to_mesa_format(enum pipe_format format) -{ - switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - return MESA_FORMAT_ARGB8888; - case PIPE_FORMAT_X8R8G8B8_UNORM: - return MESA_FORMAT_XRGB8888; - case PIPE_FORMAT_A1R5G5B5_UNORM: - return MESA_FORMAT_ARGB1555; - case PIPE_FORMAT_A4R4G4B4_UNORM: - return MESA_FORMAT_ARGB4444; - case PIPE_FORMAT_R5G6B5_UNORM: - return MESA_FORMAT_RGB565; - case PIPE_FORMAT_A8L8_UNORM: - return MESA_FORMAT_AL88; - case PIPE_FORMAT_A8_UNORM: - return MESA_FORMAT_A8; - case PIPE_FORMAT_L8_UNORM: - return MESA_FORMAT_L8; - case PIPE_FORMAT_I8_UNORM: - return MESA_FORMAT_I8; - case PIPE_FORMAT_Z16_UNORM: - return MESA_FORMAT_Z16; - case PIPE_FORMAT_Z32_UNORM: - return MESA_FORMAT_Z32; - case PIPE_FORMAT_Z24S8_UNORM: - return MESA_FORMAT_Z24_S8; - case PIPE_FORMAT_X8Z24_UNORM: - return MESA_FORMAT_X8_Z24; - case PIPE_FORMAT_S8Z24_UNORM: - return MESA_FORMAT_S8_Z24; - case PIPE_FORMAT_YCBCR: - return MESA_FORMAT_YCBCR; - case PIPE_FORMAT_YCBCR_REV: - return MESA_FORMAT_YCBCR_REV; -#if FEATURE_texture_s3tc - case PIPE_FORMAT_DXT1_RGB: - return MESA_FORMAT_RGB_DXT1; - case PIPE_FORMAT_DXT1_RGBA: - return MESA_FORMAT_RGBA_DXT1; - case PIPE_FORMAT_DXT3_RGBA: - return MESA_FORMAT_RGBA_DXT3; - case PIPE_FORMAT_DXT5_RGBA: - return MESA_FORMAT_RGBA_DXT5; -#if FEATURE_EXT_texture_sRGB - case PIPE_FORMAT_DXT1_SRGB: - return MESA_FORMAT_SRGB_DXT1; - case PIPE_FORMAT_DXT1_SRGBA: - return MESA_FORMAT_SRGBA_DXT1; - case PIPE_FORMAT_DXT3_SRGBA: - return MESA_FORMAT_SRGBA_DXT3; - case PIPE_FORMAT_DXT5_SRGBA: - return MESA_FORMAT_SRGBA_DXT5; -#endif -#endif -#if FEATURE_EXT_texture_sRGB - case PIPE_FORMAT_A8L8_SRGB: - return MESA_FORMAT_SLA8; - case PIPE_FORMAT_L8_SRGB: - return MESA_FORMAT_SL8; - case PIPE_FORMAT_R8G8B8_SRGB: - return MESA_FORMAT_SRGB8; - case PIPE_FORMAT_R8G8B8A8_SRGB: - return MESA_FORMAT_SRGBA8; - case PIPE_FORMAT_A8R8G8B8_SRGB: - return MESA_FORMAT_SARGB8; -#endif - /* XXX add additional cases */ - default: - assert(0); - return MESA_FORMAT_NONE; - } -} - - /** * Called via ctx->Driver.chooseTextureFormat(). */ @@ -819,7 +669,7 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat, if (pFormat == PIPE_FORMAT_NONE) return MESA_FORMAT_NONE; - return translate_gallium_format_to_mesa_format(pFormat); + return st_pipe_format_to_mesa_format(pFormat); } @@ -830,11 +680,11 @@ GLboolean st_equal_formats(enum pipe_format pFormat, GLenum format, GLenum type) { switch (pFormat) { - case PIPE_FORMAT_R8G8B8A8_UNORM: + case PIPE_FORMAT_A8B8G8R8_UNORM: return format == GL_RGBA && type == GL_UNSIGNED_BYTE; - case PIPE_FORMAT_B8G8R8A8_UNORM: + case PIPE_FORMAT_A8R8G8B8_UNORM: return format == GL_BGRA && type == GL_UNSIGNED_BYTE; - case PIPE_FORMAT_R5G6B5_UNORM: + case PIPE_FORMAT_B5G6R5_UNORM: return format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5; /* XXX more combos... */ default: diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h index 7cddf5aa66a..a6cf7025a92 100644 --- a/src/mesa/state_tracker/st_format.h +++ b/src/mesa/state_tracker/st_format.h @@ -1,6 +1,7 @@ /************************************************************************** * * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright (c) 2010 VMware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -31,30 +32,6 @@ #include "main/formats.h" -struct pipe_format_info -{ - enum pipe_format format; - gl_format mesa_format; - GLenum datatype; - GLubyte red_bits; - GLubyte green_bits; - GLubyte blue_bits; - GLubyte alpha_bits; - GLubyte luminance_bits; - GLubyte intensity_bits; - GLubyte depth_bits; - GLubyte stencil_bits; - GLubyte size; /**< in bytes */ -}; - - -GLboolean -st_get_format_info(enum pipe_format format, struct pipe_format_info *pinfo); - - -extern GLuint -st_sizeof_format(enum pipe_format format); - extern GLenum st_format_datatype(enum pipe_format format); @@ -85,4 +62,4 @@ extern GLboolean st_equal_formats(enum pipe_format pFormat, GLenum format, GLenum type); -#endif /* ST_CB_TEXIMAGE_H */ +#endif /* ST_FORMAT_H */ diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c index 4e225a123c8..1d35e8d6574 100644 --- a/src/mesa/state_tracker/st_framebuffer.c +++ b/src/mesa/state_tracker/st_framebuffer.c @@ -160,6 +160,7 @@ void st_unreference_framebuffer( struct st_framebuffer *stfb ) * Set/replace a framebuffer surface. * The user of the state tracker can use this instead of * st_resize_framebuffer() to provide new surfaces when a window is resized. + * \param surfIndex an ST_SURFACE_x index */ void st_set_framebuffer_surface(struct st_framebuffer *stfb, @@ -170,6 +171,13 @@ st_set_framebuffer_surface(struct st_framebuffer *stfb, struct st_renderbuffer *strb; GLuint width, height, i; + /* sanity checks */ + assert(ST_SURFACE_FRONT_LEFT == BUFFER_FRONT_LEFT); + assert(ST_SURFACE_BACK_LEFT == BUFFER_BACK_LEFT); + assert(ST_SURFACE_FRONT_RIGHT == BUFFER_FRONT_RIGHT); + assert(ST_SURFACE_BACK_RIGHT == BUFFER_BACK_RIGHT); + assert(ST_SURFACE_DEPTH == BUFFER_DEPTH); + assert(surfIndex < BUFFER_COUNT); strb = st_renderbuffer(stfb->Base.Attachment[surfIndex].Renderbuffer); diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 537a6a86482..807d21a7197 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -1055,7 +1055,7 @@ out: /** - * Tokens cannot be free with _mesa_free otherwise the builtin gallium + * Tokens cannot be free with free otherwise the builtin gallium * malloc debugging will get confused. */ void diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 7ce3938904b..7f8677d400c 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -205,8 +205,10 @@ st_translate_vertex_program(struct st_context *st, unsigned num_outputs; ureg = ureg_create( TGSI_PROCESSOR_VERTEX ); - if (ureg == NULL) + if (ureg == NULL) { + FREE(vpv); return NULL; + } vpv->num_inputs = stvp->num_inputs; num_outputs = stvp->num_outputs; diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h index 98c19817c87..4b40d6d0448 100644 --- a/src/mesa/state_tracker/st_public.h +++ b/src/mesa/state_tracker/st_public.h @@ -34,12 +34,12 @@ #include "pipe/p_compiler.h" #include "pipe/p_format.h" - +/** Renderbuffer surfaces (should match Mesa names) */ #define ST_SURFACE_FRONT_LEFT 0 #define ST_SURFACE_BACK_LEFT 1 #define ST_SURFACE_FRONT_RIGHT 2 #define ST_SURFACE_BACK_RIGHT 3 -#define ST_SURFACE_DEPTH 8 +#define ST_SURFACE_DEPTH 4 #define ST_TEXTURE_2D 0x2 #define ST_TEXTURE_RECT 0x4 @@ -105,7 +105,8 @@ void st_unreference_framebuffer( struct st_framebuffer *stfb ); PUBLIC GLboolean st_make_current(struct st_context *st, struct st_framebuffer *draw, - struct st_framebuffer *read); + struct st_framebuffer *read, + void *winsys_drawable_handle); PUBLIC struct st_context *st_get_current(void); |