diff options
Diffstat (limited to 'src/mesa/pipe/cell/ppu')
-rw-r--r-- | src/mesa/pipe/cell/ppu/Makefile | 15 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_context.c | 237 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_context.h | 49 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_flush.c | 54 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_flush.h | 35 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_spu.c | 223 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_spu.h | 81 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_state.h | 117 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_state_blend.c | 128 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_state_clip.c | 84 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_state_fs.c | 195 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_state_rasterizer.c | 65 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_state_sampler.c | 100 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_state_surface.c | 99 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_state_vertex.c | 63 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_surface.c | 99 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_surface.h | 49 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_winsys.c | 40 | ||||
-rw-r--r-- | src/mesa/pipe/cell/ppu/cell_winsys.h | 50 |
19 files changed, 1753 insertions, 30 deletions
diff --git a/src/mesa/pipe/cell/ppu/Makefile b/src/mesa/pipe/cell/ppu/Makefile index c987d54e02..f597784d65 100644 --- a/src/mesa/pipe/cell/ppu/Makefile +++ b/src/mesa/pipe/cell/ppu/Makefile @@ -17,7 +17,18 @@ SPU_CODE_MODULE = ../spu/g3d_spu.a SOURCES = \ cell_context.c \ - cell_surface.c + cell_flush.c \ + cell_state_blend.c \ + cell_state_clip.c \ + cell_state_fs.c \ + cell_state_rasterizer.c \ + cell_state_sampler.c \ + cell_state_surface.c \ + cell_state_vertex.c \ + cell_spu.c \ + cell_surface.c \ + cell_winsys.c + OBJECTS = $(SOURCES:.c=.o) \ @@ -42,7 +53,7 @@ $(CELL_LIB): $(OBJECTS) $(SPU_CODE_MODULE) clean: - rm -f *.o $(CELL_LIB) + rm -f *.o *~ $(CELL_LIB) diff --git a/src/mesa/pipe/cell/ppu/cell_context.c b/src/mesa/pipe/cell/ppu/cell_context.c index a8f6cba2fa..68543ecf30 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.c +++ b/src/mesa/pipe/cell/ppu/cell_context.c @@ -32,45 +32,232 @@ #include <stdio.h> -#include <libspe.h> -#include <libmisc.h> -#include "pipe/cell/ppu/cell_context.h" + +#include "pipe/p_defines.h" +#include "pipe/p_format.h" +#include "pipe/p_util.h" +#include "pipe/p_winsys.h" #include "pipe/cell/common.h" +#include "pipe/draw/draw_context.h" +#include "cell_context.h" +#include "cell_flush.h" +#include "cell_state.h" +#include "cell_surface.h" +#include "cell_spu.h" -#define NUM_SPUS 6 -extern spe_program_handle_t g3d_spu; +static boolean +cell_is_format_supported( struct pipe_context *pipe, + enum pipe_format format, uint type ) +{ + struct cell_context *cell = cell_context( pipe ); -static speid_t speid[NUM_SPUS]; -static struct init_info inits[NUM_SPUS]; + switch (type) { + case PIPE_TEXTURE: + /* cell supports all texture formats, XXX for now anyway */ + return TRUE; + case PIPE_SURFACE: + /* cell supports all (off-screen) surface formats, XXX for now */ + return TRUE; + case PIPE_SCREEN_SURFACE: + return format == cell->winsys->preferredFormat; + default: + assert(0); + return FALSE; + } +} -static void -start_spus(void) +static int cell_get_param(struct pipe_context *pipe, int param) { - int i; - - for (i = 0; i < NUM_SPUS; i++) { - inits[i].foo = i; - inits[i].bar = i * 10; - - speid[i] = spe_create_thread(0, /* gid */ - &g3d_spu, /* spe program handle */ - &inits[i], /* argp */ - NULL, /* envp */ - -1, /* mask */ - 0 ); /* flags */ + switch (param) { + case PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS: + return 8; + case PIPE_CAP_NPOT_TEXTURES: + return 1; + case PIPE_CAP_TWO_SIDED_STENCIL: + return 1; + case PIPE_CAP_GLSL: + return 1; + case PIPE_CAP_S3TC: + return 0; + case PIPE_CAP_ANISOTROPIC_FILTER: + return 0; + case PIPE_CAP_POINT_SPRITE: + return 1; + case PIPE_CAP_MAX_RENDER_TARGETS: + return 1; + case PIPE_CAP_OCCLUSION_QUERY: + return 1; + case PIPE_CAP_TEXTURE_SHADOW_MAP: + return 1; + case PIPE_CAP_MAX_TEXTURE_2D_LEVELS: + return 12; /* max 2Kx2K */ + case PIPE_CAP_MAX_TEXTURE_3D_LEVELS: + return 8; /* max 128x128x128 */ + case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS: + return 12; /* max 2Kx2K */ + default: + return 0; + } +} + +static float cell_get_paramf(struct pipe_context *pipe, int param) +{ + switch (param) { + case PIPE_CAP_MAX_LINE_WIDTH: + /* fall-through */ + case PIPE_CAP_MAX_LINE_WIDTH_AA: + return 255.0; /* arbitrary */ + + case PIPE_CAP_MAX_POINT_WIDTH: + /* fall-through */ + case PIPE_CAP_MAX_POINT_WIDTH_AA: + return 255.0; /* arbitrary */ + + case PIPE_CAP_MAX_TEXTURE_ANISOTROPY: + return 0.0; + + case PIPE_CAP_MAX_TEXTURE_LOD_BIAS: + return 16.0; /* arbitrary */ + + default: + return 0; } } +static const char * +cell_get_name( struct pipe_context *pipe ) +{ + return "Cell"; +} + +static const char * +cell_get_vendor( struct pipe_context *pipe ) +{ + return "Tungsten Graphics, Inc."; +} + + + +static void +cell_destroy_context( struct pipe_context *pipe ) +{ + struct cell_context *cell = cell_context(pipe); + + cell_spu_exit(cell); + wait_spus(cell->num_spus); + + free(cell); +} + + -void cell_create_context(void) + +struct pipe_context * +cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws) { - printf("cell_create_context\n"); + struct cell_context *cell; + + cell = CALLOC_STRUCT(cell_context); + if (!cell) + return NULL; + + cell->winsys = cws; + cell->pipe.winsys = winsys; + cell->pipe.destroy = cell_destroy_context; + + /* queries */ + cell->pipe.is_format_supported = cell_is_format_supported; + cell->pipe.get_name = cell_get_name; + cell->pipe.get_vendor = cell_get_vendor; + cell->pipe.get_param = cell_get_param; + cell->pipe.get_paramf = cell_get_paramf; + + + /* state setters */ + cell->pipe.create_alpha_test_state = cell_create_alpha_test_state; + cell->pipe.bind_alpha_test_state = cell_bind_alpha_test_state; + cell->pipe.delete_alpha_test_state = cell_delete_alpha_test_state; + + cell->pipe.create_blend_state = cell_create_blend_state; + cell->pipe.bind_blend_state = cell_bind_blend_state; + cell->pipe.delete_blend_state = cell_delete_blend_state; + + cell->pipe.create_sampler_state = cell_create_sampler_state; + cell->pipe.bind_sampler_state = cell_bind_sampler_state; + cell->pipe.delete_sampler_state = cell_delete_sampler_state; + + cell->pipe.create_depth_stencil_state = cell_create_depth_stencil_state; + cell->pipe.bind_depth_stencil_state = cell_bind_depth_stencil_state; + cell->pipe.delete_depth_stencil_state = cell_delete_depth_stencil_state; + + cell->pipe.create_rasterizer_state = cell_create_rasterizer_state; + cell->pipe.bind_rasterizer_state = cell_bind_rasterizer_state; + cell->pipe.delete_rasterizer_state = cell_delete_rasterizer_state; + + cell->pipe.create_fs_state = cell_create_fs_state; + cell->pipe.bind_fs_state = cell_bind_fs_state; + cell->pipe.delete_fs_state = cell_delete_fs_state; + + cell->pipe.create_vs_state = cell_create_vs_state; + cell->pipe.bind_vs_state = cell_bind_vs_state; + cell->pipe.delete_vs_state = cell_delete_vs_state; + + cell->pipe.set_blend_color = cell_set_blend_color; + cell->pipe.set_clip_state = cell_set_clip_state; + cell->pipe.set_clear_color_state = cell_set_clear_color_state; + cell->pipe.set_constant_buffer = cell_set_constant_buffer; +#if 0 + cell->pipe.set_feedback_state = cell_set_feedback_state; +#endif + + cell->pipe.set_framebuffer_state = cell_set_framebuffer_state; + + cell->pipe.set_polygon_stipple = cell_set_polygon_stipple; + cell->pipe.set_sampler_units = cell_set_sampler_units; + cell->pipe.set_scissor_state = cell_set_scissor_state; + cell->pipe.set_texture_state = cell_set_texture_state; + cell->pipe.set_viewport_state = cell_set_viewport_state; + + cell->pipe.set_vertex_buffer = cell_set_vertex_buffer; + cell->pipe.set_vertex_element = cell_set_vertex_element; +#if 0 + cell->pipe.set_feedback_buffer = cell_set_feedback_buffer; + + cell->pipe.draw_arrays = cell_draw_arrays; + cell->pipe.draw_elements = cell_draw_elements; +#endif + + cell->pipe.clear = cell_clear_surface; + cell->pipe.flush = cell_flush; + +#if 0 + cell->pipe.begin_query = cell_begin_query; + cell->pipe.end_query = cell_end_query; + cell->pipe.wait_query = cell_wait_query; + + /* textures */ + cell->pipe.mipmap_tree_layout = cell_mipmap_tree_layout; + cell->pipe.get_tex_surface = cell_get_tex_surface; +#endif + + + cell->draw = draw_create(); + + /* + * SPU stuff + */ + cell->num_spus = 6; /* XXX >6 seems to fail */ + + cell_start_spus(cell->num_spus); - start_spus(); +#if 0 + test_spus(cell); + wait_spus(); +#endif - /* TODO: do something with the SPUs! */ + return &cell->pipe; } diff --git a/src/mesa/pipe/cell/ppu/cell_context.h b/src/mesa/pipe/cell/ppu/cell_context.h index b4d93d1414..a64692081d 100644 --- a/src/mesa/pipe/cell/ppu/cell_context.h +++ b/src/mesa/pipe/cell/ppu/cell_context.h @@ -31,16 +31,61 @@ #include "pipe/p_context.h" - +#include "cell_winsys.h" struct cell_context { struct pipe_context pipe; - int spu_info; + struct cell_winsys *winsys; + + const struct pipe_alpha_test_state *alpha_test; + const struct pipe_blend_state *blend; + const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; + const struct pipe_depth_stencil_state *depth_stencil; + const struct pipe_rasterizer_state *rasterizer; + + struct pipe_blend_color blend_color; + struct pipe_clear_color_state clear_color; + struct pipe_clip_state clip; + struct pipe_constant_buffer constants[2]; + struct pipe_feedback_state feedback; + struct pipe_framebuffer_state framebuffer; + struct pipe_poly_stipple poly_stipple; + struct pipe_scissor_state scissor; + struct softpipe_texture *texture[PIPE_MAX_SAMPLERS]; + struct pipe_viewport_state viewport; + struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX]; + struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX]; + uint sampler_units[PIPE_MAX_SAMPLERS]; + uint dirty; + + /** The primitive drawing context */ + struct draw_context *draw; + struct draw_stage *setup; + struct draw_stage *vbuf; + + + uint num_spus; + + }; +static INLINE struct cell_context * +cell_context(struct pipe_context *pipe) +{ + return (struct cell_context *) pipe; +} + + +extern struct pipe_context * +cell_create_context(struct pipe_winsys *ws, struct cell_winsys *cws); + + + + + #endif /* CELL_CONTEXT_H */ diff --git a/src/mesa/pipe/cell/ppu/cell_flush.c b/src/mesa/pipe/cell/ppu/cell_flush.c new file mode 100644 index 0000000000..e844d13f06 --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_flush.c @@ -0,0 +1,54 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#include <cbe_mfc.h> + +#include "cell_context.h" +#include "cell_flush.h" +#include "cell_spu.h" + + +void +cell_flush(struct pipe_context *pipe, unsigned flags) +{ + struct cell_context *cell = cell_context(pipe); + uint i; + + printf("%s\n", __FUNCTION__); + + /* Send CMD_FINISH to all SPUs */ + for (i = 0; i < cell->num_spus; i++) { + send_mbox_message(control_ps_area[i], CELL_CMD_FINISH); + } + + /* Wait for ack */ + for (i = 0; i < cell->num_spus; i++) { + uint k = wait_mbox_message(control_ps_area[i]); + assert(k == CELL_CMD_FINISH); + } +} diff --git a/src/mesa/pipe/cell/ppu/cell_flush.h b/src/mesa/pipe/cell/ppu/cell_flush.h new file mode 100644 index 0000000000..cf1a104f97 --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_flush.h @@ -0,0 +1,35 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#ifndef CELL_FLUSH +#define CELL_FLUSH + +extern void +cell_flush(struct pipe_context *pipe, unsigned flags); + +#endif diff --git a/src/mesa/pipe/cell/ppu/cell_spu.c b/src/mesa/pipe/cell/ppu/cell_spu.c new file mode 100644 index 0000000000..ed56250ff1 --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_spu.c @@ -0,0 +1,223 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#include <cbe_mfc.h> + +#include "cell_spu.h" +#include "pipe/p_format.h" +#include "pipe/p_state.h" +#include "pipe/cell/common.h" + + +/* +helpful headers: +/opt/ibm/cell-sdk/prototype/src/include/ppu/cbe_mfc.h +*/ + + +/** + * SPU/SPE handles, etc + */ +speid_t speid[MAX_SPUS]; +spe_spu_control_area_t *control_ps_area[MAX_SPUS]; + + +/** + * Data sent to SPUs + */ +struct cell_init_info inits[MAX_SPUS] ALIGN16; +struct cell_command command[MAX_SPUS] ALIGN16; + + +/** + * Write a 1-word message to the given SPE mailbox. + */ +void +send_mbox_message(spe_spu_control_area_t *ca, unsigned int msg) +{ + while (_spe_in_mbox_status(ca) < 1) + ; + _spe_in_mbox_write(ca, msg); +} + + +/** + * Wait for a 1-word message to arrive in given mailbox. + */ +uint +wait_mbox_message(spe_spu_control_area_t *ca) +{ + uint k; + while (_spe_out_mbox_status(ca) < 1) + ; + k = _spe_out_mbox_read(ca); + return k; +} + + +/** + * Create the SPU threads + */ +void +cell_start_spus(uint num_spus) +{ + uint i; + + assert((sizeof(struct cell_command) & 0xf) == 0); + ASSERT_ALIGN16(&command[0]); + ASSERT_ALIGN16(&command[1]); + + assert((sizeof(struct cell_init_info) & 0xf) == 0); + ASSERT_ALIGN16(&inits[0]); + ASSERT_ALIGN16(&inits[1]); + + /* XXX do we need to create a gid with spe_create_group()? */ + + for (i = 0; i < num_spus; i++) { + inits[i].id = i; + inits[i].num_spus = num_spus; + inits[i].cmd = &command[i]; + + speid[i] = spe_create_thread(0, /* gid */ + &g3d_spu, /* spe program handle */ + &inits[i], /* argp */ + NULL, /* envp */ + -1, /* mask */ + SPE_MAP_PS/*0*/ ); /* flags */ + + control_ps_area[i] = spe_get_ps_area(speid[i], SPE_CONTROL_AREA); + assert(control_ps_area[i]); + } +} + + +/** wait for all SPUs to finish working */ +/** XXX temporary */ +void +finish_all(uint num_spus) +{ + uint i; + + for (i = 0; i < num_spus; i++) { + send_mbox_message(control_ps_area[i], CELL_CMD_FINISH); + } + for (i = 0; i < num_spus; i++) { + /* wait for mbox message */ + unsigned k; + while (_spe_out_mbox_status(control_ps_area[i]) < 1) + ; + k = _spe_out_mbox_read(control_ps_area[i]); + assert(k == CELL_CMD_FINISH); + } +} + + +/** + ** Send test commands (XXX temporary) + **/ +void +test_spus(struct cell_context *cell) +{ + uint i; + struct pipe_surface *surf = cell->framebuffer.cbufs[0]; + + printf("PPU: sleep(2)\n\n\n"); + sleep(2); + + for (i = 0; i < cell->num_spus; i++) { + command[i].fb.start = surf->map; + command[i].fb.width = surf->width; + command[i].fb.height = surf->height; + command[i].fb.format = PIPE_FORMAT_A8R8G8B8_UNORM; + send_mbox_message(control_ps_area[i], CELL_CMD_FRAMEBUFFER); + } + + for (i = 0; i < cell->num_spus; i++) { + command[i].clear.value = 0xff880044; /* XXX */ + send_mbox_message(control_ps_area[i], CELL_CMD_CLEAR_TILES); + } + + finish_all(cell->num_spus); + + { + uint *b = (uint*) surf->map; + printf("PPU: Clear results: 0x%x 0x%x 0x%x 0x%x\n", + b[0], b[1000], b[2000], b[3000]); + } + + for (i = 0; i < cell->num_spus; i++) { + send_mbox_message(control_ps_area[i], CELL_CMD_INVERT_TILES); + } + + finish_all(cell->num_spus); + + { + uint *b = (uint*) surf->map; + printf("PPU: Inverted results: 0x%x 0x%x 0x%x 0x%x\n", + b[0], b[1000], b[2000], b[3000]); + } + + + + for (i = 0; i < cell->num_spus; i++) { + send_mbox_message(control_ps_area[i], CELL_CMD_EXIT); + } +} + + +/** + * Wait for all SPUs to exit/return. + */ +void +wait_spus(uint num_spus) +{ + int i, status; + + for (i = 0; i < num_spus; i++) { + spe_wait( speid[i], &status, 1 ); + } +} + + +/** + * Tell all the SPUs to stop/exit. + */ +void +cell_spu_exit(struct cell_context *cell) +{ + uint i; + int status; + + for (i = 0; i < cell->num_spus; i++) { + send_mbox_message(control_ps_area[i], CELL_CMD_EXIT); + } + + for (i = 0; i < cell->num_spus; i++) { + spe_wait( speid[i], &status, 1 ); + } +} diff --git a/src/mesa/pipe/cell/ppu/cell_spu.h b/src/mesa/pipe/cell/ppu/cell_spu.h new file mode 100644 index 0000000000..dcbc72573f --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_spu.h @@ -0,0 +1,81 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef CELL_SPU +#define CELL_SPU + + +#include <libspe.h> +#include <libmisc.h> +#include "pipe/cell/common.h" + +#include "cell_context.h" + + +#define MAX_SPUS 7 + +/** + * SPU/SPE handles, etc + */ +extern spe_program_handle_t g3d_spu; +extern speid_t speid[MAX_SPUS]; +extern spe_spu_control_area_t *control_ps_area[MAX_SPUS]; + + +/** + * Data sent to SPUs + */ +extern struct cell_init_info inits[MAX_SPUS] ALIGN16; +extern struct cell_command command[MAX_SPUS] ALIGN16; + + +void +send_mbox_message(spe_spu_control_area_t *ca, unsigned int msg); + +uint +wait_mbox_message(spe_spu_control_area_t *ca); + + +void +cell_start_spus(uint num_spus); + + +void +finish_all(uint num_spus); + +void +test_spus(struct cell_context *cell); + + +void +wait_spus(uint num_spus); + +void +cell_spu_exit(struct cell_context *cell); + + +#endif /* CELL_SPU */ diff --git a/src/mesa/pipe/cell/ppu/cell_state.h b/src/mesa/pipe/cell/ppu/cell_state.h new file mode 100644 index 0000000000..033767d29b --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_state.h @@ -0,0 +1,117 @@ + + +#ifndef CELL_STATE_H +#define CELL_STATE_H + + +#define CELL_NEW_VIEWPORT 0x1 +#define CELL_NEW_RASTERIZER 0x2 +#define CELL_NEW_FS 0x4 +#define CELL_NEW_BLEND 0x8 +#define CELL_NEW_CLIP 0x10 +#define CELL_NEW_SCISSOR 0x20 +#define CELL_NEW_STIPPLE 0x40 +#define CELL_NEW_FRAMEBUFFER 0x80 +#define CELL_NEW_ALPHA_TEST 0x100 +#define CELL_NEW_DEPTH_STENCIL 0x200 +#define CELL_NEW_SAMPLER 0x400 +#define CELL_NEW_TEXTURE 0x800 +#define CELL_NEW_VERTEX 0x1000 +#define CELL_NEW_VS 0x2000 +#define CELL_NEW_CONSTANTS 0x4000 + + + +extern void +cell_set_framebuffer_state( struct pipe_context *, + const struct pipe_framebuffer_state * ); + + +extern void * +cell_create_alpha_test_state(struct pipe_context *, + const struct pipe_alpha_test_state *); +extern void +cell_bind_alpha_test_state(struct pipe_context *, void *); +extern void +cell_delete_alpha_test_state(struct pipe_context *, void *); + +extern void * +cell_create_blend_state(struct pipe_context *, const struct pipe_blend_state *); +extern void cell_bind_blend_state(struct pipe_context *, void *); +extern void cell_delete_blend_state(struct pipe_context *, void *); + +extern void cell_set_blend_color( struct pipe_context *pipe, + const struct pipe_blend_color *blend_color ); + + +void * +cell_create_sampler_state(struct pipe_context *, + const struct pipe_sampler_state *); + +extern void +cell_bind_sampler_state(struct pipe_context *, unsigned, void *); + +extern void +cell_delete_sampler_state(struct pipe_context *, void *); + + +extern void * +cell_create_depth_stencil_state(struct pipe_context *, + const struct pipe_depth_stencil_state *); + +extern void +cell_bind_depth_stencil_state(struct pipe_context *, void *); + +extern void +cell_delete_depth_stencil_state(struct pipe_context *, void *); + + +void *cell_create_fs_state(struct pipe_context *, + const struct pipe_shader_state *); +void cell_bind_fs_state(struct pipe_context *, void *); +void cell_delete_fs_state(struct pipe_context *, void *); +void *cell_create_vs_state(struct pipe_context *, + const struct pipe_shader_state *); +void cell_bind_vs_state(struct pipe_context *, void *); +void cell_delete_vs_state(struct pipe_context *, void *); + + +void * +cell_create_rasterizer_state(struct pipe_context *, + const struct pipe_rasterizer_state *); +void cell_bind_rasterizer_state(struct pipe_context *, void *); +void cell_delete_rasterizer_state(struct pipe_context *, void *); + + +void cell_set_clip_state( struct pipe_context *, + const struct pipe_clip_state * ); + +void cell_set_constant_buffer(struct pipe_context *pipe, + uint shader, uint index, + const struct pipe_constant_buffer *buf); + +void cell_set_polygon_stipple( struct pipe_context *, + const struct pipe_poly_stipple * ); + +void cell_set_sampler_units( struct pipe_context *, + uint numSamplers, const uint *units ); + +void cell_set_scissor_state( struct pipe_context *, + const struct pipe_scissor_state * ); + +void cell_set_texture_state( struct pipe_context *, + unsigned unit, struct pipe_texture * ); + +void cell_set_vertex_element(struct pipe_context *, + unsigned index, + const struct pipe_vertex_element *); + +void cell_set_vertex_buffer(struct pipe_context *, + unsigned index, + const struct pipe_vertex_buffer *); + +void cell_set_viewport_state( struct pipe_context *, + const struct pipe_viewport_state * ); + + +#endif diff --git a/src/mesa/pipe/cell/ppu/cell_state_blend.c b/src/mesa/pipe/cell/ppu/cell_state_blend.c new file mode 100644 index 0000000000..e807463d90 --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_state_blend.c @@ -0,0 +1,128 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/* Authors: Keith Whitwell <keith@tungstengraphics.com> + */ + +#include "pipe/p_util.h" +#include "cell_context.h" +#include "cell_state.h" + +void * +cell_create_blend_state(struct pipe_context *pipe, + const struct pipe_blend_state *blend) +{ + struct pipe_blend_state *state = MALLOC( sizeof(struct pipe_blend_state) ); + memcpy(state, blend, sizeof(struct pipe_blend_state)); + return state; +} + +void cell_bind_blend_state( struct pipe_context *pipe, + void *blend ) +{ + struct cell_context *cell = cell_context(pipe); + + cell->blend = (const struct pipe_blend_state *)blend; + + cell->dirty |= CELL_NEW_BLEND; +} + +void cell_delete_blend_state(struct pipe_context *pipe, + void *blend) +{ + FREE( blend ); +} + + +void cell_set_blend_color( struct pipe_context *pipe, + const struct pipe_blend_color *blend_color ) +{ + struct cell_context *cell = cell_context(pipe); + + cell->blend_color = *blend_color; + + cell->dirty |= CELL_NEW_BLEND; +} + + +/** XXX move someday? Or consolidate all these simple state setters + * into one file. + */ + +void * +cell_create_alpha_test_state(struct pipe_context *pipe, + const struct pipe_alpha_test_state *alpha) +{ + struct pipe_alpha_test_state *state = MALLOC( sizeof(struct pipe_alpha_test_state) ); + memcpy(state, alpha, sizeof(struct pipe_alpha_test_state)); + return state; +} + +void +cell_bind_alpha_test_state(struct pipe_context *pipe, + void *alpha) +{ + struct cell_context *cell = cell_context(pipe); + + cell->alpha_test = (const struct pipe_alpha_test_state *)alpha; + + cell->dirty |= CELL_NEW_ALPHA_TEST; +} + +void +cell_delete_alpha_test_state(struct pipe_context *pipe, + void *alpha) +{ + FREE( alpha ); +} + +void * +cell_create_depth_stencil_state(struct pipe_context *pipe, + const struct pipe_depth_stencil_state *depth_stencil) +{ + struct pipe_depth_stencil_state *state = + MALLOC( sizeof(struct pipe_depth_stencil_state) ); + memcpy(state, depth_stencil, sizeof(struct pipe_depth_stencil_state)); + return state; +} + +void +cell_bind_depth_stencil_state(struct pipe_context *pipe, + void *depth_stencil) +{ + struct cell_context *cell = cell_context(pipe); + + cell->depth_stencil = (const struct pipe_depth_stencil_state *)depth_stencil; + + cell->dirty |= CELL_NEW_DEPTH_STENCIL; +} + +void +cell_delete_depth_stencil_state(struct pipe_context *pipe, void *depth) +{ + FREE( depth ); +} diff --git a/src/mesa/pipe/cell/ppu/cell_state_clip.c b/src/mesa/pipe/cell/ppu/cell_state_clip.c new file mode 100644 index 0000000000..4f43665941 --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_state_clip.c @@ -0,0 +1,84 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/* Authors: Keith Whitwell <keith@tungstengraphics.com> + */ + +#include "cell_context.h" +#include "cell_state.h" +#include "pipe/draw/draw_context.h" + + +void cell_set_clip_state( struct pipe_context *pipe, + const struct pipe_clip_state *clip ) +{ + struct cell_context *cell = cell_context(pipe); + + /* pass the clip state to the draw module */ + draw_set_clip_state(cell->draw, clip); +} + + + +/* Called when driver state tracker notices changes to the viewport + * matrix: + */ +void cell_set_viewport_state( struct pipe_context *pipe, + const struct pipe_viewport_state *viewport ) +{ + struct cell_context *cell = cell_context(pipe); + + cell->viewport = *viewport; /* struct copy */ + cell->dirty |= CELL_NEW_VIEWPORT; + + /* pass the viewport info to the draw module */ + draw_set_viewport_state(cell->draw, viewport); + + /* Using tnl/ and vf/ modules is temporary while getting started. + * Full pipe will have vertex shader, vertex fetch of its own. + */ +} + + +void cell_set_scissor_state( struct pipe_context *pipe, + const struct pipe_scissor_state *scissor ) +{ + struct cell_context *cell = cell_context(pipe); + + memcpy( &cell->scissor, scissor, sizeof(*scissor) ); + cell->dirty |= CELL_NEW_SCISSOR; +} + + +void cell_set_polygon_stipple( struct pipe_context *pipe, + const struct pipe_poly_stipple *stipple ) +{ + struct cell_context *cell = cell_context(pipe); + + memcpy( &cell->poly_stipple, stipple, sizeof(*stipple) ); + cell->dirty |= CELL_NEW_STIPPLE; +} diff --git a/src/mesa/pipe/cell/ppu/cell_state_fs.c b/src/mesa/pipe/cell/ppu/cell_state_fs.c new file mode 100644 index 0000000000..910f210cdc --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_state_fs.c @@ -0,0 +1,195 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include "pipe/p_defines.h" +#include "pipe/p_util.h" +#include "pipe/p_winsys.h" +#if 0 +#include "pipe/draw/draw_context.h" +#include "pipe/p_shader_tokens.h" +#include "pipe/llvm/gallivm.h" +#include "pipe/tgsi/util/tgsi_dump.h" +#include "pipe/tgsi/exec/tgsi_sse2.h" +#endif + +#include "cell_context.h" +#include "cell_state.h" + + +void * cell_create_fs_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) +{ + struct cell_context *cell = cell_context(pipe); + + return malloc(5); /* XXX temp */ + +#if 0 + /* Decide whether we'll be codegenerating this shader and if so do + * that now. + */ + + struct sp_fragment_shader_state *state = MALLOC( sizeof(struct sp_fragment_shader_state) ); + state->shader = *templ; + + if( cell->dump_fs ) { + tgsi_dump( + state->shader.tokens, + 0 ); + } + +#if defined(__i386__) || defined(__386__) + if (cell->use_sse) { + x86_init_func( &state->sse2_program ); + tgsi_emit_sse2_fs( state->shader.tokens, &state->sse2_program ); + } +#endif + +#ifdef MESA_LLVM + state->llvm_prog = gallivm_from_tgsi(state->shader.tokens, GALLIVM_FS); + if (!gallivm_global_cpu_engine()) { + gallivm_cpu_engine_create(state->llvm_prog); + } + else + gallivm_cpu_jit_compile(gallivm_global_cpu_engine(), state->llvm_prog); +#endif + return state; +#endif +} + +void cell_bind_fs_state(struct pipe_context *pipe, void *fs) +{ + struct cell_context *cell = cell_context(pipe); +#if 0 + cell->fs = (struct sp_fragment_shader_state *) fs; + + cell->dirty |= SP_NEW_FS; +#endif +} + +void cell_delete_fs_state(struct pipe_context *pipe, + void *shader) +{ +#if 0 + struct sp_fragment_shader_state *state = shader; + +#if defined(__i386__) || defined(__386__) + x86_release_func( &state->sse2_program ); +#endif + + FREE( state ); +#endif +} + + +void * +cell_create_vs_state(struct pipe_context *pipe, + const struct pipe_shader_state *templ) +{ + return malloc(5); /* XXX */ +#if 0 + struct cell_context *cell = cell_context(pipe); + struct sp_vertex_shader_state *state; + + state = MALLOC( sizeof(struct sp_vertex_shader_state) ); + if (state == NULL ) { + return NULL; + } + + state->state = MALLOC( sizeof(struct pipe_shader_state) ); + if (state->state == NULL) { + FREE( state ); + return NULL; + } + memcpy( state->state, templ, sizeof(struct pipe_shader_state) ); + + state->draw_data = draw_create_vertex_shader(cell->draw, + state->state); + if (state->draw_data == NULL) { + FREE( state->state ); + FREE( state ); + return NULL; + } + + return state; +#endif +} + + + +void +cell_bind_vs_state(struct pipe_context *pipe, void *vs) +{ +#if 0 + struct cell_context *cell = cell_context(pipe); + + cell->vs = (const struct sp_vertex_shader_state *)vs; + + draw_bind_vertex_shader(cell->draw, cell->vs->draw_data); + + cell->dirty |= SP_NEW_VS; +#endif +} + +void +cell_delete_vs_state(struct pipe_context *pipe, void *vs) +{ +#if 0 + struct cell_context *cell = cell_context(pipe); + + struct sp_vertex_shader_state *state = + (struct sp_vertex_shader_state *)vs; + + draw_delete_vertex_shader(cell->draw, state->draw_data); + FREE( state->state ); + FREE( state ); +#endif +} + + + +void cell_set_constant_buffer(struct pipe_context *pipe, + uint shader, uint index, + const struct pipe_constant_buffer *buf) +{ +#if 0 + struct cell_context *cell = cell_context(pipe); + struct pipe_winsys *ws = pipe->winsys; + + assert(shader < PIPE_SHADER_TYPES); + assert(index == 0); + + /* note: reference counting */ + ws->buffer_reference(ws, + &cell->constants[shader].buffer, + buf->buffer); + cell->constants[shader].size = buf->size; + + cell->dirty |= SP_NEW_CONSTANTS; +#endif +} + + diff --git a/src/mesa/pipe/cell/ppu/cell_state_rasterizer.c b/src/mesa/pipe/cell/ppu/cell_state_rasterizer.c new file mode 100644 index 0000000000..11e7de7309 --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_state_rasterizer.c @@ -0,0 +1,65 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#include "pipe/p_defines.h" +#include "pipe/p_util.h" +#include "pipe/draw/draw_context.h" +#include "cell_context.h" +#include "cell_state.h" + + +void * +cell_create_rasterizer_state(struct pipe_context *pipe, + const struct pipe_rasterizer_state *setup) +{ + struct pipe_rasterizer_state *state = + MALLOC( sizeof(struct pipe_rasterizer_state) ); + memcpy(state, setup, sizeof(struct pipe_rasterizer_state)); + return state; +} + + +void +cell_bind_rasterizer_state(struct pipe_context *pipe, void *setup) +{ + struct cell_context *cell = cell_context(pipe); + + /* pass-through to draw module */ + draw_set_rasterizer_state(cell->draw, setup); + + cell->rasterizer = (struct pipe_rasterizer_state *)setup; + + cell->dirty |= CELL_NEW_RASTERIZER; +} + +void +cell_delete_rasterizer_state(struct pipe_context *pipe, void *rasterizer) +{ + FREE( rasterizer ); +} + + diff --git a/src/mesa/pipe/cell/ppu/cell_state_sampler.c b/src/mesa/pipe/cell/ppu/cell_state_sampler.c new file mode 100644 index 0000000000..c2a180ed30 --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_state_sampler.c @@ -0,0 +1,100 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/* Authors: + * Brian Paul + */ + +#include "pipe/p_util.h" +#include "cell_context.h" +#include "cell_state.h" +#if 0 +#include "cell_texture.h" +#include "cell_tile_cache.h" +#endif + + +void * +cell_create_sampler_state(struct pipe_context *pipe, + const struct pipe_sampler_state *sampler) +{ + struct pipe_sampler_state *state = MALLOC( sizeof(struct pipe_sampler_state) ); + memcpy(state, sampler, sizeof(struct pipe_sampler_state)); + return state; +} + +void +cell_bind_sampler_state(struct pipe_context *pipe, + unsigned unit, void *sampler) +{ + struct cell_context *cell = cell_context(pipe); + + assert(unit < PIPE_MAX_SAMPLERS); + cell->sampler[unit] = (struct pipe_sampler_state *)sampler; + + cell->dirty |= CELL_NEW_SAMPLER; +} + + +void +cell_delete_sampler_state(struct pipe_context *pipe, + void *sampler) +{ + FREE( sampler ); +} + + +void +cell_set_texture_state(struct pipe_context *pipe, + unsigned unit, + struct pipe_texture *texture) +{ + struct cell_context *cell = cell_context(pipe); + + assert(unit < PIPE_MAX_SAMPLERS); + +#if 0 + cell->texture[unit] = cell_texture(texture); /* ptr, not struct */ + cell_tile_cache_set_texture(cell->tex_cache[unit], texture); +#endif + + cell->dirty |= CELL_NEW_TEXTURE; +} + + +void +cell_set_sampler_units(struct pipe_context *pipe, + uint num_samplers, const uint *units ) +{ + struct cell_context *cell = cell_context(pipe); + uint i; + for (i = 0; i < num_samplers; i++) + cell->sampler_units[i] = units[i]; + cell->dirty |= CELL_NEW_SAMPLER; +} + + diff --git a/src/mesa/pipe/cell/ppu/cell_state_surface.c b/src/mesa/pipe/cell/ppu/cell_state_surface.c new file mode 100644 index 0000000000..f7330caf5e --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_state_surface.c @@ -0,0 +1,99 @@ + + +#include "cell_context.h" +#include "cell_state.h" + +void +cell_set_framebuffer_state(struct pipe_context *pipe, + const struct pipe_framebuffer_state *fb) +{ + struct cell_context *cell = cell_context(pipe); + + cell->framebuffer = *fb; + + cell->dirty |= CELL_NEW_FRAMEBUFFER; + +#if 0 + struct pipe_surface *ps; + uint i; + + for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { + /* check if changing cbuf */ + if (sp->framebuffer.cbufs[i] != fb->cbufs[i]) { + /* flush old */ + sp_flush_tile_cache(sp, sp->cbuf_cache[i]); + /* unmap old */ + ps = sp->framebuffer.cbufs[i]; + if (ps && ps->map) + pipe_surface_unmap(ps); + /* map new */ + ps = fb->cbufs[i]; + if (ps) + pipe_surface_map(ps); + /* assign new */ + sp->framebuffer.cbufs[i] = fb->cbufs[i]; + + /* update cache */ + sp_tile_cache_set_surface(sp, sp->cbuf_cache[i], ps); + } + } + + sp->framebuffer.num_cbufs = fb->num_cbufs; + + /* zbuf changing? */ + if (sp->framebuffer.zbuf != fb->zbuf) { + /* flush old */ + sp_flush_tile_cache(sp, sp->zbuf_cache); + /* unmap old */ + ps = sp->framebuffer.zbuf; + if (ps && ps->map) + pipe_surface_unmap(ps); + if (sp->framebuffer.sbuf == sp->framebuffer.zbuf) { + /* combined z/stencil */ + sp->framebuffer.sbuf = NULL; + } + /* map new */ + ps = fb->zbuf; + if (ps) + pipe_surface_map(ps); + /* assign new */ + sp->framebuffer.zbuf = fb->zbuf; + + /* update cache */ + sp_tile_cache_set_surface(sp, sp->zbuf_cache, ps); + } + + /* XXX combined depth/stencil here */ + + /* sbuf changing? */ + if (sp->framebuffer.sbuf != fb->sbuf) { + /* flush old */ + sp_flush_tile_cache(sp, sp->sbuf_cache_sep); + /* unmap old */ + ps = sp->framebuffer.sbuf; + if (ps && ps->map) + pipe_surface_unmap(ps); + /* map new */ + ps = fb->sbuf; + if (ps && fb->sbuf != fb->zbuf) + pipe_surface_map(ps); + /* assign new */ + sp->framebuffer.sbuf = fb->sbuf; + + /* update cache */ + if (fb->sbuf != fb->zbuf) { + /* separate stencil buf */ + sp->sbuf_cache = sp->sbuf_cache_sep; + sp_tile_cache_set_surface(sp, sp->sbuf_cache, ps); + } + else { + /* combined depth/stencil */ + sp->sbuf_cache = sp->zbuf_cache; + sp_tile_cache_set_surface(sp, sp->sbuf_cache, ps); + } + } + + sp->dirty |= SP_NEW_FRAMEBUFFER; +#endif +} + diff --git a/src/mesa/pipe/cell/ppu/cell_state_vertex.c b/src/mesa/pipe/cell/ppu/cell_state_vertex.c new file mode 100644 index 0000000000..0f01e920f9 --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_state_vertex.c @@ -0,0 +1,63 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/* Authors: Keith Whitwell <keith@tungstengraphics.com> + */ + + +#include "cell_context.h" +#include "cell_state.h" + +#include "pipe/draw/draw_context.h" + + +void +cell_set_vertex_element(struct pipe_context *pipe, + unsigned index, + const struct pipe_vertex_element *attrib) +{ + struct cell_context *cell = cell_context(pipe); + assert(index < PIPE_ATTRIB_MAX); + cell->vertex_element[index] = *attrib; /* struct copy */ + cell->dirty |= CELL_NEW_VERTEX; + + draw_set_vertex_element(cell->draw, index, attrib); +} + + +void +cell_set_vertex_buffer(struct pipe_context *pipe, + unsigned index, + const struct pipe_vertex_buffer *buffer) +{ + struct cell_context *cell = cell_context(pipe); + assert(index < PIPE_ATTRIB_MAX); + cell->vertex_buffer[index] = *buffer; /* struct copy */ + cell->dirty |= CELL_NEW_VERTEX; + + draw_set_vertex_buffer(cell->draw, index, buffer); +} diff --git a/src/mesa/pipe/cell/ppu/cell_surface.c b/src/mesa/pipe/cell/ppu/cell_surface.c index 2c4b6e640b..1692960244 100644 --- a/src/mesa/pipe/cell/ppu/cell_surface.c +++ b/src/mesa/pipe/cell/ppu/cell_surface.c @@ -1,9 +1,106 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +/** + * Authors + * Brian Paul + */ #include <stdio.h> +#include <assert.h> +#include <stdint.h> +#include "pipe/p_inlines.h" +#include "pipe/p_util.h" +#include "pipe/cell/common.h" +#include "cell_context.h" +#include "cell_surface.h" +#include "cell_spu.h" + -void cell_create_surface(void) +struct pipe_surface * +cell_create_surface(int width, int height) { +#if 0 + /* XXX total hack */ + struct pipe_surface *ps = CALLOC_STRUCT(pipe_surface); + printf("cell_create_surface\n"); + ps->width = width; + ps->height = height; + + ps->region = CALLOC_STRUCT(pipe_region); + ps->region->map = align_malloc(width * height * 4, 16); + return ps; +#endif + return NULL; +} + + + +void +cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps, + unsigned clearValue) +{ + struct cell_context *cell = cell_context(pipe); + uint i; + + printf("%s 0x%08x\n", __FUNCTION__, clearValue); + + { + char s[100]; + pf_sprint_name(s, ps->format); + printf("format = %s\n", s); + } + + if (!ps->map) + pipe_surface_map(ps); + + for (i = 0; i < cell->num_spus; i++) { + command[i].fb.start = ps->map; + command[i].fb.width = ps->width; + command[i].fb.height = ps->height; + command[i].fb.format = ps->format; + send_mbox_message(control_ps_area[i], CELL_CMD_FRAMEBUFFER); + } + + for (i = 0; i < cell->num_spus; i++) { + command[i].clear.value = clearValue | (i << 21); + send_mbox_message(control_ps_area[i], CELL_CMD_CLEAR_TILES); + } +} + + +void +cell_set_clear_color_state(struct pipe_context *pipe, + const struct pipe_clear_color_state *clear) +{ + struct cell_context *cell = cell_context(pipe); + + cell->clear_color = *clear; /* struct copy */ } diff --git a/src/mesa/pipe/cell/ppu/cell_surface.h b/src/mesa/pipe/cell/ppu/cell_surface.h new file mode 100644 index 0000000000..8b42ba02d5 --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_surface.h @@ -0,0 +1,49 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#ifndef CELL_SURFACE +#define CELL_SURFACE + + +#include "pipe/p_state.h" + + +extern struct pipe_surface * +cell_create_surface(int width, int height); + +extern void +cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps, + unsigned clearValue); + + +extern void +cell_set_clear_color_state(struct pipe_context *pipe, + const struct pipe_clear_color_state *clear); + + +#endif /* CELL_SURFACE */ diff --git a/src/mesa/pipe/cell/ppu/cell_winsys.c b/src/mesa/pipe/cell/ppu/cell_winsys.c new file mode 100644 index 0000000000..ebabce3c8f --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_winsys.c @@ -0,0 +1,40 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#include "pipe/p_util.h" +#include "cell_winsys.h" + + +struct cell_winsys * +cell_get_winsys(uint format) +{ + struct cell_winsys *cws = CALLOC_STRUCT(cell_winsys); + if (cws) + cws->preferredFormat = format; + return cws; +} diff --git a/src/mesa/pipe/cell/ppu/cell_winsys.h b/src/mesa/pipe/cell/ppu/cell_winsys.h new file mode 100644 index 0000000000..ae2af5696b --- /dev/null +++ b/src/mesa/pipe/cell/ppu/cell_winsys.h @@ -0,0 +1,50 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +#ifndef CELL_WINSYS_H +#define CELL_WINSYS_H + +#include "pipe/p_compiler.h" + + +/** + * Very simple winsys at this time. + * Will probably eventually add SPU control info. + */ +struct cell_winsys +{ + uint preferredFormat; +}; + + +extern struct cell_winsys * +cell_get_winsys(uint format); + + + +#endif |