sp_quad.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  quad_stage

Functions

struct quad_stagesp_quad_polygon_stipple_stage (struct softpipe_context *softpipe)
struct quad_stagesp_quad_earlyz_stage (struct softpipe_context *softpipe)
struct quad_stagesp_quad_shade_stage (struct softpipe_context *softpipe)
struct quad_stagesp_quad_alpha_test_stage (struct softpipe_context *softpipe)
struct quad_stagesp_quad_stencil_test_stage (struct softpipe_context *softpipe)
struct quad_stagesp_quad_depth_test_stage (struct softpipe_context *softpipe)
struct quad_stagesp_quad_occlusion_stage (struct softpipe_context *softpipe)
struct quad_stagesp_quad_coverage_stage (struct softpipe_context *softpipe)
struct quad_stagesp_quad_blend_stage (struct softpipe_context *softpipe)
struct quad_stagesp_quad_colormask_stage (struct softpipe_context *softpipe)
struct quad_stagesp_quad_output_stage (struct softpipe_context *softpipe)
void sp_build_quad_pipeline (struct softpipe_context *sp)
void sp_depth_test_quad (struct quad_stage *qs, struct quad_header *quad)
 Quad depth testing.


Function Documentation

void sp_build_quad_pipeline ( struct softpipe_context sp  ) 

Definition at line 59 of file sp_quad.c.

References pipe_depth_stencil_alpha_state::alpha, softpipe_context::alpha_test, softpipe_context::blend, pipe_blend_state::blend_enable, softpipe_context::colormask, pipe_blend_state::colormask, softpipe_context::coverage, pipe_depth_stencil_alpha_state::depth, softpipe_context::depth_stencil, softpipe_context::earlyz, pipe_alpha_state::enabled, pipe_depth_state::enabled, softpipe_context::first, softpipe_context::framebuffer, softpipe_context::fs, sp_fragment_shader::info, pipe_rasterizer_state::line_smooth, pipe_blend_state::logicop_enable, softpipe_context::occlusion, pipe_depth_state::occlusion_count, softpipe_context::output, pipe_rasterizer_state::point_smooth, pipe_rasterizer_state::poly_smooth, pipe_rasterizer_state::poly_stipple_enable, softpipe_context::polygon_stipple, softpipe_context::quad, softpipe_context::rasterizer, softpipe_context::shade, sp_build_depth_stencil(), SP_NUM_QUAD_THREADS, sp_push_quad_first(), tgsi_shader_info::uses_kill, tgsi_shader_info::writes_z, and pipe_framebuffer_state::zsbuf.

00060 {
00061    uint i;
00062 
00063    boolean early_depth_test =
00064                sp->depth_stencil->depth.enabled &&
00065                sp->framebuffer.zsbuf &&
00066                !sp->depth_stencil->alpha.enabled &&
00067                !sp->fs->info.uses_kill &&
00068                !sp->fs->info.writes_z;
00069 
00070    /* build up the pipeline in reverse order... */
00071    for (i = 0; i < SP_NUM_QUAD_THREADS; i++) {
00072       sp->quad[i].first = sp->quad[i].output;
00073 
00074       if (sp->blend->colormask != 0xf) {
00075          sp_push_quad_first( sp, sp->quad[i].colormask, i );
00076       }
00077 
00078       if (sp->blend->blend_enable ||
00079           sp->blend->logicop_enable) {
00080          sp_push_quad_first( sp, sp->quad[i].blend, i );
00081       }
00082 
00083       if (sp->depth_stencil->depth.occlusion_count) {
00084          sp_push_quad_first( sp, sp->quad[i].occlusion, i );
00085       }
00086 
00087       if (sp->rasterizer->poly_smooth ||
00088           sp->rasterizer->line_smooth ||
00089           sp->rasterizer->point_smooth) {
00090          sp_push_quad_first( sp, sp->quad[i].coverage, i );
00091       }
00092 
00093       if (!early_depth_test) {
00094          sp_build_depth_stencil( sp, i );
00095       }
00096 
00097       if (sp->depth_stencil->alpha.enabled) {
00098          sp_push_quad_first( sp, sp->quad[i].alpha_test, i );
00099       }
00100 
00101       /* XXX always enable shader? */
00102       if (1) {
00103          sp_push_quad_first( sp, sp->quad[i].shade, i );
00104       }
00105 
00106       if (early_depth_test) {
00107          sp_build_depth_stencil( sp, i );
00108          sp_push_quad_first( sp, sp->quad[i].earlyz, i );
00109       }
00110 
00111 #if !USE_DRAW_STAGE_PSTIPPLE
00112       if (sp->rasterizer->poly_stipple_enable) {
00113          sp_push_quad_first( sp, sp->quad[i].polygon_stipple, i );
00114       }
00115 #endif
00116    }
00117 }

void sp_depth_test_quad ( struct quad_stage qs,
struct quad_header quad 
)

Quad depth testing.

Do depth testing for a quad. Not static since it's used by the stencil code.

< Z values fetched from depth buffer

< Z values from the quad

Definition at line 53 of file sp_quad_depth_test.c.

References assert, softpipe_cached_tile::data, pipe_depth_stencil_alpha_state::depth, quad_header_output::depth, softpipe_cached_tile::depth16, softpipe_cached_tile::depth32, softpipe_context::depth_stencil, pipe_surface::format, softpipe_context::framebuffer, pipe_depth_state::func, quad_header::inout, quad_header::input, quad_header_inout::mask, MASK_ALL, quad_header::output, PIPE_FORMAT_S8Z24_UNORM, PIPE_FORMAT_X8Z24_UNORM, PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_Z24S8_UNORM, PIPE_FORMAT_Z24X8_UNORM, PIPE_FORMAT_Z32_UNORM, PIPE_FUNC_ALWAYS, PIPE_FUNC_EQUAL, PIPE_FUNC_GEQUAL, PIPE_FUNC_GREATER, PIPE_FUNC_LEQUAL, PIPE_FUNC_LESS, PIPE_FUNC_NEVER, PIPE_FUNC_NOTEQUAL, QUAD_SIZE, quad_stage::softpipe, sp_get_cached_tile(), TILE_SIZE, pipe_depth_state::writemask, softpipe_cached_tile::x, quad_header_input::x0, softpipe_cached_tile::y, quad_header_input::y0, pipe_framebuffer_state::zsbuf, and softpipe_context::zsbuf_cache.

00054 {
00055    struct softpipe_context *softpipe = qs->softpipe;
00056    struct pipe_surface *ps = softpipe->framebuffer.zsbuf;
00057    const enum pipe_format format = ps->format;
00058    unsigned bzzzz[QUAD_SIZE];  
00059    unsigned qzzzz[QUAD_SIZE];  
00060    unsigned zmask = 0;
00061    unsigned j;
00062    struct softpipe_cached_tile *tile
00063       = sp_get_cached_tile(softpipe, softpipe->zsbuf_cache, quad->input.x0, quad->input.y0);
00064 
00065    assert(ps); /* shouldn't get here if there's no zbuffer */
00066 
00067    /*
00068     * Convert quad's float depth values to int depth values (qzzzz).
00069     * If the Z buffer stores integer values, we _have_ to do the depth
00070     * compares with integers (not floats).  Otherwise, the float->int->float
00071     * conversion of Z values (which isn't an identity function) will cause
00072     * Z-fighting errors.
00073     *
00074     * Also, get the zbuffer values (bzzzz) from the cached tile.
00075     */
00076    switch (format) {
00077    case PIPE_FORMAT_Z16_UNORM:
00078       {
00079          float scale = 65535.0;
00080 
00081          for (j = 0; j < QUAD_SIZE; j++) {
00082             qzzzz[j] = (unsigned) (quad->output.depth[j] * scale);
00083          }
00084 
00085          for (j = 0; j < QUAD_SIZE; j++) {
00086             int x = quad->input.x0 % TILE_SIZE + (j & 1);
00087             int y = quad->input.y0 % TILE_SIZE + (j >> 1);
00088             bzzzz[j] = tile->data.depth16[y][x];
00089          }
00090       }
00091       break;
00092    case PIPE_FORMAT_Z32_UNORM:
00093       {
00094          double scale = (double) (uint) ~0UL;
00095 
00096          for (j = 0; j < QUAD_SIZE; j++) {
00097             qzzzz[j] = (unsigned) (quad->output.depth[j] * scale);
00098          }
00099 
00100          for (j = 0; j < QUAD_SIZE; j++) {
00101             int x = quad->input.x0 % TILE_SIZE + (j & 1);
00102             int y = quad->input.y0 % TILE_SIZE + (j >> 1);
00103             bzzzz[j] = tile->data.depth32[y][x];
00104          }
00105       }
00106       break;
00107    case PIPE_FORMAT_X8Z24_UNORM:
00108       /* fall-through */
00109    case PIPE_FORMAT_S8Z24_UNORM:
00110       {
00111          float scale = (float) ((1 << 24) - 1);
00112 
00113          for (j = 0; j < QUAD_SIZE; j++) {
00114             qzzzz[j] = (unsigned) (quad->output.depth[j] * scale);
00115          }
00116 
00117          for (j = 0; j < QUAD_SIZE; j++) {
00118             int x = quad->input.x0 % TILE_SIZE + (j & 1);
00119             int y = quad->input.y0 % TILE_SIZE + (j >> 1);
00120             bzzzz[j] = tile->data.depth32[y][x] & 0xffffff;
00121          }
00122       }
00123       break;
00124    case PIPE_FORMAT_Z24X8_UNORM:
00125       /* fall-through */
00126    case PIPE_FORMAT_Z24S8_UNORM:
00127       {
00128          float scale = (float) ((1 << 24) - 1);
00129 
00130          for (j = 0; j < QUAD_SIZE; j++) {
00131             qzzzz[j] = (unsigned) (quad->output.depth[j] * scale);
00132          }
00133 
00134          for (j = 0; j < QUAD_SIZE; j++) {
00135             int x = quad->input.x0 % TILE_SIZE + (j & 1);
00136             int y = quad->input.y0 % TILE_SIZE + (j >> 1);
00137             bzzzz[j] = tile->data.depth32[y][x] >> 8;
00138          }
00139       }
00140       break;
00141    default:
00142       assert(0);
00143    }
00144 
00145    switch (softpipe->depth_stencil->depth.func) {
00146    case PIPE_FUNC_NEVER:
00147       /* zmask = 0 */
00148       break;
00149    case PIPE_FUNC_LESS:
00150       /* Note this is pretty much a single sse or cell instruction.  
00151        * Like this:  quad->mask &= (quad->outputs.depth < zzzz);
00152        */
00153       for (j = 0; j < QUAD_SIZE; j++) {
00154          if (qzzzz[j] < bzzzz[j]) 
00155             zmask |= 1 << j;
00156       }
00157       break;
00158    case PIPE_FUNC_EQUAL:
00159       for (j = 0; j < QUAD_SIZE; j++) {
00160          if (qzzzz[j] == bzzzz[j]) 
00161             zmask |= 1 << j;
00162       }
00163       break;
00164    case PIPE_FUNC_LEQUAL:
00165       for (j = 0; j < QUAD_SIZE; j++) {
00166          if (qzzzz[j] <= bzzzz[j]) 
00167             zmask |= (1 << j);
00168       }
00169       break;
00170    case PIPE_FUNC_GREATER:
00171       for (j = 0; j < QUAD_SIZE; j++) {
00172          if (qzzzz[j] > bzzzz[j]) 
00173             zmask |= (1 << j);
00174       }
00175       break;
00176    case PIPE_FUNC_NOTEQUAL:
00177       for (j = 0; j < QUAD_SIZE; j++) {
00178          if (qzzzz[j] != bzzzz[j]) 
00179             zmask |= (1 << j);
00180       }
00181       break;
00182    case PIPE_FUNC_GEQUAL:
00183       for (j = 0; j < QUAD_SIZE; j++) {
00184          if (qzzzz[j] >= bzzzz[j]) 
00185             zmask |= (1 << j);
00186       }
00187       break;
00188    case PIPE_FUNC_ALWAYS:
00189       zmask = MASK_ALL;
00190       break;
00191    default:
00192       assert(0);
00193    }
00194 
00195    quad->inout.mask &= zmask;
00196 
00197    if (softpipe->depth_stencil->depth.writemask) {
00198       
00199       /* This is also efficient with sse / spe instructions: 
00200        */
00201       for (j = 0; j < QUAD_SIZE; j++) {
00202          if (quad->inout.mask & (1 << j)) {
00203             bzzzz[j] = qzzzz[j];
00204          }
00205       }
00206 
00207       /* put updated Z values back into cached tile */
00208       switch (format) {
00209       case PIPE_FORMAT_Z16_UNORM:
00210          for (j = 0; j < QUAD_SIZE; j++) {
00211             int x = quad->input.x0 % TILE_SIZE + (j & 1);
00212             int y = quad->input.y0 % TILE_SIZE + (j >> 1);
00213             tile->data.depth16[y][x] = (ushort) bzzzz[j];
00214          }
00215          break;
00216       case PIPE_FORMAT_X8Z24_UNORM:
00217          /* fall-through */
00218          /* (yes, this falls through to a different case than above) */
00219       case PIPE_FORMAT_Z32_UNORM:
00220          for (j = 0; j < QUAD_SIZE; j++) {
00221             int x = quad->input.x0 % TILE_SIZE + (j & 1);
00222             int y = quad->input.y0 % TILE_SIZE + (j >> 1);
00223             tile->data.depth32[y][x] = bzzzz[j];
00224          }
00225          break;
00226       case PIPE_FORMAT_S8Z24_UNORM:
00227          for (j = 0; j < QUAD_SIZE; j++) {
00228             int x = quad->input.x0 % TILE_SIZE + (j & 1);
00229             int y = quad->input.y0 % TILE_SIZE + (j >> 1);
00230             uint s8z24 = tile->data.depth32[y][x];
00231             s8z24 = (s8z24 & 0xff000000) | bzzzz[j];
00232             tile->data.depth32[y][x] = s8z24;
00233          }
00234          break;
00235       case PIPE_FORMAT_Z24S8_UNORM:
00236          for (j = 0; j < QUAD_SIZE; j++) {
00237             int x = quad->input.x0 % TILE_SIZE + (j & 1);
00238             int y = quad->input.y0 % TILE_SIZE + (j >> 1);
00239             uint z24s8 = tile->data.depth32[y][x];
00240             z24s8 = (z24s8 & 0xff) | (bzzzz[j] << 8);
00241             tile->data.depth32[y][x] = z24s8;
00242          }
00243          break;
00244       case PIPE_FORMAT_Z24X8_UNORM:
00245          for (j = 0; j < QUAD_SIZE; j++) {
00246             int x = quad->input.x0 % TILE_SIZE + (j & 1);
00247             int y = quad->input.y0 % TILE_SIZE + (j >> 1);
00248             tile->data.depth32[y][x] = bzzzz[j] << 8;
00249          }
00250          break;
00251       default:
00252          assert(0);
00253       }
00254    }
00255 }

struct quad_stage* sp_quad_alpha_test_stage ( struct softpipe_context softpipe  )  [read]

Definition at line 98 of file sp_quad_alpha_test.c.

References alpha_test_begin(), alpha_test_destroy(), alpha_test_quad(), quad_stage::begin, CALLOC_STRUCT, quad_stage::destroy, quad_stage::run, and quad_stage::softpipe.

00099 {
00100    struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
00101 
00102    stage->softpipe = softpipe;
00103    stage->begin = alpha_test_begin;
00104    stage->run = alpha_test_quad;
00105    stage->destroy = alpha_test_destroy;
00106 
00107    return stage;
00108 }

struct quad_stage* sp_quad_blend_stage ( struct softpipe_context softpipe  )  [read]

Definition at line 749 of file sp_quad_blend.c.

References quad_stage::begin, blend_begin(), blend_destroy(), blend_quad(), CALLOC_STRUCT, quad_stage::destroy, quad_stage::run, and quad_stage::softpipe.

00750 {
00751    struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
00752 
00753    stage->softpipe = softpipe;
00754    stage->begin = blend_begin;
00755    stage->run = blend_quad;
00756    stage->destroy = blend_destroy;
00757 
00758    return stage;
00759 }

struct quad_stage* sp_quad_colormask_stage ( struct softpipe_context softpipe  )  [read]

Definition at line 106 of file sp_quad_colormask.c.

References quad_stage::begin, CALLOC_STRUCT, colormask_begin(), colormask_destroy(), colormask_quad(), quad_stage::destroy, quad_stage::run, and quad_stage::softpipe.

00107 {
00108    struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
00109 
00110    stage->softpipe = softpipe;
00111    stage->begin = colormask_begin;
00112    stage->run = colormask_quad;
00113    stage->destroy = colormask_destroy;
00114 
00115    return stage;
00116 }

struct quad_stage* sp_quad_coverage_stage ( struct softpipe_context softpipe  )  [read]

Definition at line 83 of file sp_quad_coverage.c.

References quad_stage::begin, CALLOC_STRUCT, coverage_begin(), coverage_destroy(), coverage_quad(), quad_stage::destroy, quad_stage::run, and quad_stage::softpipe.

00084 {
00085    struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
00086 
00087    stage->softpipe = softpipe;
00088    stage->begin = coverage_begin;
00089    stage->run = coverage_quad;
00090    stage->destroy = coverage_destroy;
00091 
00092    return stage;
00093 }

struct quad_stage* sp_quad_depth_test_stage ( struct softpipe_context softpipe  )  [read]

Definition at line 280 of file sp_quad_depth_test.c.

References quad_stage::begin, CALLOC_STRUCT, depth_test_begin(), depth_test_destroy(), depth_test_quad(), quad_stage::destroy, quad_stage::run, and quad_stage::softpipe.

00281 {
00282    struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
00283 
00284    stage->softpipe = softpipe;
00285    stage->begin = depth_test_begin;
00286    stage->run = depth_test_quad;
00287    stage->destroy = depth_test_destroy;
00288 
00289    return stage;
00290 }

struct quad_stage* sp_quad_earlyz_stage ( struct softpipe_context softpipe  )  [read]

Definition at line 77 of file sp_quad_earlyz.c.

References quad_stage::begin, CALLOC_STRUCT, quad_stage::destroy, earlyz_begin(), earlyz_destroy(), earlyz_quad(), quad_stage::run, and quad_stage::softpipe.

00079 {
00080    struct quad_stage *stage = CALLOC_STRUCT( quad_stage );
00081 
00082    stage->softpipe = softpipe;
00083    stage->begin = earlyz_begin;
00084    stage->run = earlyz_quad;
00085    stage->destroy = earlyz_destroy;
00086 
00087    return stage;
00088 }

struct quad_stage* sp_quad_occlusion_stage ( struct softpipe_context softpipe  )  [read]

Definition at line 75 of file sp_quad_occlusion.c.

References quad_stage::begin, CALLOC_STRUCT, quad_stage::destroy, occlusion_begin(), occlusion_count_quad(), occlusion_destroy(), quad_stage::run, and quad_stage::softpipe.

00076 {
00077    struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
00078 
00079    stage->softpipe = softpipe;
00080    stage->begin = occlusion_begin;
00081    stage->run = occlusion_count_quad;
00082    stage->destroy = occlusion_destroy;
00083 
00084    return stage;
00085 }

struct quad_stage* sp_quad_output_stage ( struct softpipe_context softpipe  )  [read]

Definition at line 93 of file sp_quad_output.c.

References quad_stage::begin, CALLOC_STRUCT, quad_stage::destroy, output_begin(), output_destroy(), output_quad(), quad_stage::run, and quad_stage::softpipe.

00094 {
00095    struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
00096 
00097    stage->softpipe = softpipe;
00098    stage->begin = output_begin;
00099    stage->run = output_quad;
00100    stage->destroy = output_destroy;
00101 
00102    return stage;
00103 }

struct quad_stage* sp_quad_polygon_stipple_stage ( struct softpipe_context softpipe  )  [read]

Definition at line 83 of file sp_quad_stipple.c.

References quad_stage::begin, CALLOC_STRUCT, quad_stage::destroy, quad_stage::run, quad_stage::softpipe, stipple_begin(), stipple_destroy(), and stipple_quad().

00085 {
00086    struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
00087 
00088    stage->softpipe = softpipe;
00089    stage->begin = stipple_begin;
00090    stage->run = stipple_quad;
00091    stage->destroy = stipple_destroy;
00092 
00093    return stage;

struct quad_stage* sp_quad_shade_stage ( struct softpipe_context softpipe  )  [read]

Definition at line 178 of file sp_quad_fs.c.

References align16(), assert, quad_stage::begin, tgsi_sampler::cache, CALLOC_STRUCT, quad_stage::destroy, tgsi_sampler::get_samples, tgsi_exec_machine::Inputs, quad_shade_stage::inputs, quad_shade_stage::machine, MALLOC, tgsi_exec_machine::Outputs, quad_shade_stage::outputs, softpipe_context::pipe, tgsi_sampler::pipe, PIPE_MAX_ATTRIBS, PIPE_MAX_SAMPLERS, quad_stage::run, quad_shade_stage::samplers, shade_begin(), shade_destroy(), shade_quad(), quad_stage::softpipe, sp_get_samples(), quad_shade_stage::stage, softpipe_context::tex_cache, and tgsi_exec_machine_init().

00179 {
00180    struct quad_shade_stage *qss = CALLOC_STRUCT(quad_shade_stage);
00181    uint i;
00182 
00183    /* allocate storage for program inputs/outputs, aligned to 16 bytes */
00184    qss->inputs = MALLOC(PIPE_MAX_ATTRIBS * sizeof(*qss->inputs) + 16);
00185    qss->outputs = MALLOC(PIPE_MAX_ATTRIBS * sizeof(*qss->outputs) + 16);
00186    qss->machine.Inputs = align16(qss->inputs);
00187    qss->machine.Outputs = align16(qss->outputs);
00188 
00189    qss->stage.softpipe = softpipe;
00190    qss->stage.begin = shade_begin;
00191    qss->stage.run = shade_quad;
00192    qss->stage.destroy = shade_destroy;
00193 
00194    /* set TGSI sampler state that's constant */
00195    for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
00196       assert(softpipe->tex_cache[i]);
00197       qss->samplers[i].get_samples = sp_get_samples;
00198       qss->samplers[i].pipe = &softpipe->pipe;
00199       qss->samplers[i].cache = softpipe->tex_cache[i];
00200    }
00201 
00202    tgsi_exec_machine_init( &qss->machine );
00203 
00204    return &qss->stage;
00205 }

struct quad_stage* sp_quad_stencil_test_stage ( struct softpipe_context softpipe  )  [read]

Definition at line 342 of file sp_quad_stencil.c.

References quad_stage::begin, CALLOC_STRUCT, quad_stage::destroy, quad_stage::run, quad_stage::softpipe, stencil_begin(), stencil_destroy(), and stencil_test_quad().

00343 {
00344    struct quad_stage *stage = CALLOC_STRUCT(quad_stage);
00345 
00346    stage->softpipe = softpipe;
00347    stage->begin = stencil_begin;
00348    stage->run = stencil_test_quad;
00349    stage->destroy = stencil_destroy;
00350 
00351    return stage;
00352 }


Generated on Tue Sep 29 06:25:40 2009 for Gallium3D by  doxygen 1.5.4