brw_wm.c File Reference

Include dependency graph for brw_wm.c:

Go to the source code of this file.

Functions

static void do_wm_prog (struct brw_context *brw, struct brw_fragment_program *fp, struct brw_wm_prog_key *key)
static void brw_wm_populate_key (struct brw_context *brw, struct brw_wm_prog_key *key)
static void brw_upload_wm_prog (struct brw_context *brw)

Variables

struct brw_tracked_state brw_wm_prog


Function Documentation

static void brw_upload_wm_prog ( struct brw_context brw  )  [static]

Definition at line 181 of file brw_wm.c.

References brw_context::attribs, brw_search_cache(), brw_wm_populate_key(), BRW_WM_PROG, brw_context::cache, do_wm_prog(), brw_context::FragmentProgram, brw_context::prog_data, brw_context::prog_gs_offset, and brw_context::wm.

00182 {
00183    struct brw_wm_prog_key key;
00184    struct brw_fragment_program *fp = (struct brw_fragment_program *)
00185       brw->attribs.FragmentProgram;
00186 
00187    brw_wm_populate_key(brw, &key);
00188 
00189    /* Make an early check for the key.
00190     */
00191    if (brw_search_cache(&brw->cache[BRW_WM_PROG],
00192                         &key, sizeof(key),
00193                         &brw->wm.prog_data,
00194                         &brw->wm.prog_gs_offset))
00195       return;
00196 
00197    do_wm_prog(brw, fp, &key);
00198 }

static void brw_wm_populate_key ( struct brw_context brw,
struct brw_wm_prog_key key 
) [static]

Definition at line 83 of file brw_wm.c.

References AA_ALWAYS, AA_NEVER, AA_SOMETIMES, pipe_depth_stencil_alpha_state::alpha, brw_context::attribs, BRW_MAX_TEX_UNIT, brw_wm_lookup_iz(), pipe_sampler_state::compare_mode, pipe_rasterizer_state::cull_mode, pipe_depth_stencil_alpha_state::depth, brw_context::DepthStencil, pipe_stencil_state::enabled, pipe_depth_state::enabled, pipe_alpha_state::enabled, pipe_rasterizer_state::fill_ccw, pipe_rasterizer_state::fill_cw, brw_context::FragmentProgram, brw_fragment_program::id, brw_fragment_program::info, IZ_DEPTH_TEST_ENABLE_BIT, IZ_DEPTH_WRITE_ENABLE_BIT, IZ_EARLY_DEPTH_TEST_BIT, IZ_PS_COMPUTES_DEPTH_BIT, IZ_PS_KILL_ALPHATEST_BIT, IZ_STENCIL_TEST_ENABLE_BIT, IZ_STENCIL_WRITE_ENABLE_BIT, pipe_rasterizer_state::line_smooth, PIPE_POLYGON_MODE_LINE, PIPE_PRIM_LINES, PIPE_PRIM_TRIANGLES, PIPE_TEX_COMPARE_R_TO_TEXTURE, PIPE_WINDING_CCW, PIPE_WINDING_CW, brw_wm_prog_key::program_string_id, brw_context::Raster, brw_context::reduced_primitive, brw_context::Samplers, brw_wm_prog_key::shadowtex_mask, pipe_depth_stencil_alpha_state::stencil, tgsi_shader_info::uses_kill, pipe_stencil_state::write_mask, pipe_depth_state::writemask, tgsi_shader_info::writes_z, and brw_wm_prog_key::yuvtex_mask.

00085 {
00086    /* BRW_NEW_FRAGMENT_PROGRAM */
00087    struct brw_fragment_program *fp =
00088       (struct brw_fragment_program *)brw->attribs.FragmentProgram;
00089    unsigned lookup = 0;
00090    unsigned line_aa;
00091    
00092    memset(key, 0, sizeof(*key));
00093 
00094    /* Build the index for table lookup
00095     */
00096    /* BRW_NEW_DEPTH_STENCIL */
00097    if (fp->info.uses_kill ||
00098        brw->attribs.DepthStencil->alpha.enabled)
00099       lookup |= IZ_PS_KILL_ALPHATEST_BIT;
00100 
00101    if (fp->info.writes_z)
00102       lookup |= IZ_PS_COMPUTES_DEPTH_BIT;
00103 
00104    if (brw->attribs.DepthStencil->depth.enabled)
00105       lookup |= IZ_DEPTH_TEST_ENABLE_BIT;
00106 
00107    if (brw->attribs.DepthStencil->depth.enabled &&
00108        brw->attribs.DepthStencil->depth.writemask) /* ?? */
00109       lookup |= IZ_DEPTH_WRITE_ENABLE_BIT;
00110 
00111    if (brw->attribs.DepthStencil->stencil[0].enabled) {
00112       lookup |= IZ_STENCIL_TEST_ENABLE_BIT;
00113 
00114       if (brw->attribs.DepthStencil->stencil[0].write_mask ||
00115           brw->attribs.DepthStencil->stencil[1].write_mask)
00116          lookup |= IZ_STENCIL_WRITE_ENABLE_BIT;
00117    }
00118 
00119    /* XXX: when should this be disabled?
00120     */
00121    if (1)
00122       lookup |= IZ_EARLY_DEPTH_TEST_BIT;
00123 
00124 
00125    line_aa = AA_NEVER;
00126 
00127    /* _NEW_LINE, _NEW_POLYGON, BRW_NEW_REDUCED_PRIMITIVE */
00128    if (brw->attribs.Raster->line_smooth) {
00129       if (brw->reduced_primitive == PIPE_PRIM_LINES) {
00130          line_aa = AA_ALWAYS;
00131       }
00132       else if (brw->reduced_primitive == PIPE_PRIM_TRIANGLES) {
00133          if (brw->attribs.Raster->fill_ccw == PIPE_POLYGON_MODE_LINE) {
00134             line_aa = AA_SOMETIMES;
00135 
00136             if (brw->attribs.Raster->fill_cw == PIPE_POLYGON_MODE_LINE ||
00137                 (brw->attribs.Raster->cull_mode == PIPE_WINDING_CW))
00138                line_aa = AA_ALWAYS;
00139          }
00140          else if (brw->attribs.Raster->fill_cw == PIPE_POLYGON_MODE_LINE) {
00141             line_aa = AA_SOMETIMES;
00142 
00143             if (brw->attribs.Raster->cull_mode == PIPE_WINDING_CCW)
00144                line_aa = AA_ALWAYS;
00145          }
00146       }
00147    }
00148 
00149    brw_wm_lookup_iz(line_aa,
00150                     lookup,
00151                     key);
00152 
00153 
00154 #if 0
00155    /* BRW_NEW_SAMPLER 
00156     *
00157     * Not doing any of this at the moment:
00158     */
00159    for (i = 0; i < BRW_MAX_TEX_UNIT; i++) {
00160       const struct pipe_sampler_state *unit = brw->attribs.Samplers[i];
00161 
00162       if (unit) {
00163 
00164          if (unit->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
00165             key->shadowtex_mask |= 1<<i;
00166          }
00167          if (t->Image[0][t->BaseLevel]->InternalFormat == GL_YCBCR_MESA)
00168             key->yuvtex_mask |= 1<<i;
00169       }
00170    }
00171 #endif
00172 
00173 
00174    /* Extra info:
00175     */
00176    key->program_string_id = fp->id;
00177 
00178 }

static void do_wm_prog ( struct brw_context brw,
struct brw_fragment_program fp,
struct brw_wm_prog_key key 
) [static]

Definition at line 42 of file brw_wm.c.

References brw_get_program(), brw_null_reg(), brw_upload_cache(), brw_wm_glsl_emit(), BRW_WM_PROG, brw_context::cache, CALLOC_STRUCT, debug_printf(), brw_wm_compile::delta_xy, brw_wm_compile::fp, FREE, brw_wm_compile::func, brw_wm_compile::key, brw_wm_compile::pixel_w, brw_wm_compile::pixel_xy, brw_context::prog_data, brw_wm_compile::prog_data, brw_context::prog_gs_offset, and brw_context::wm.

00045 {
00046    struct brw_wm_compile *c = CALLOC_STRUCT(brw_wm_compile);
00047    const unsigned *program;
00048    unsigned program_size;
00049 
00050    c->key = *key;
00051    c->fp = fp;
00052    
00053    c->delta_xy[0] = brw_null_reg();
00054    c->delta_xy[1] = brw_null_reg();
00055    c->pixel_xy[0] = brw_null_reg();
00056    c->pixel_xy[1] = brw_null_reg();
00057    c->pixel_w = brw_null_reg();
00058 
00059 
00060    debug_printf("XXXXXXXX FP\n");
00061    
00062    brw_wm_glsl_emit(c);
00063 
00064    /* get the program
00065     */
00066    program = brw_get_program(&c->func, &program_size);
00067 
00068    /*
00069     */
00070    brw->wm.prog_gs_offset = brw_upload_cache( &brw->cache[BRW_WM_PROG],
00071                                               &c->key,
00072                                               sizeof(c->key),
00073                                               program,
00074                                               program_size,
00075                                               &c->prog_data,
00076                                               &brw->wm.prog_data );
00077 
00078    FREE(c);
00079 }


Variable Documentation

struct brw_tracked_state brw_wm_prog

Initial value:

 {
   .dirty = {
      .brw   = ( 0x4  |
                 0x80000 ),
      .cache = 0
   },
   .update = brw_upload_wm_prog
}

Definition at line 201 of file brw_wm.c.


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