spu_exec.h File Reference

Include dependency graph for spu_exec.h:

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

Go to the source code of this file.

Data Structures

union  spu_exec_channel
 Registers may be treated as float, signed int or unsigned int. More...
struct  spu_exec_vector
 A vector[RGBA] of channels[4 pixels]. More...
struct  spu_interp_coef
 For fragment programs, information for computing fragment input values from plane equation of the triangle/line. More...
struct  spu_sampler
 Opaque to TGSI. More...
struct  spu_exec_machine
 Run-time virtual machine state for executing TGSI shader. More...

Functions

void spu_exec_machine_init (struct spu_exec_machine *mach, uint numSamplers, struct spu_sampler *samplers, unsigned processor)
 Initialize machine state by expanding tokens to full instructions, allocating temporary storage, setting up constants, etc.
uint spu_exec_machine_run (struct spu_exec_machine *mach)
 Run TGSI interpreter.


Function Documentation

void spu_exec_machine_init ( struct spu_exec_machine mach,
uint  numSamplers,
struct spu_sampler samplers,
unsigned  processor 
)

Initialize machine state by expanding tokens to full instructions, allocating temporary storage, setting up constants, etc.

After this, we can call spu_exec_machine_run() many times.

Definition at line 143 of file spu_exec.c.

References spu_exec_machine::Addrs, spu_exec_machine::Processor, spu_exec_machine::Samplers, TEMP_0_C, TEMP_0_I, TEMP_128_C, TEMP_128_I, TEMP_1_C, TEMP_1_I, TEMP_2_C, TEMP_2_I, TEMP_7F_C, TEMP_7F_I, TEMP_80_C, TEMP_80_I, TEMP_FF_C, TEMP_FF_I, TEMP_M128_C, TEMP_M128_I, and TGSI_EXEC_NUM_TEMPS.

00147 {
00148    const qword zero = si_il(0);
00149    const qword not_zero = si_il(~0);
00150 
00151    (void) numSamplers;
00152    mach->Samplers = samplers;
00153    mach->Processor = processor;
00154    mach->Addrs = &mach->Temps[TGSI_EXEC_NUM_TEMPS];
00155 
00156    /* Setup constants. */
00157    mach->Temps[TEMP_0_I].xyzw[TEMP_0_C].q = zero;
00158    mach->Temps[TEMP_FF_I].xyzw[TEMP_FF_C].q = not_zero;
00159    mach->Temps[TEMP_7F_I].xyzw[TEMP_7F_C].q = si_shli(not_zero, -1);
00160    mach->Temps[TEMP_80_I].xyzw[TEMP_80_C].q = si_shli(not_zero, 31);
00161 
00162    mach->Temps[TEMP_1_I].xyzw[TEMP_1_C].q = (qword) spu_splats(1.0f);
00163    mach->Temps[TEMP_2_I].xyzw[TEMP_2_C].q = (qword) spu_splats(2.0f);
00164    mach->Temps[TEMP_128_I].xyzw[TEMP_128_C].q = (qword) spu_splats(128.0f);
00165    mach->Temps[TEMP_M128_I].xyzw[TEMP_M128_C].q = (qword) spu_splats(-128.0f);
00166 }

uint spu_exec_machine_run ( struct spu_exec_machine mach  ) 

Run TGSI interpreter.

Returns:
bitmask of "alive" quad components

Definition at line 1866 of file spu_exec.c.

References ALIGN16_ATTRIB, ASSERT, spu_exec_machine::CallStackTop, spu_exec_machine::CondMask, spu_exec_machine::CondStackTop, spu_exec_machine::ContMask, spu_exec_machine::ContStackTop, spu_exec_machine::Declarations, exec_declaration(), exec_instruction(), spu_exec_machine::ExecMask, spu_exec_channel::f, spu_exec_machine::FuncMask, spu_exec_channel::i, spu_exec_machine::Instructions, spu_exec_machine::LoopMask, spu_exec_machine::LoopStackTop, spu_exec_machine::NumDeclarations, spu_exec_machine::Outputs, spu_exec_machine::Primitives, spu_exec_machine::Processor, ROUNDUP16, spu_dcache_fetch_unaligned(), TEMP_KILMASK_C, TEMP_KILMASK_I, TEMP_OUTPUT_C, TEMP_OUTPUT_I, TEMP_PRIMITIVE_C, TEMP_PRIMITIVE_I, TGSI_PROCESSOR_FRAGMENT, TGSI_PROCESSOR_GEOMETRY, and spu_exec_vector::xyzw.

01867 {
01868    uint i;
01869    int pc = 0;
01870 
01871    mach->CondMask = 0xf;
01872    mach->LoopMask = 0xf;
01873    mach->ContMask = 0xf;
01874    mach->FuncMask = 0xf;
01875    mach->ExecMask = 0xf;
01876 
01877    mach->CondStackTop = 0; /* temporarily subvert this ASSERTion */
01878    ASSERT(mach->CondStackTop == 0);
01879    ASSERT(mach->LoopStackTop == 0);
01880    ASSERT(mach->ContStackTop == 0);
01881    ASSERT(mach->CallStackTop == 0);
01882 
01883    mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] = 0;
01884    mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] = 0;
01885 
01886    if( mach->Processor == TGSI_PROCESSOR_GEOMETRY ) {
01887       mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0] = 0;
01888       mach->Primitives[0] = 0;
01889    }
01890 
01891 
01892    /* execute declarations (interpolants) */
01893    if( mach->Processor == TGSI_PROCESSOR_FRAGMENT ) {
01894       for (i = 0; i < mach->NumDeclarations; i++) {
01895          union {
01896             struct tgsi_full_declaration decl;
01897             qword buffer[ROUNDUP16(sizeof(struct tgsi_full_declaration)) / 16];
01898          } d ALIGN16_ATTRIB;
01899          unsigned ea = (unsigned) (mach->Declarations + pc);
01900 
01901          spu_dcache_fetch_unaligned(d.buffer, ea, sizeof(d.decl));
01902 
01903          exec_declaration( mach, &d.decl );
01904       }
01905    }
01906 
01907    /* execute instructions, until pc is set to -1 */
01908    while (pc != -1) {
01909       union {
01910          struct tgsi_full_instruction inst;
01911          qword buffer[ROUNDUP16(sizeof(struct tgsi_full_instruction)) / 16];
01912       } i ALIGN16_ATTRIB;
01913       unsigned ea = (unsigned) (mach->Instructions + pc);
01914 
01915       spu_dcache_fetch_unaligned(i.buffer, ea, sizeof(i.inst));
01916       exec_instruction( mach, & i.inst, &pc );
01917    }
01918 
01919 #if 0
01920    /* we scale from floats in [0,1] to Zbuffer ints in sp_quad_depth_test.c */
01921    if (mach->Processor == TGSI_PROCESSOR_FRAGMENT) {
01922       /*
01923        * Scale back depth component.
01924        */
01925       for (i = 0; i < 4; i++)
01926          mach->Outputs[0].xyzw[2].f[i] *= ctx->DrawBuffer->_DepthMaxF;
01927    }
01928 #endif
01929 
01930    return ~mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0];
01931 }


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