~ubuntu-branches/ubuntu/precise/mesa/precise-updates

« back to all changes in this revision

Viewing changes to src/gallium/drivers/cell/ppu/cell_context.c

  • Committer: Package Import Robot
  • Author(s): Robert Hooker
  • Date: 2012-02-02 12:05:48 UTC
  • mfrom: (1.7.1) (3.3.27 sid)
  • Revision ID: package-import@ubuntu.com-20120202120548-nvkma85jq0h4coix
Tags: 8.0~rc2-0ubuntu4
Drop drisearchdir handling, it is no longer needed with multiarch
and dri-alternates being removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**************************************************************************
2
 
 * 
3
 
 * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
4
 
 * All Rights Reserved.
5
 
 * 
6
 
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 
 * copy of this software and associated documentation files (the
8
 
 * "Software"), to deal in the Software without restriction, including
9
 
 * without limitation the rights to use, copy, modify, merge, publish,
10
 
 * distribute, sub license, and/or sell copies of the Software, and to
11
 
 * permit persons to whom the Software is furnished to do so, subject to
12
 
 * the following conditions:
13
 
 * 
14
 
 * The above copyright notice and this permission notice (including the
15
 
 * next paragraph) shall be included in all copies or substantial portions
16
 
 * of the Software.
17
 
 * 
18
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19
 
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
 
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21
 
 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22
 
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
 
 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
 
 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
 
 * 
26
 
 **************************************************************************/
27
 
 
28
 
/**
29
 
 * Authors
30
 
 *  Brian Paul
31
 
 */
32
 
 
33
 
 
34
 
#include <stdio.h>
35
 
 
36
 
#include "pipe/p_defines.h"
37
 
#include "pipe/p_format.h"
38
 
#include "util/u_memory.h"
39
 
#include "pipe/p_screen.h"
40
 
#include "util/u_inlines.h"
41
 
 
42
 
#include "draw/draw_context.h"
43
 
#include "draw/draw_private.h"
44
 
 
45
 
#include "cell/common.h"
46
 
#include "cell_batch.h"
47
 
#include "cell_clear.h"
48
 
#include "cell_context.h"
49
 
#include "cell_draw_arrays.h"
50
 
#include "cell_fence.h"
51
 
#include "cell_flush.h"
52
 
#include "cell_state.h"
53
 
#include "cell_surface.h"
54
 
#include "cell_spu.h"
55
 
#include "cell_pipe_state.h"
56
 
#include "cell_texture.h"
57
 
#include "cell_vbuf.h"
58
 
 
59
 
 
60
 
 
61
 
static void
62
 
cell_destroy_context( struct pipe_context *pipe )
63
 
{
64
 
   struct cell_context *cell = cell_context(pipe);
65
 
   unsigned i;
66
 
 
67
 
   for (i = 0; i < cell->num_vertex_buffers; i++) {
68
 
      pipe_resource_reference(&cell->vertex_buffer[i].buffer, NULL);
69
 
   }
70
 
 
71
 
   util_delete_keymap(cell->fragment_ops_cache, NULL);
72
 
 
73
 
   cell_spu_exit(cell);
74
 
 
75
 
   align_free(cell);
76
 
}
77
 
 
78
 
 
79
 
static struct draw_context *
80
 
cell_draw_create(struct cell_context *cell)
81
 
{
82
 
   struct draw_context *draw = draw_create(&cell->pipe);
83
 
 
84
 
#if 0 /* broken */
85
 
   if (getenv("GALLIUM_CELL_VS")) {
86
 
      /* plug in SPU-based vertex transformation code */
87
 
      draw->shader_queue_flush = cell_vertex_shader_queue_flush;
88
 
      draw->driver_private = cell;
89
 
   }
90
 
#endif
91
 
 
92
 
   return draw;
93
 
}
94
 
 
95
 
 
96
 
static const struct debug_named_value cell_debug_flags[] = {
97
 
   {"checker", CELL_DEBUG_CHECKER, NULL},/**< modulate tile clear color by SPU ID */
98
 
   {"asm", CELL_DEBUG_ASM, NULL},        /**< dump SPU asm code */
99
 
   {"sync", CELL_DEBUG_SYNC, NULL},      /**< SPUs do synchronous DMA */
100
 
   {"fragops", CELL_DEBUG_FRAGMENT_OPS, NULL}, /**< SPUs emit fragment ops debug messages*/
101
 
   {"fragopfallback", CELL_DEBUG_FRAGMENT_OP_FALLBACK, NULL}, /**< SPUs use reference implementation for fragment ops*/
102
 
   {"cmd", CELL_DEBUG_CMD, NULL},       /**< SPUs dump command buffer info */
103
 
   {"cache", CELL_DEBUG_CACHE, NULL},   /**< report texture cache stats on exit */
104
 
   DEBUG_NAMED_VALUE_END
105
 
};
106
 
 
107
 
 
108
 
struct pipe_context *
109
 
cell_create_context(struct pipe_screen *screen,
110
 
                    void *priv )
111
 
{
112
 
   struct cell_context *cell;
113
 
   uint i;
114
 
 
115
 
   /* some fields need to be 16-byte aligned, so align the whole object */
116
 
   cell = (struct cell_context*) align_malloc(sizeof(struct cell_context), 16);
117
 
   if (!cell)
118
 
      return NULL;
119
 
 
120
 
   memset(cell, 0, sizeof(*cell));
121
 
 
122
 
   cell->winsys = NULL;         /* XXX: fixme - get this from screen? */
123
 
   cell->pipe.winsys = NULL;
124
 
   cell->pipe.screen = screen;
125
 
   cell->pipe.priv = priv;
126
 
   cell->pipe.destroy = cell_destroy_context;
127
 
 
128
 
   cell->pipe.clear = cell_clear;
129
 
   cell->pipe.flush = cell_flush;
130
 
 
131
 
#if 0
132
 
   cell->pipe.begin_query = cell_begin_query;
133
 
   cell->pipe.end_query = cell_end_query;
134
 
   cell->pipe.wait_query = cell_wait_query;
135
 
#endif
136
 
 
137
 
   cell_init_draw_functions(cell);
138
 
   cell_init_state_functions(cell);
139
 
   cell_init_shader_functions(cell);
140
 
   cell_init_surface_functions(cell);
141
 
   cell_init_vertex_functions(cell);
142
 
   cell_init_texture_transfer_funcs(cell);
143
 
 
144
 
   cell->draw = cell_draw_create(cell);
145
 
 
146
 
   /* Create cache of fragment ops generated code */
147
 
   cell->fragment_ops_cache =
148
 
      util_new_keymap(sizeof(struct cell_fragment_ops_key), ~0, NULL);
149
 
 
150
 
   cell_init_vbuf(cell);
151
 
 
152
 
   draw_set_rasterize_stage(cell->draw, cell->vbuf);
153
 
 
154
 
   /* convert all points/lines to tris for the time being */
155
 
   draw_wide_point_threshold(cell->draw, 0.0);
156
 
   draw_wide_line_threshold(cell->draw, 0.0);
157
 
 
158
 
   /* get env vars or read config file to get debug flags */
159
 
   cell->debug_flags = debug_get_flags_option("CELL_DEBUG", 
160
 
                                              cell_debug_flags, 
161
 
                                              0 );
162
 
 
163
 
   for (i = 0; i < CELL_NUM_BUFFERS; i++)
164
 
      cell_fence_init(&cell->fenced_buffers[i].fence);
165
 
 
166
 
 
167
 
   /*
168
 
    * SPU stuff
169
 
    */
170
 
   /* This call only works with SDK 3.0.  Anyone still using 2.1??? */
171
 
   cell->num_cells = spe_cpu_info_get(SPE_COUNT_PHYSICAL_CPU_NODES, -1);
172
 
   cell->num_spus = spe_cpu_info_get(SPE_COUNT_USABLE_SPES, -1);
173
 
   if (cell->debug_flags) {
174
 
      printf("Cell: found %d Cell(s) with %u SPUs\n",
175
 
             cell->num_cells, cell->num_spus);
176
 
   }
177
 
   if (getenv("CELL_NUM_SPUS")) {
178
 
      cell->num_spus = atoi(getenv("CELL_NUM_SPUS"));
179
 
      assert(cell->num_spus > 0);
180
 
   }
181
 
 
182
 
   cell_start_spus(cell);
183
 
 
184
 
   cell_init_batch_buffers(cell);
185
 
 
186
 
   /* make sure SPU initializations are done before proceeding */
187
 
   cell_flush_int(cell, CELL_FLUSH_WAIT);
188
 
 
189
 
   return &cell->pipe;
190
 
}