diff options
author | Dave Airlie <airlied@redhat.com> | 2009-04-09 10:14:35 +1000 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2009-04-09 10:31:08 +1000 |
commit | d1a9b1f513109c975a5a7ed5a2d0c329b280afe4 (patch) | |
tree | 5c85af47b4f5af0661acf129e3ce3f59e43cbfd9 /src/gallium/drivers/softpipe | |
parent | 90ffce497395d8c02fee2ea4ee4c025eede3d876 (diff) | |
parent | 8648c2685870174cf620ef15de70ef030a8d5a20 (diff) |
Merge remote branch 'origin/master' into radeon-rewrite
Conflicts:
src/mesa/drivers/dri/r200/r200_tex.c
src/mesa/drivers/dri/r300/r300_cmdbuf.c
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_swtcl.c
src/mesa/drivers/dri/r300/r300_tex.c
src/mesa/drivers/dri/r300/r300_texmem.c
src/mesa/drivers/dri/r300/r300_texstate.c
src/mesa/drivers/dri/radeon/radeon_tex.c
Diffstat (limited to 'src/gallium/drivers/softpipe')
-rw-r--r-- | src/gallium/drivers/softpipe/sp_clear.c | 70 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_clear.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_fs_exec.c | 17 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_fs_llvm.c | 14 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_fs_sse.c | 25 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_quad_fs.c | 21 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_setup.c | 27 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_surface.c | 1 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_texture.c | 7 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_tile_cache.c | 43 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_tile_cache.h | 3 |
11 files changed, 97 insertions, 135 deletions
diff --git a/src/gallium/drivers/softpipe/sp_clear.c b/src/gallium/drivers/softpipe/sp_clear.c index ad108ec446..fa59277438 100644 --- a/src/gallium/drivers/softpipe/sp_clear.c +++ b/src/gallium/drivers/softpipe/sp_clear.c @@ -2,6 +2,7 @@ * * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. * All Rights Reserved. + * Copyright 2009 VMware, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the @@ -27,6 +28,7 @@ /* Author: * Brian Paul + * Michel Dänzer */ @@ -40,34 +42,15 @@ /** - * Convert packed pixel from one format to another. - */ -static unsigned -convert_color(enum pipe_format srcFormat, unsigned srcColor, - enum pipe_format dstFormat) -{ - ubyte r, g, b, a; - unsigned dstColor; - - util_unpack_color_ub(srcFormat, &srcColor, &r, &g, &b, &a); - util_pack_color_ub(r, g, b, a, dstFormat, &dstColor); - - return dstColor; -} - - - -/** - * Clear the given surface to the specified value. + * Clear the given buffers to the specified values. * No masking, no scissor (clear entire buffer). - * Note: when clearing a color buffer, the clearValue is always - * encoded as PIPE_FORMAT_A8R8G8B8_UNORM. */ void -softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue) +softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba, + double depth, unsigned stencil) { struct softpipe_context *softpipe = softpipe_context(pipe); + unsigned cv; uint i; if (softpipe->no_rast) @@ -77,31 +60,30 @@ softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps, softpipe_update_derived(softpipe); /* not needed?? */ #endif - if (ps == sp_tile_cache_get_surface(softpipe->zsbuf_cache)) { - sp_tile_cache_clear(softpipe->zsbuf_cache, clearValue); - softpipe->framebuffer.zsbuf->status = PIPE_SURFACE_STATUS_CLEAR; -#if TILE_CLEAR_OPTIMIZATION - return; -#endif - } + if (buffers & PIPE_CLEAR_COLOR) { + for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) { + struct pipe_surface *ps = softpipe->framebuffer.cbufs[i]; - for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) { - if (ps == sp_tile_cache_get_surface(softpipe->cbuf_cache[i])) { - unsigned cv; - if (ps->format != PIPE_FORMAT_A8R8G8B8_UNORM) { - cv = convert_color(PIPE_FORMAT_A8R8G8B8_UNORM, clearValue, - ps->format); - } - else { - cv = clearValue; - } - sp_tile_cache_clear(softpipe->cbuf_cache[i], cv); - softpipe->framebuffer.cbufs[i]->status = PIPE_SURFACE_STATUS_CLEAR; + util_pack_color(rgba, ps->format, &cv); + sp_tile_cache_clear(softpipe->cbuf_cache[i], rgba, cv); + +#if !TILE_CLEAR_OPTIMIZATION + /* non-cached surface */ + pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, cv); +#endif } } + if (buffers & PIPE_CLEAR_DEPTHSTENCIL) { + static const float zero[4] = { 0.0F, 0.0F, 0.0F, 0.0F }; + struct pipe_surface *ps = softpipe->framebuffer.zsbuf; + + cv = util_pack_z_stencil(ps->format, depth, stencil); + sp_tile_cache_clear(softpipe->zsbuf_cache, zero, cv); + #if !TILE_CLEAR_OPTIMIZATION - /* non-cached surface */ - pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue); + /* non-cached surface */ + pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, cv); #endif + } } diff --git a/src/gallium/drivers/softpipe/sp_clear.h b/src/gallium/drivers/softpipe/sp_clear.h index a8ed1c4ecc..2e450672f5 100644 --- a/src/gallium/drivers/softpipe/sp_clear.h +++ b/src/gallium/drivers/softpipe/sp_clear.h @@ -36,8 +36,8 @@ struct pipe_context; extern void -softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps, - unsigned clearValue); +softpipe_clear(struct pipe_context *pipe, unsigned buffers, const float *rgba, + double depth, unsigned stencil); #endif /* SP_CLEAR_H */ diff --git a/src/gallium/drivers/softpipe/sp_fs_exec.c b/src/gallium/drivers/softpipe/sp_fs_exec.c index 0c14d92864..9ee86fe787 100644 --- a/src/gallium/drivers/softpipe/sp_fs_exec.c +++ b/src/gallium/drivers/softpipe/sp_fs_exec.c @@ -25,22 +25,29 @@ * **************************************************************************/ +/** + * Execute fragment shader using the TGSI interpreter. + */ #include "sp_context.h" #include "sp_state.h" #include "sp_fs.h" #include "sp_quad.h" - #include "pipe/p_state.h" #include "pipe/p_defines.h" #include "util/u_memory.h" #include "tgsi/tgsi_exec.h" #include "tgsi/tgsi_parse.h" + +/** + * Subclass of sp_fragment_shader + */ struct sp_exec_fragment_shader { struct sp_fragment_shader base; + /* No other members for now */ }; @@ -106,8 +113,6 @@ exec_prepare( const struct sp_fragment_shader *base, } - - /* TODO: hide the machine struct in here somewhere, remove from this * interface: */ @@ -116,7 +121,6 @@ exec_run( const struct sp_fragment_shader *base, struct tgsi_exec_machine *machine, struct quad_header *quad ) { - /* Compute X, Y, Z, W vals for this quad */ sp_setup_pos_vector(quad->posCoef, (float)quad->input.x0, (float)quad->input.y0, @@ -126,7 +130,6 @@ exec_run( const struct sp_fragment_shader *base, } - static void exec_delete( struct sp_fragment_shader *base ) { @@ -135,9 +138,6 @@ exec_delete( struct sp_fragment_shader *base ) } - - - struct sp_fragment_shader * softpipe_create_fs_exec(struct softpipe_context *softpipe, const struct pipe_shader_state *templ) @@ -160,4 +160,3 @@ softpipe_create_fs_exec(struct softpipe_context *softpipe, return &shader->base; } - diff --git a/src/gallium/drivers/softpipe/sp_fs_llvm.c b/src/gallium/drivers/softpipe/sp_fs_llvm.c index f33b3e3285..95c0d982d1 100644 --- a/src/gallium/drivers/softpipe/sp_fs_llvm.c +++ b/src/gallium/drivers/softpipe/sp_fs_llvm.c @@ -25,7 +25,9 @@ * **************************************************************************/ -/* Authors: +/** + * Execute fragment shader using LLVM code generation. + * Authors: * Zack Rusin */ @@ -33,7 +35,6 @@ #include "sp_state.h" #include "sp_fs.h" - #include "pipe/p_state.h" #include "pipe/p_defines.h" #include "util/u_memory.h" @@ -41,11 +42,16 @@ #if 0 -struct sp_llvm_fragment_shader { +/** + * Subclass of sp_fragment_shader + */ +struct sp_llvm_fragment_shader +{ struct sp_fragment_shader base; struct gallivm_prog *llvm_prog; }; + static void shade_quad_llvm(struct quad_stage *qs, struct quad_header *quad) @@ -160,7 +166,7 @@ delete_llvm_fs( struct sp_fragment_shader *base ) struct sp_fragment_shader * softpipe_create_fs_llvm(struct softpipe_context *softpipe, - const struct pipe_shader_state *templ) + const struct pipe_shader_state *templ) { struct sp_llvm_fragment_shader *shader = NULL; diff --git a/src/gallium/drivers/softpipe/sp_fs_sse.c b/src/gallium/drivers/softpipe/sp_fs_sse.c index 366abe2ed4..31c3ca21c5 100644 --- a/src/gallium/drivers/softpipe/sp_fs_sse.c +++ b/src/gallium/drivers/softpipe/sp_fs_sse.c @@ -25,13 +25,15 @@ * **************************************************************************/ +/** + * Execute fragment shader using runtime SSE code generation. + */ #include "sp_context.h" #include "sp_state.h" #include "sp_fs.h" #include "sp_quad.h" - #include "pipe/p_state.h" #include "pipe/p_defines.h" #include "util/u_memory.h" @@ -56,14 +58,25 @@ typedef void (PIPE_CDECL *codegen_function)( ); -struct sp_sse_fragment_shader { +/** + * Subclass of sp_fragment_shader + */ +struct sp_sse_fragment_shader +{ struct sp_fragment_shader base; - struct x86_function sse2_program; + struct x86_function sse2_program; codegen_function func; float immediates[TGSI_EXEC_NUM_IMMEDIATES][4]; }; +/** cast wrapper */ +static INLINE struct sp_sse_fragment_shader * +sp_sse_fragment_shader(const struct sp_fragment_shader *base) +{ + return (struct sp_sse_fragment_shader *) base; +} + static void fs_sse_prepare( const struct sp_fragment_shader *base, @@ -83,7 +96,7 @@ fs_sse_run( const struct sp_fragment_shader *base, struct tgsi_exec_machine *machine, struct quad_header *quad ) { - struct sp_sse_fragment_shader *shader = (struct sp_sse_fragment_shader *) base; + struct sp_sse_fragment_shader *shader = sp_sse_fragment_shader(base); /* Compute X, Y, Z, W vals for this quad -- place in temp[0] for now */ sp_setup_pos_vector(quad->posCoef, @@ -110,7 +123,7 @@ fs_sse_run( const struct sp_fragment_shader *base, static void fs_sse_delete( struct sp_fragment_shader *base ) { - struct sp_sse_fragment_shader *shader = (struct sp_sse_fragment_shader *) base; + struct sp_sse_fragment_shader *shader = sp_sse_fragment_shader(base); x86_release_func( &shader->sse2_program ); FREE(shader); @@ -156,7 +169,7 @@ softpipe_create_fs_sse(struct softpipe_context *softpipe, #else -/* Maybe put this varient in the header file. +/* Maybe put this variant in the header file. */ struct sp_fragment_shader * softpipe_create_fs_sse(struct softpipe_context *softpipe, diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c index adca5df73d..ca637a1d6a 100644 --- a/src/gallium/drivers/softpipe/sp_quad_fs.c +++ b/src/gallium/drivers/softpipe/sp_quad_fs.c @@ -65,14 +65,11 @@ quad_shade_stage(struct quad_stage *qs) } - /** * Execute fragment shader for the four fragments in the quad. */ static void -shade_quad( - struct quad_stage *qs, - struct quad_header *quad ) +shade_quad(struct quad_stage *qs, struct quad_header *quad) { struct quad_shade_stage *qss = quad_shade_stage( qs ); struct softpipe_context *softpipe = qs->softpipe; @@ -85,9 +82,7 @@ shade_quad( machine->InterpCoefs = quad->coef; /* run shader */ - quad->inout.mask &= softpipe->fs->run( softpipe->fs, - &qss->machine, - quad ); + quad->inout.mask &= softpipe->fs->run( softpipe->fs, machine, quad ); /* store outputs */ z_written = FALSE; @@ -135,15 +130,17 @@ shade_quad( } /* shader may cull fragments */ - if( quad->inout.mask ) { + if (quad->inout.mask) { qs->next->run( qs->next, quad ); } } + /** * Per-primitive (or per-begin?) setup */ -static void shade_begin(struct quad_stage *qs) +static void +shade_begin(struct quad_stage *qs) { struct quad_shade_stage *qss = quad_shade_stage(qs); struct softpipe_context *softpipe = qs->softpipe; @@ -157,7 +154,8 @@ static void shade_begin(struct quad_stage *qs) } -static void shade_destroy(struct quad_stage *qs) +static void +shade_destroy(struct quad_stage *qs) { struct quad_shade_stage *qss = (struct quad_shade_stage *) qs; @@ -168,7 +166,8 @@ static void shade_destroy(struct quad_stage *qs) } -struct quad_stage *sp_quad_shade_stage( struct softpipe_context *softpipe ) +struct quad_stage * +sp_quad_shade_stage( struct softpipe_context *softpipe ) { struct quad_shade_stage *qss = CALLOC_STRUCT(quad_shade_stage); diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c index 96cb09b905..accc692b66 100644 --- a/src/gallium/drivers/softpipe/sp_setup.c +++ b/src/gallium/drivers/softpipe/sp_setup.c @@ -252,16 +252,6 @@ static PIPE_THREAD_ROUTINE( quad_thread, param ) #endif -/** - * Test if x is NaN or +/- infinity. - */ -static INLINE boolean -is_inf_or_nan(float x) -{ - union fi tmp; - tmp.f = x; - return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31); -} /** @@ -506,6 +496,9 @@ static void print_vertex(const struct setup_context *setup, for (i = 0; i < setup->quad.nr_attrs; i++) { debug_printf(" %d: %f %f %f %f\n", i, v[i][0], v[i][1], v[i][2], v[i][3]); + if (util_is_inf_or_nan(v[i][0])) { + debug_printf(" NaN!\n"); + } } } #endif @@ -595,7 +588,7 @@ static boolean setup_sort_vertices( struct setup_context *setup, debug_printf("%s one-over-area %f area %f det %f\n", __FUNCTION__, setup->oneoverarea, area, det ); */ - if (is_inf_or_nan(setup->oneoverarea)) + if (util_is_inf_or_nan(setup->oneoverarea)) return FALSE; } @@ -1065,7 +1058,7 @@ setup_line_coefficients(struct setup_context *setup, /* NOTE: this is not really area but something proportional to it */ area = setup->emaj.dx * setup->emaj.dx + setup->emaj.dy * setup->emaj.dy; - if (area == 0.0f || is_inf_or_nan(area)) + if (area == 0.0f || util_is_inf_or_nan(area)) return FALSE; setup->oneoverarea = 1.0f / area; @@ -1489,16 +1482,6 @@ void setup_prepare( struct setup_context *setup ) softpipe_update_derived(sp); } - /* Mark surfaces as defined now */ - for (i = 0; i < sp->framebuffer.nr_cbufs; i++){ - if (sp->framebuffer.cbufs[i]) { - sp->framebuffer.cbufs[i]->status = PIPE_SURFACE_STATUS_DEFINED; - } - } - if (sp->framebuffer.zsbuf) { - sp->framebuffer.zsbuf->status = PIPE_SURFACE_STATUS_DEFINED; - } - /* Note: nr_attrs is only used for debugging (vertex printing) */ setup->quad.nr_attrs = draw_num_vs_outputs(sp->draw); diff --git a/src/gallium/drivers/softpipe/sp_surface.c b/src/gallium/drivers/softpipe/sp_surface.c index ef04843f17..b04c2a63ad 100644 --- a/src/gallium/drivers/softpipe/sp_surface.c +++ b/src/gallium/drivers/softpipe/sp_surface.c @@ -27,6 +27,7 @@ #include "util/u_rect.h" #include "sp_context.h" +#include "sp_surface.h" static void diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c index 48b2c22af4..c0113c47ad 100644 --- a/src/gallium/drivers/softpipe/sp_texture.c +++ b/src/gallium/drivers/softpipe/sp_texture.c @@ -138,7 +138,6 @@ softpipe_texture_create(struct pipe_screen *screen, goto fail; } - assert(p_atomic_read(&spt->base.reference.count) == 1); return &spt->base; fail: @@ -328,7 +327,7 @@ static void * softpipe_transfer_map( struct pipe_screen *screen, struct pipe_transfer *transfer ) { - ubyte *map; + ubyte *map, *xfer_map; struct softpipe_texture *spt; unsigned flags = 0; @@ -358,9 +357,11 @@ softpipe_transfer_map( struct pipe_screen *screen, softpipe_screen(screen)->timestamp++; } - return map + softpipe_transfer(transfer)->offset + + xfer_map = map + softpipe_transfer(transfer)->offset + transfer->y / transfer->block.height * transfer->stride + transfer->x / transfer->block.width * transfer->block.size; + /*printf("map = %p xfer map = %p\n", map, xfer_map);*/ + return xfer_map; } diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index 69292753f1..1f9b8f1f4f 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -57,9 +57,9 @@ struct softpipe_tile_cache struct pipe_texture *texture; /**< if caching a texture */ struct softpipe_cached_tile entries[NUM_ENTRIES]; uint clear_flags[(MAX_WIDTH / TILE_SIZE) * (MAX_HEIGHT / TILE_SIZE) / 32]; - float clear_color[4]; - uint clear_val; - boolean depth_stencil; /** Is the surface a depth/stencil format? */ + float clear_color[4]; /**< for color bufs */ + uint clear_val; /**< for z+stencil, or packed color clear value */ + boolean depth_stencil; /**< Is the surface a depth/stencil format? */ struct pipe_transfer *tex_trans; void *tex_trans_map; @@ -599,40 +599,17 @@ sp_get_cached_tile_tex(struct softpipe_context *sp, * Save the color and set a 'clearflag' for each tile of the screen. */ void -sp_tile_cache_clear(struct softpipe_tile_cache *tc, uint clearValue) +sp_tile_cache_clear(struct softpipe_tile_cache *tc, const float *rgba, + uint clearValue) { - uint r, g, b, a; uint pos; - tc->clear_val = clearValue; - - switch (tc->transfer->format) { - case PIPE_FORMAT_R8G8B8A8_UNORM: - r = (clearValue >> 24) & 0xff; - g = (clearValue >> 16) & 0xff; - b = (clearValue >> 8) & 0xff; - a = (clearValue ) & 0xff; - break; - case PIPE_FORMAT_A8R8G8B8_UNORM: - r = (clearValue >> 16) & 0xff; - g = (clearValue >> 8) & 0xff; - b = (clearValue ) & 0xff; - a = (clearValue >> 24) & 0xff; - break; - case PIPE_FORMAT_B8G8R8A8_UNORM: - r = (clearValue >> 8) & 0xff; - g = (clearValue >> 16) & 0xff; - b = (clearValue >> 24) & 0xff; - a = (clearValue ) & 0xff; - break; - default: - r = g = b = a = 0; - } + tc->clear_color[0] = rgba[0]; + tc->clear_color[1] = rgba[1]; + tc->clear_color[2] = rgba[2]; + tc->clear_color[3] = rgba[3]; - tc->clear_color[0] = r / 255.0f; - tc->clear_color[1] = g / 255.0f; - tc->clear_color[2] = b / 255.0f; - tc->clear_color[3] = a / 255.0f; + tc->clear_val = clearValue; #if TILE_CLEAR_OPTIMIZATION /* set flags to indicate all the tiles are cleared */ diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.h b/src/gallium/drivers/softpipe/sp_tile_cache.h index 9ac3fdda94..8f247d0e58 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.h +++ b/src/gallium/drivers/softpipe/sp_tile_cache.h @@ -89,7 +89,8 @@ sp_flush_tile_cache(struct softpipe_context *softpipe, struct softpipe_tile_cache *tc); extern void -sp_tile_cache_clear(struct softpipe_tile_cache *tc, uint clearValue); +sp_tile_cache_clear(struct softpipe_tile_cache *tc, const float *rgba, + uint clearValue); extern struct softpipe_cached_tile * sp_get_cached_tile(struct softpipe_context *softpipe, |