Commit graph

33 commits

Author SHA1 Message Date
Brian Paul
c4a782041b cell: datatype clean-ups in SPE rtasm 2009-01-11 14:22:00 -07:00
Brian Paul
2b26a92cd3 gallium: s/false/FALSE/ 2009-01-10 14:58:44 -07:00
Robert Ellison
11fc390f64 CELL: use variant-length fragment ops programs
This is a set of changes that optimizes the memory use of fragment
operation programs (by using and transmitting only as much memory as is
needed for the fragment ops programs, instead of maximal sizes), as well
as eliminate the dependency on hard-coded maximal program sizes.  State
that is not dependent on fragment facing (i.e. that isn't using
two-sided stenciling) will only save and transmit a single
fragment operation program, instead of two identical programs.

- Added the ability to emit a LNOP (No Operation (Load)) instruction.
  This is used to pad the generated fragment operations programs to
  a multiple of 8 bytes, which is necessary for proper operation of
  the dual instruction pipeline, and also required for proper SPU-side
  decoding.

- Added the ability to allocate and manage a variant-length
  struct cell_command_fragment_ops.  This structure now puts the
  generated function field at the end, where it can be as large
  as necessary.

- On the PPU side, we now combine the generated front-facing and
  back-facing code into a single variant-length buffer (and only use one
  if the two sets of code are identical) for transmission to the SPU.

- On the SPU side, we pull the correct sizes out of the buffer,
  allocate a new code buffer if the one we have isn't large enough,
  and save the code to that buffer.  The buffer is deallocated when
  the SPU exits.

- Commented out the emit_fetch() static function, which was not being used.
2008-11-21 11:42:35 -07:00
Robert Ellison
90027f8578 CELL: two-sided stencil fixes
With these changes, the tests/stencil_twoside test now works.

- Eliminate blending from the stencil_twoside test, as it produces an
  unneeded dependency on having blending working

- The spe_splat() function will now work if the register being splatted
  and the destination register are the same

- Separate fragment code generated for front-facing and back-facing
  fragments.  Often these are the same; if two-sided stenciling is on,
  they can be different.  This is easier and faster than generating
  code that does both tests and merges the results.

- Fixed a cut/paste bug where if the back Z-pass stencil operation
  were different from all the other operations, the back Z-fail
  results were incorrect.
2008-11-11 13:57:10 -07:00
Brian Paul
f952aac1da gallium: grow SPE instruction buffer as needed 2008-10-29 16:56:28 -06:00
Brian Paul
d3403b5482 cell: add emit_RI10s() which does range checking on the 10-bit signed immediate field
This type of checking should be expanded to cover more instructions...
2008-10-10 14:57:57 -06:00
Brian Paul
f42ef6f39d cell: additional 'offset' checking in spe_lqd(), spe_stqd() 2008-10-10 14:44:52 -06:00
Brian Paul
78c67a726f cell: fix assertions in spe_lqd(), spe_stqd() 2008-10-10 14:36:18 -06:00
Robert Ellison
adeed0f90f CELL: fixing stencil bugs
These are the defects found and fixed so far.  Several more have
been observed; I'm working on them.

- Fixed an error in spe_load_uint() that caused incorrect values to be
  loaded if the given unsigned value had the low 18 bits as 0,
  and that caused inefficient code to be emitted if the given value
  had the high 14 bits as 0.

- Fixed a problem in stencil code generation where optional registers
  weren't tracked correctly.

- Fixed a problem that the stencil function NEVER was acting as ALWAYS.

- Fixed several problems that could occur if stenciling were enabled but
  depth was disabled.

- Fixed a problem with two-sided stencil writemask handling that could
  cause a stencil writemask to not be applied.

- Fixed several state permutations that were incorrectly flagged as
  not requiring stencil values to be calculated.
2008-10-10 14:15:51 -06:00
Brian Paul
7ac1fc7766 cell: fix incorrect bitmask in spe_load_uint() 2008-10-09 19:54:46 -06:00
Brian Paul
d48a92e880 cell: implement function calls from shader code. fslight demo runs now.
Used for SIN, COS, EXP2, LOG2, POW instructions.  TEX next.

Fixed some bugs in MIN, MAX, DP3, DP4, DPH instructions.

In rtasm code:
  Special-case spe_lqd(), spe_stqd() functions so they take byte offsets but
  low-order 4 bits are shifted out.  This makes things consistant with SPU
  assembly language conventions.
  Added spe_get_registers_used() function.
2008-10-08 20:44:32 -06:00
Brian Paul
5c57cbec32 gallium: asst. clean-ups
Don't use register qualifier.  Doxygen-ize comments.  Remove 'extern'.
2008-10-08 16:35:40 -06:00
Brian Paul
73d00b9e93 gallium: better instruction printing for SPE code 2008-10-08 16:33:04 -06:00
Robert Ellison
afaa53040b CELL: changes to generate SPU code for stenciling
This set of code changes are for stencil code generation
support.  Both one-sided and two-sided stenciling are supported.
In addition to the raw code generation changes, these changes had
to be made elsewhere in the system:

- Added new "register set" feature to the SPE assembly generation.
  A "register set" is a way to allocate multiple registers and free
  them all at the same time, delegating register allocation management
  to the spe_function unit.  It's quite useful in complex register
  allocation schemes (like stenciling).

- Added and improved SPE macro calculations.
  These are operations between registers and unsigned integer
  immediates.  In many cases, the calculation can be performed
  with a single instruction; the macros will generate the
  single instruction if possible, or generate a register load
  and register-to-register operation if not.  These macro
  functions are: spe_load_uint() (which has new ways to
  load a value in a single instruction), spe_and_uint(),
  spe_xor_uint(), spe_compare_equal_uint(), and spe_compare_greater_uint().

- Added facing to fragment generation.  While rendering, the rasterizer
  needs to be able to determine front- and back-facing fragments, in order
  to correctly apply two-sided stencil.  That requires these changes:
  - Added front_winding field to the cell_command_render block, so that
    the state tracker could communicate to the rasterizer what it
    considered to be the front-facing direction.
  - Added fragment facing as an input to the fragment function.
  - Calculated facing is passed during emit_quad().
2008-10-03 18:05:14 -06:00
Brian Paul
99cdfc997b cell: use different opcodes for spe_move() depending on even/odd address 2008-09-19 17:56:45 -06:00
Brian Paul
7af5f944e5 gallium: added spe_code_size() 2008-09-19 17:56:45 -06:00
Brian Paul
0838b70275 cell: change spe_complement() to take a src and dst reg, like other instructions 2008-09-19 09:36:29 -06:00
Robert Ellison
a57fbe53dc CELL: add codegen for logic op, color mask
- rtasm_ppc_spe.c, rtasm_ppc_spe.h: added a new macro function
  "spe_load_uint" for loading and splatting unsigned integers
  in a register; it will use "ila" for values 18 bits or less,
  "ilh" for word values that are symmetric across halfwords,
  "ilhu" for values that have zeroes in their bottom halfwords,
  or "ilhu" followed by "iohl" for general 32-bit values.

  Of the 15 color masks of interest, 4 are 18 bits or less,
  2 are symmetric across halfwords, 3 are zero in the bottom
  halfword, and 6 require two instructions to load.

- cell_gen_fragment.c: added full codegen for logic op and
  color mask.
2008-09-19 01:55:00 -06:00
Robert Ellison
f8bba34d4e CELL: finish fragment ops blending (except for unusual D3D modes)
- Added new "macro" functions spe_float_min() and spe_float_max()
  to rtasm_ppc_spe.{ch}.  These emit instructions that cause
  the minimum or maximum of each element in a vector of floats
  to be saved in the destination register.

- Major changes to cell_gen_fragment.c to implement all the blending
  modes (except for the mysterious D3D-based PIPE_BLENDFACTOR_SRC1_COLOR,
  PIPE_BLENDFACTOR_SRC1_ALPHA, PIPE_BLENDFACTOR_INV_SRC1_COLOR, and
  PIPE_BLENDFACTOR_INV_SRC1_ALPHA).

- Some revamping of code in cell_gen_fragment.c: use the new spe_float_min()
  and spe_float_max() functions (instead of expanding these calculations
  inline via macros); create and use an inline utility function for handling
  "optional" register allocation (for the {1,1,1,1} vector, and the
  blend color vectors) instead of expanding with macros; use the Float
  Multiply and Subtract (fnms) instruction to simplify and optimize many
  blending calculations.
2008-09-18 01:29:41 -06:00
Brian Paul
ae3373441d gallium: emit SPU instructions in assembler-compatible syntax 2008-09-15 15:10:02 -06:00
Jonathan White
367774a62a Fixed emit_RRR 2008-09-15 11:57:59 -06:00
Brian Paul
8b5013d232 gallium: added print/dump code to SPE code emitter 2008-09-12 21:52:47 -06:00
Brian Paul
31a112cad4 gallium: added spe_splat_word() 2008-09-12 21:08:01 -06:00
Brian Paul
b71f4150c8 gallium: minor optimization to spe_load_int() 2008-09-12 08:22:15 -06:00
Brian Paul
178bbaff80 gallium: add special cases in spe_load_float(), spe_load_int(), added spe_splat() 2008-09-11 17:10:32 -06:00
Brian Paul
ee582fd3a7 gallium: assorted additions and fixes to Cell SPE rtasm code
Fix incorrect opcode for fsmbi.
Added "macro" functions for loading floats/ints, register complement, zero, move.
Added #defines for return address and stack pointer registers.
Added assertions to check that the instruction buffer doesn't overflow.
2008-09-11 10:39:28 -06:00
Brian Paul
bb5becf1e2 gallium: comments, assertions, etc 2008-09-11 10:39:28 -06:00
Brian Paul
4f25420bdd gallium: refactor/replace p_util.h with util/u_memory.h and util/u_math.h
Also, rename p_tile.[ch] to u_tile.[ch]
2008-08-24 17:48:55 -06:00
Ian Romanick
84d8030735 cell: Float convert-to and convert-from instructions use different shift bias 2008-03-25 18:15:58 -07:00
Ian Romanick
9f106a8683 cell: Don't free NULL code pointers 2008-03-17 16:07:54 -07:00
Ian Romanick
0c715de39f cell: Fix simple register allocator
THere are 64-bits in a uint64_t, not 128.  Duh.
2008-03-17 15:47:45 -07:00
Ian Romanick
b1525662b3 Move SPE register allocator to rtasm code
Move the register allocator to a common location.  There is more code
on the way that will make use of this interface.
2008-03-10 17:00:44 -07:00
José Fonseca
5d78212d75 Bring in ppc spe rtasm into gallium's rtasm module.
Moving files since these are not being used outside gallium.
2008-02-19 14:06:11 +09:00
Renamed from src/mesa/ppc/rtasm/spe_asm.c (Browse further)