mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-02 21:50:34 +01:00
cell: assorted comments, clean-ups, etc.
This commit is contained in:
parent
27ae1bcabf
commit
dc248fc288
10 changed files with 115 additions and 39 deletions
|
|
@ -32,6 +32,13 @@
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* Search the buffer pool for an empty/free buffer and return its index.
|
||||
* Buffers are used for storing vertex data, state and commands which
|
||||
* will be sent to the SPUs.
|
||||
* If no empty buffers are available, wait for one.
|
||||
* \return buffer index in [0, CELL_NUM_BUFFERS-1]
|
||||
*/
|
||||
uint
|
||||
cell_get_empty_buffer(struct cell_context *cell)
|
||||
{
|
||||
|
|
@ -74,6 +81,11 @@ cell_get_empty_buffer(struct cell_context *cell)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Flush the current batch buffer to the SPUs.
|
||||
* An empty buffer will be found and set as the new current batch buffer
|
||||
* for subsequent commands/data.
|
||||
*/
|
||||
void
|
||||
cell_batch_flush(struct cell_context *cell)
|
||||
{
|
||||
|
|
@ -120,6 +132,9 @@ cell_batch_flush(struct cell_context *cell)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the number of bytes free in the current batch buffer.
|
||||
*/
|
||||
uint
|
||||
cell_batch_free_space(const struct cell_context *cell)
|
||||
{
|
||||
|
|
@ -129,7 +144,7 @@ cell_batch_free_space(const struct cell_context *cell)
|
|||
|
||||
|
||||
/**
|
||||
* Append data to current batch.
|
||||
* Append data to the current batch buffer.
|
||||
* \param data address of block of bytes to append
|
||||
* \param bytes size of block of bytes
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -44,6 +44,9 @@
|
|||
#include "cell_state.h"
|
||||
|
||||
|
||||
/**
|
||||
* Called via pipe->clear()
|
||||
*/
|
||||
void
|
||||
cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps,
|
||||
unsigned clearValue)
|
||||
|
|
@ -61,13 +64,16 @@ cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps,
|
|||
PIPE_BUFFER_USAGE_GPU_WRITE);
|
||||
|
||||
if (ps == cell->framebuffer.zsbuf) {
|
||||
/* clear z/stencil buffer */
|
||||
surfIndex = 1;
|
||||
}
|
||||
else {
|
||||
/* clear color buffer */
|
||||
surfIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
/* Build a CLEAR command and place it in the current batch buffer */
|
||||
{
|
||||
struct cell_command_clear_surface *clr
|
||||
= (struct cell_command_clear_surface *)
|
||||
|
|
|
|||
|
|
@ -39,8 +39,13 @@
|
|||
#include "rtasm/rtasm_ppc_spe.h"
|
||||
#include "tgsi/tgsi_scan.h"
|
||||
|
||||
|
||||
struct cell_vbuf_render;
|
||||
|
||||
|
||||
/**
|
||||
* Cell vertex shader state, subclass of pipe_shader_state.
|
||||
*/
|
||||
struct cell_vertex_shader_state
|
||||
{
|
||||
struct pipe_shader_state shader;
|
||||
|
|
@ -49,6 +54,9 @@ struct cell_vertex_shader_state
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* Cell fragment shader state, subclass of pipe_shader_state.
|
||||
*/
|
||||
struct cell_fragment_shader_state
|
||||
{
|
||||
struct pipe_shader_state shader;
|
||||
|
|
@ -57,7 +65,11 @@ struct cell_fragment_shader_state
|
|||
};
|
||||
|
||||
|
||||
struct cell_blend_state {
|
||||
/**
|
||||
* Cell blend state atom, subclass of pipe_blend_state.
|
||||
*/
|
||||
struct cell_blend_state
|
||||
{
|
||||
struct pipe_blend_state base;
|
||||
|
||||
/**
|
||||
|
|
@ -67,17 +79,24 @@ struct cell_blend_state {
|
|||
};
|
||||
|
||||
|
||||
struct cell_depth_stencil_alpha_state {
|
||||
struct pipe_depth_stencil_alpha_state base;
|
||||
/**
|
||||
* Cell depth/stencil/alpha state atom, subclass of
|
||||
* pipe_depth_stencil_alpha_state.
|
||||
*/
|
||||
struct cell_depth_stencil_alpha_state
|
||||
{
|
||||
struct pipe_depth_stencil_alpha_state base;
|
||||
|
||||
/**
|
||||
* Generated code to perform alpha, stencil, and depth testing on the SPE
|
||||
*/
|
||||
struct spe_function code;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Per-context state, subclass of pipe_context.
|
||||
*/
|
||||
struct cell_context
|
||||
{
|
||||
struct pipe_context pipe;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,9 @@
|
|||
#include "draw/draw_context.h"
|
||||
|
||||
|
||||
/**
|
||||
* Called via pipe->flush()
|
||||
*/
|
||||
void
|
||||
cell_flush(struct pipe_context *pipe, unsigned flags,
|
||||
struct pipe_fence_handle **fence)
|
||||
|
|
@ -54,7 +57,11 @@ cell_flush(struct pipe_context *pipe, unsigned flags,
|
|||
}
|
||||
|
||||
|
||||
/** internal flush */
|
||||
/**
|
||||
* Cell internal flush function. Send the current batch buffer to all SPUs.
|
||||
* If flags & CELL_FLUSH_WAIT, do not return until the SPUs are idle.
|
||||
* \param flags bitmask of flags CELL_FLUSH_WAIT, or zero
|
||||
*/
|
||||
void
|
||||
cell_flush_int(struct cell_context *cell, unsigned flags)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,6 +26,11 @@
|
|||
**************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* Utility/wrappers for communicating with the SPUs.
|
||||
*/
|
||||
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "cell_spu.h"
|
||||
|
|
@ -74,7 +79,11 @@ wait_mbox_message(spe_context_ptr_t ctx)
|
|||
}
|
||||
|
||||
|
||||
static void *cell_thread_function(void *arg)
|
||||
/**
|
||||
* Called by pthread_create() to spawn an SPU thread.
|
||||
*/
|
||||
static void *
|
||||
cell_thread_function(void *arg)
|
||||
{
|
||||
struct cell_init_info *init = (struct cell_init_info *) arg;
|
||||
unsigned entry = SPE_DEFAULT_ENTRY;
|
||||
|
|
@ -92,7 +101,10 @@ static void *cell_thread_function(void *arg)
|
|||
|
||||
|
||||
/**
|
||||
* Create the SPU threads
|
||||
* Create the SPU threads. This is done once during driver initialization.
|
||||
* This involves setting the the "init" message which is sent to each SPU.
|
||||
* The init message specifies an SPU id, total number of SPUs, location
|
||||
* and number of batch buffers, etc.
|
||||
*/
|
||||
void
|
||||
cell_start_spus(struct cell_context *cell)
|
||||
|
|
@ -100,7 +112,6 @@ cell_start_spus(struct cell_context *cell)
|
|||
static boolean one_time_init = FALSE;
|
||||
uint i, j;
|
||||
|
||||
|
||||
if (one_time_init) {
|
||||
fprintf(stderr, "PPU: Multiple rendering contexts not yet supported "
|
||||
"on Cell.\n");
|
||||
|
|
@ -145,6 +156,7 @@ cell_start_spus(struct cell_context *cell)
|
|||
|
||||
/**
|
||||
* Tell all the SPUs to stop/exit.
|
||||
* This is done when the driver's exiting / cleaning up.
|
||||
*/
|
||||
void
|
||||
cell_spu_exit(struct cell_context *cell)
|
||||
|
|
|
|||
|
|
@ -35,21 +35,6 @@
|
|||
#include "cell_state_emit.h"
|
||||
|
||||
|
||||
static int
|
||||
find_vs_output(const struct cell_vertex_shader_state *vs,
|
||||
uint semantic_name,
|
||||
uint semantic_index)
|
||||
{
|
||||
uint i;
|
||||
for (i = 0; i < vs->info.num_outputs; i++) {
|
||||
if (vs->info.output_semantic_name[i] == semantic_name &&
|
||||
vs->info.output_semantic_index[i] == semantic_index)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine how to map vertex program outputs to fragment program inputs.
|
||||
* Basically, this will be used when computing the triangle interpolation
|
||||
|
|
@ -58,7 +43,6 @@ find_vs_output(const struct cell_vertex_shader_state *vs,
|
|||
static void
|
||||
calculate_vertex_layout( struct cell_context *cell )
|
||||
{
|
||||
const struct cell_vertex_shader_state *vs = cell->vs;
|
||||
const struct cell_fragment_shader_state *fs = cell->fs;
|
||||
const enum interp_mode colorInterp
|
||||
= cell->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
|
||||
|
|
@ -82,7 +66,7 @@ calculate_vertex_layout( struct cell_context *cell )
|
|||
vinfo->num_attribs = 0;
|
||||
|
||||
/* we always want to emit vertex pos */
|
||||
src = find_vs_output(vs, TGSI_SEMANTIC_POSITION, 0);
|
||||
src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_POSITION, 0);
|
||||
assert(src >= 0);
|
||||
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_POS, src);
|
||||
|
||||
|
|
@ -98,14 +82,14 @@ calculate_vertex_layout( struct cell_context *cell )
|
|||
break;
|
||||
|
||||
case TGSI_SEMANTIC_COLOR:
|
||||
src = find_vs_output(vs, TGSI_SEMANTIC_COLOR,
|
||||
fs->info.input_semantic_index[i]);
|
||||
src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_COLOR,
|
||||
fs->info.input_semantic_index[i]);
|
||||
assert(src >= 0);
|
||||
draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
|
||||
break;
|
||||
|
||||
case TGSI_SEMANTIC_FOG:
|
||||
src = find_vs_output(vs, TGSI_SEMANTIC_FOG, 0);
|
||||
src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_FOG, 0);
|
||||
#if 1
|
||||
if (src < 0) /* XXX temp hack, try demos/fogcoord.c with this */
|
||||
src = 0;
|
||||
|
|
@ -116,7 +100,7 @@ calculate_vertex_layout( struct cell_context *cell )
|
|||
|
||||
case TGSI_SEMANTIC_GENERIC:
|
||||
/* this includes texcoords and varying vars */
|
||||
src = find_vs_output(vs, TGSI_SEMANTIC_GENERIC,
|
||||
src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_GENERIC,
|
||||
fs->info.input_semantic_index[i]);
|
||||
assert(src >= 0);
|
||||
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
|
||||
|
|
@ -163,6 +147,9 @@ compute_cliprect(struct cell_context *sp)
|
|||
|
||||
|
||||
|
||||
/**
|
||||
* Update derived state, send current state to SPUs prior to rendering.
|
||||
*/
|
||||
void cell_update_derived( struct cell_context *cell )
|
||||
{
|
||||
if (cell->dirty & (CELL_NEW_RASTERIZER |
|
||||
|
|
|
|||
|
|
@ -47,7 +47,10 @@ emit_state_cmd(struct cell_context *cell, uint cmd,
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* For state marked as 'dirty', construct a state-update command block
|
||||
* and insert it into the current batch buffer.
|
||||
*/
|
||||
void
|
||||
cell_emit_state(struct cell_context *cell)
|
||||
{
|
||||
|
|
@ -90,7 +93,8 @@ cell_emit_state(struct cell_context *cell)
|
|||
blend.size = (char *) cell->blend->code.csr
|
||||
- (char *) cell->blend->code.store;
|
||||
blend.read_fb = TRUE;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
blend.base = 0;
|
||||
blend.size = 0;
|
||||
blend.read_fb = FALSE;
|
||||
|
|
@ -101,7 +105,6 @@ cell_emit_state(struct cell_context *cell)
|
|||
|
||||
if (cell->dirty & CELL_NEW_DEPTH_STENCIL) {
|
||||
struct cell_command_depth_stencil_alpha_test dsat;
|
||||
|
||||
|
||||
if (cell->depth_stencil != NULL) {
|
||||
dsat.base = (intptr_t) cell->depth_stencil->code.store;
|
||||
|
|
@ -109,15 +112,15 @@ cell_emit_state(struct cell_context *cell)
|
|||
- (char *) cell->depth_stencil->code.store;
|
||||
dsat.read_depth = TRUE;
|
||||
dsat.read_stencil = FALSE;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
dsat.base = 0;
|
||||
dsat.size = 0;
|
||||
dsat.read_depth = FALSE;
|
||||
dsat.read_stencil = FALSE;
|
||||
}
|
||||
|
||||
emit_state_cmd(cell, CELL_CMD_STATE_DEPTH_STENCIL, &dsat,
|
||||
sizeof(dsat));
|
||||
emit_state_cmd(cell, CELL_CMD_STATE_DEPTH_STENCIL, &dsat, sizeof(dsat));
|
||||
}
|
||||
|
||||
if (cell->dirty & CELL_NEW_SAMPLER) {
|
||||
|
|
@ -170,7 +173,6 @@ cell_emit_state(struct cell_context *cell)
|
|||
info.immediates = (uintptr_t) draw->vs.machine.Imms;
|
||||
info.num_immediates = draw->vs.machine.ImmLimit / 4;
|
||||
|
||||
emit_state_cmd(cell, CELL_CMD_STATE_BIND_VS,
|
||||
& info, sizeof(info));
|
||||
emit_state_cmd(cell, CELL_CMD_STATE_BIND_VS, &info, sizeof(info));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,10 @@ cell_vertex_shader_state(void *shader)
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create fragment shader state.
|
||||
* Called via pipe->create_fs_state()
|
||||
*/
|
||||
static void *
|
||||
cell_create_fs_state(struct pipe_context *pipe,
|
||||
const struct pipe_shader_state *templ)
|
||||
|
|
@ -77,6 +80,9 @@ cell_create_fs_state(struct pipe_context *pipe,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via pipe->bind_fs_state()
|
||||
*/
|
||||
static void
|
||||
cell_bind_fs_state(struct pipe_context *pipe, void *fs)
|
||||
{
|
||||
|
|
@ -88,6 +94,9 @@ cell_bind_fs_state(struct pipe_context *pipe, void *fs)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via pipe->delete_fs_state()
|
||||
*/
|
||||
static void
|
||||
cell_delete_fs_state(struct pipe_context *pipe, void *fs)
|
||||
{
|
||||
|
|
@ -98,6 +107,10 @@ cell_delete_fs_state(struct pipe_context *pipe, void *fs)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create vertex shader state.
|
||||
* Called via pipe->create_vs_state()
|
||||
*/
|
||||
static void *
|
||||
cell_create_vs_state(struct pipe_context *pipe,
|
||||
const struct pipe_shader_state *templ)
|
||||
|
|
@ -128,6 +141,9 @@ cell_create_vs_state(struct pipe_context *pipe,
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via pipe->bind_vs_state()
|
||||
*/
|
||||
static void
|
||||
cell_bind_vs_state(struct pipe_context *pipe, void *vs)
|
||||
{
|
||||
|
|
@ -142,6 +158,9 @@ cell_bind_vs_state(struct pipe_context *pipe, void *vs)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via pipe->delete_vs_state()
|
||||
*/
|
||||
static void
|
||||
cell_delete_vs_state(struct pipe_context *pipe, void *vs)
|
||||
{
|
||||
|
|
@ -154,6 +173,9 @@ cell_delete_vs_state(struct pipe_context *pipe, void *vs)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called via pipe->set_constant_buffer()
|
||||
*/
|
||||
static void
|
||||
cell_set_constant_buffer(struct pipe_context *pipe,
|
||||
uint shader, uint index,
|
||||
|
|
|
|||
|
|
@ -372,6 +372,7 @@ cell_init_texture_functions(struct cell_context *cell)
|
|||
/*cell->pipe.texture_update = cell_texture_update;*/
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
cell_init_screen_texture_funcs(struct pipe_screen *screen)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,6 +26,11 @@
|
|||
**************************************************************************/
|
||||
|
||||
/**
|
||||
* Vertex buffer code. The draw module transforms vertices to window
|
||||
* coords, etc. and emits the vertices into buffer supplied by this module.
|
||||
* When a vertex buffer is full, or we flush, we'll send the vertex data
|
||||
* to the SPUs.
|
||||
*
|
||||
* Authors
|
||||
* Brian Paul
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue