sp_fs_exec.c File Reference

Include dependency graph for sp_fs_exec.c:

Go to the source code of this file.

Data Structures

struct  sp_exec_fragment_shader

Functions

void sp_setup_pos_vector (const struct tgsi_interp_coef *coef, float x, float y, struct tgsi_exec_vector *quadpos)
 Compute quad X,Y,Z,W for the four fragments in a quad.
static void exec_prepare (const struct sp_fragment_shader *base, struct tgsi_exec_machine *machine, struct tgsi_sampler *samplers)
static unsigned exec_run (const struct sp_fragment_shader *base, struct tgsi_exec_machine *machine, struct quad_header *quad)
static void exec_delete (struct sp_fragment_shader *base)
struct sp_fragment_shadersoftpipe_create_fs_exec (struct softpipe_context *softpipe, const struct pipe_shader_state *templ)


Function Documentation

static void exec_delete ( struct sp_fragment_shader base  )  [static]

Definition at line 118 of file sp_fs_exec.c.

References FREE, sp_fragment_shader::shader, and pipe_shader_state::tokens.

00119 {
00120    FREE((void *) base->shader.tokens);
00121    FREE(base);
00122 }

static void exec_prepare ( const struct sp_fragment_shader base,
struct tgsi_exec_machine machine,
struct tgsi_sampler samplers 
) [static]

Definition at line 85 of file sp_fs_exec.c.

References PIPE_MAX_SAMPLERS, sp_fragment_shader::shader, tgsi_exec_machine_bind_shader(), and pipe_shader_state::tokens.

00088 {
00089    tgsi_exec_machine_bind_shader( machine,
00090                                   base->shader.tokens,
00091                                   PIPE_MAX_SAMPLERS,
00092                                   samplers );
00093 }

static unsigned exec_run ( const struct sp_fragment_shader base,
struct tgsi_exec_machine machine,
struct quad_header quad 
) [static]

Definition at line 102 of file sp_fs_exec.c.

References quad_header::input, quad_header::posCoef, tgsi_exec_machine::QuadPos, sp_setup_pos_vector(), tgsi_exec_machine_run(), quad_header_input::x0, and quad_header_input::y0.

00105 {
00106 
00107    /* Compute X, Y, Z, W vals for this quad */
00108    sp_setup_pos_vector(quad->posCoef, 
00109                        (float)quad->input.x0, (float)quad->input.y0, 
00110                        &machine->QuadPos);
00111    
00112    return tgsi_exec_machine_run( machine );
00113 }

struct sp_fragment_shader* softpipe_create_fs_exec ( struct softpipe_context softpipe,
const struct pipe_shader_state templ 
) [read]

Definition at line 129 of file sp_fs_exec.c.

References sp_exec_fragment_shader::base, CALLOC_STRUCT, sp_fragment_shader::delete, exec_delete(), exec_prepare(), exec_run(), sp_fragment_shader::prepare, sp_fragment_shader::run, sp_fragment_shader::shader, tgsi_dup_tokens(), and pipe_shader_state::tokens.

00131 {
00132    struct sp_exec_fragment_shader *shader;
00133 
00134    /* Decide whether we'll be codegenerating this shader and if so do
00135     * that now.
00136     */
00137 
00138    shader = CALLOC_STRUCT(sp_exec_fragment_shader);
00139    if (!shader)
00140       return NULL;
00141 
00142    /* we need to keep a local copy of the tokens */
00143    shader->base.shader.tokens = tgsi_dup_tokens(templ->tokens);
00144    shader->base.prepare = exec_prepare;
00145    shader->base.run = exec_run;
00146    shader->base.delete = exec_delete;
00147 
00148    return &shader->base;
00149 }

void sp_setup_pos_vector ( const struct tgsi_interp_coef coef,
float  x,
float  y,
struct tgsi_exec_vector quadpos 
)

Compute quad X,Y,Z,W for the four fragments in a quad.

This should really be part of the compiled shader.

Definition at line 54 of file sp_fs_exec.c.

References tgsi_interp_coef::a0, tgsi_interp_coef::dadx, tgsi_interp_coef::dady, tgsi_exec_channel::f, and tgsi_exec_vector::xyzw.

00057 {
00058    uint chan;
00059    /* do X */
00060    quadpos->xyzw[0].f[0] = x;
00061    quadpos->xyzw[0].f[1] = x + 1;
00062    quadpos->xyzw[0].f[2] = x;
00063    quadpos->xyzw[0].f[3] = x + 1;
00064 
00065    /* do Y */
00066    quadpos->xyzw[1].f[0] = y;
00067    quadpos->xyzw[1].f[1] = y;
00068    quadpos->xyzw[1].f[2] = y + 1;
00069    quadpos->xyzw[1].f[3] = y + 1;
00070 
00071    /* do Z and W for all fragments in the quad */
00072    for (chan = 2; chan < 4; chan++) {
00073       const float dadx = coef->dadx[chan];
00074       const float dady = coef->dady[chan];
00075       const float a0 = coef->a0[chan] + dadx * x + dady * y;
00076       quadpos->xyzw[chan].f[0] = a0;
00077       quadpos->xyzw[chan].f[1] = a0 + dadx;
00078       quadpos->xyzw[chan].f[2] = a0 + dady;
00079       quadpos->xyzw[chan].f[3] = a0 + dadx + dady;
00080    }
00081 }


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