summaryrefslogtreecommitdiff
path: root/src/gallium
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2008-02-29 13:24:31 +1100
committerBen Skeggs <skeggsb@gmail.com>2008-02-29 13:24:31 +1100
commit8c77e6f674206ef34ab15026b08e495209dcd4ea (patch)
tree7d21d99eee6970b340bc7a3afedeadfc99dd5745 /src/gallium
parent68ef52886263690632552ae187a4673945c2ab74 (diff)
parentebe3b34ad225e320a09bb4069ce4d24808386327 (diff)
Merge branch 'upstream-gallium-0.1' into nouveau-gallium-0.1
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_cache.h26
-rw-r--r--src/gallium/auxiliary/draw/Makefile4
-rw-r--r--src/gallium/auxiliary/draw/SConscript3
-rw-r--r--src/gallium/auxiliary/draw/draw_aaline.c7
-rw-r--r--src/gallium/auxiliary/draw/draw_aapoint.c8
-rw-r--r--src/gallium/auxiliary/draw/draw_clip.c8
-rw-r--r--src/gallium/auxiliary/draw/draw_context.c48
-rw-r--r--src/gallium/auxiliary/draw/draw_context.h8
-rw-r--r--src/gallium/auxiliary/draw/draw_flatshade.c8
-rw-r--r--src/gallium/auxiliary/draw/draw_private.h13
-rw-r--r--src/gallium/auxiliary/draw/draw_pstipple.c8
-rw-r--r--src/gallium/auxiliary/draw/draw_twoside.c12
-rw-r--r--src/gallium/auxiliary/draw/draw_validate.c33
-rw-r--r--src/gallium/auxiliary/draw/draw_vertex_fetch.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_vertex_shader.c17
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_exec.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_sse.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_wide_line.c187
-rw-r--r--src/gallium/auxiliary/draw/draw_wide_point.c257
-rw-r--r--src/gallium/auxiliary/draw/draw_wide_prims.c15
-rw-r--r--src/gallium/auxiliary/gallivm/gallivm.h2
-rw-r--r--src/gallium/auxiliary/gallivm/gallivm_p.h6
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer.h11
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h11
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr.h11
-rwxr-xr-xsrc/gallium/auxiliary/tgsi/exec/tgsi_sse2.c10
-rwxr-xr-xsrc/gallium/auxiliary/tgsi/exec/tgsi_sse2.h8
-rw-r--r--src/gallium/auxiliary/tgsi/util/tgsi_build.h8
-rw-r--r--src/gallium/auxiliary/tgsi/util/tgsi_dump.c18
-rw-r--r--src/gallium/auxiliary/tgsi/util/tgsi_dump.h8
-rw-r--r--src/gallium/auxiliary/tgsi/util/tgsi_parse.h8
-rw-r--r--src/gallium/auxiliary/tgsi/util/tgsi_scan.c29
-rw-r--r--src/gallium/auxiliary/tgsi/util/tgsi_scan.h15
-rw-r--r--src/gallium/auxiliary/tgsi/util/tgsi_util.h8
-rw-r--r--src/gallium/drivers/cell/ppu/Makefile1
-rw-r--r--src/gallium/drivers/cell/ppu/cell_context.c119
-rw-r--r--src/gallium/drivers/cell/ppu/cell_context.h2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_pipe_state.c3
-rw-r--r--src/gallium/drivers/cell/ppu/cell_screen.c166
-rw-r--r--src/gallium/drivers/cell/ppu/cell_screen.h41
-rw-r--r--src/gallium/drivers/cell/ppu/cell_spu.c10
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.c45
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.h4
-rw-r--r--src/gallium/drivers/cell/spu/spu_main.c2
-rw-r--r--src/gallium/drivers/cell/spu/spu_main.h3
-rw-r--r--src/gallium/drivers/cell/spu/spu_texture.c184
-rw-r--r--src/gallium/drivers/failover/fo_context.c7
-rw-r--r--src/gallium/drivers/i915simple/Makefile2
-rw-r--r--src/gallium/drivers/i915simple/SConscript2
-rw-r--r--src/gallium/drivers/i915simple/i915_context.c158
-rw-r--r--src/gallium/drivers/i915simple/i915_context.h11
-rw-r--r--src/gallium/drivers/i915simple/i915_fpc.h6
-rw-r--r--src/gallium/drivers/i915simple/i915_fpc_translate.c33
-rw-r--r--src/gallium/drivers/i915simple/i915_screen.c250
-rw-r--r--src/gallium/drivers/i915simple/i915_screen.h (renamed from src/gallium/drivers/i965simple/brw_strings.c)69
-rw-r--r--src/gallium/drivers/i915simple/i915_state.c5
-rw-r--r--src/gallium/drivers/i915simple/i915_state_derived.c12
-rw-r--r--src/gallium/drivers/i915simple/i915_texture.c54
-rw-r--r--src/gallium/drivers/i915simple/i915_texture.h7
-rw-r--r--src/gallium/drivers/i915simple/i915_winsys.h15
-rw-r--r--src/gallium/drivers/i965simple/Makefile3
-rw-r--r--src/gallium/drivers/i965simple/SConscript2
-rw-r--r--src/gallium/drivers/i965simple/brw_context.c150
-rw-r--r--src/gallium/drivers/i965simple/brw_context.h21
-rw-r--r--src/gallium/drivers/i965simple/brw_draw_upload.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_screen.c235
-rw-r--r--src/gallium/drivers/i965simple/brw_screen.h (renamed from src/gallium/drivers/i915simple/i915_strings.c)79
-rw-r--r--src/gallium/drivers/i965simple/brw_sf.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_shader_info.c5
-rw-r--r--src/gallium/drivers/i965simple/brw_state.c17
-rw-r--r--src/gallium/drivers/i965simple/brw_state.h7
-rw-r--r--src/gallium/drivers/i965simple/brw_surface.c1
-rw-r--r--src/gallium/drivers/i965simple/brw_tex_layout.c52
-rw-r--r--src/gallium/drivers/i965simple/brw_tex_layout.h32
-rw-r--r--src/gallium/drivers/i965simple/brw_vs.c4
-rw-r--r--src/gallium/drivers/i965simple/brw_vs.h2
-rw-r--r--src/gallium/drivers/i965simple/brw_vs_emit.c6
-rw-r--r--src/gallium/drivers/i965simple/brw_winsys.h4
-rw-r--r--src/gallium/drivers/i965simple/brw_wm.c4
-rw-r--r--src/gallium/drivers/i965simple/brw_wm_decl.c20
-rw-r--r--src/gallium/drivers/i965simple/brw_wm_state.c4
-rw-r--r--src/gallium/drivers/softpipe/Makefile1
-rw-r--r--src/gallium/drivers/softpipe/sp_context.c115
-rw-r--r--src/gallium/drivers/softpipe/sp_fs_llvm.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_prim_setup.c22
-rw-r--r--src/gallium/drivers/softpipe/sp_quad.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_fs.c6
-rw-r--r--src/gallium/drivers/softpipe/sp_screen.c165
-rw-r--r--src/gallium/drivers/softpipe/sp_state.h7
-rw-r--r--src/gallium/drivers/softpipe/sp_state_derived.c14
-rw-r--r--src/gallium/drivers/softpipe/sp_state_fs.c13
-rw-r--r--src/gallium/drivers/softpipe/sp_state_sampler.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c84
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.h22
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.c5
-rw-r--r--src/gallium/drivers/softpipe/sp_winsys.h8
-rw-r--r--src/gallium/include/pipe/p_context.h35
-rw-r--r--src/gallium/include/pipe/p_defines.h2
-rw-r--r--src/gallium/include/pipe/p_format.h2
-rw-r--r--src/gallium/include/pipe/p_inlines.h19
-rw-r--r--src/gallium/include/pipe/p_screen.h98
-rw-r--r--src/gallium/include/pipe/p_shader_tokens.h12
-rw-r--r--src/gallium/include/pipe/p_state.h8
-rw-r--r--src/gallium/winsys/dri/intel/intel_context.h3
-rw-r--r--src/gallium/winsys/dri/intel/intel_winsys_i915.c10
-rw-r--r--src/gallium/winsys/dri/intel/intel_winsys_softpipe.c3
-rw-r--r--src/gallium/winsys/xlib/xm_winsys.c9
-rw-r--r--src/gallium/winsys/xlib/xm_winsys_aub.c4
108 files changed, 2222 insertions, 1137 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.h b/src/gallium/auxiliary/cso_cache/cso_cache.h
index 3b0fe100b8..44ee128a4a 100644
--- a/src/gallium/auxiliary/cso_cache/cso_cache.h
+++ b/src/gallium/auxiliary/cso_cache/cso_cache.h
@@ -88,44 +88,44 @@ struct cso_cache;
struct cso_blend {
struct pipe_blend_state state;
- void *data;
- void (*delete_state)(void *, void *);
- void *context;
+ void *data;
+ void (*delete_state)(struct pipe_context *, void *);
+ struct pipe_context *context;
};
struct cso_depth_stencil_alpha {
struct pipe_depth_stencil_alpha_state state;
void *data;
- void (*delete_state)(void *, void *);
- void *context;
+ void (*delete_state)(struct pipe_context *, void *);
+ struct pipe_context *context;
};
struct cso_rasterizer {
struct pipe_rasterizer_state state;
void *data;
- void (*delete_state)(void *, void *);
- void *context;
+ void (*delete_state)(struct pipe_context *, void *);
+ struct pipe_context *context;
};
struct cso_fragment_shader {
struct pipe_shader_state state;
void *data;
- void (*delete_state)(void *, void *);
- void *context;
+ void (*delete_state)(struct pipe_context *, void *);
+ struct pipe_context *context;
};
struct cso_vertex_shader {
struct pipe_shader_state state;
void *data;
- void (*delete_state)(void *, void *);
- void *context;
+ void (*delete_state)(struct pipe_context *, void *);
+ struct pipe_context *context;
};
struct cso_sampler {
struct pipe_sampler_state state;
void *data;
- void (*delete_state)(void *, void *);
- void *context;
+ void (*delete_state)(struct pipe_context *, void *);
+ struct pipe_context *context;
};
diff --git a/src/gallium/auxiliary/draw/Makefile b/src/gallium/auxiliary/draw/Makefile
index c9980f0b83..2daa1636f3 100644
--- a/src/gallium/auxiliary/draw/Makefile
+++ b/src/gallium/auxiliary/draw/Makefile
@@ -29,7 +29,9 @@ C_SOURCES = \
draw_vf.c \
draw_vf_generic.c \
draw_vf_sse.c \
- draw_wide_prims.c
+ draw_wide_line.c \
+ draw_wide_point.c
+
include ../../Makefile.template
diff --git a/src/gallium/auxiliary/draw/SConscript b/src/gallium/auxiliary/draw/SConscript
index 3302dc44f7..c18dcb2927 100644
--- a/src/gallium/auxiliary/draw/SConscript
+++ b/src/gallium/auxiliary/draw/SConscript
@@ -28,7 +28,8 @@ draw = env.ConvenienceLibrary(
'draw_vf.c',
'draw_vf_generic.c',
'draw_vf_sse.c',
- 'draw_wide_prims.c',
+ 'draw_wide_point.c',
+ 'draw_wide_line.c'
])
auxiliaries.insert(0, draw)
diff --git a/src/gallium/auxiliary/draw/draw_aaline.c b/src/gallium/auxiliary/draw/draw_aaline.c
index 73a02a32e4..51140388f0 100644
--- a/src/gallium/auxiliary/draw/draw_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_aaline.c
@@ -340,9 +340,11 @@ generate_aaline_fs(struct aaline_stage *aaline)
tgsi_dump(aaline_fs.tokens, 0);
#endif
+#if 1 /* XXX remove */
aaline_fs.input_semantic_name[aaline_fs.num_inputs] = TGSI_SEMANTIC_GENERIC;
aaline_fs.input_semantic_index[aaline_fs.num_inputs] = transform.maxGeneric + 1;
aaline_fs.num_inputs++;
+#endif
aaline->fs->aaline_fs
= aaline->driver_create_fs_state(aaline->pipe, &aaline_fs);
@@ -362,6 +364,7 @@ static void
aaline_create_texture(struct aaline_stage *aaline)
{
struct pipe_context *pipe = aaline->pipe;
+ struct pipe_screen *screen = pipe->screen;
struct pipe_texture texTemp;
uint level;
@@ -374,7 +377,7 @@ aaline_create_texture(struct aaline_stage *aaline)
texTemp.depth[0] = 1;
texTemp.cpp = 1;
- aaline->texture = pipe->texture_create(pipe, &texTemp);
+ aaline->texture = screen->texture_create(screen, &texTemp);
/* Fill in mipmap images.
* Basically each level is solid opaque, except for the outermost
@@ -388,7 +391,7 @@ aaline_create_texture(struct aaline_stage *aaline)
assert(aaline->texture->width[level] == aaline->texture->height[level]);
- surface = pipe->get_tex_surface(pipe, aaline->texture, 0, level, 0);
+ surface = screen->get_tex_surface(screen, aaline->texture, 0, level, 0);
data = pipe_surface_map(surface);
for (i = 0; i < size; i++) {
diff --git a/src/gallium/auxiliary/draw/draw_aapoint.c b/src/gallium/auxiliary/draw/draw_aapoint.c
index cae6fcd4d2..d48a416899 100644
--- a/src/gallium/auxiliary/draw/draw_aapoint.c
+++ b/src/gallium/auxiliary/draw/draw_aapoint.c
@@ -509,14 +509,16 @@ generate_aapoint_fs(struct aapoint_stage *aapoint)
(struct tgsi_token *) aapoint_fs.tokens,
MAX, &transform.base);
-#if 1 /* DEBUG */
+#if 0 /* DEBUG */
tgsi_dump(orig_fs->tokens, 0);
tgsi_dump(aapoint_fs.tokens, 0);
#endif
+#if 1 /* XXX remove */
aapoint_fs.input_semantic_name[aapoint_fs.num_inputs] = TGSI_SEMANTIC_GENERIC;
aapoint_fs.input_semantic_index[aapoint_fs.num_inputs] = transform.maxGeneric + 1;
aapoint_fs.num_inputs++;
+#endif
aapoint->fs->aapoint_fs
= aapoint->driver_create_fs_state(aapoint->pipe, &aapoint_fs);
@@ -694,8 +696,8 @@ aapoint_first_point(struct draw_stage *stage, struct prim_header *header)
/* find PSIZ vertex output */
const struct draw_vertex_shader *vs = draw->vertex_shader;
uint i;
- for (i = 0; i < vs->state->num_outputs; i++) {
- if (vs->state->output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) {
+ for (i = 0; i < vs->info.num_outputs; i++) {
+ if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) {
aapoint->psize_slot = i;
break;
}
diff --git a/src/gallium/auxiliary/draw/draw_clip.c b/src/gallium/auxiliary/draw/draw_clip.c
index e3051507ea..200152ecab 100644
--- a/src/gallium/auxiliary/draw/draw_clip.c
+++ b/src/gallium/auxiliary/draw/draw_clip.c
@@ -409,13 +409,13 @@ clip_init_state( struct draw_stage *stage )
clipper->flat = stage->draw->rasterizer->flatshade ? TRUE : FALSE;
if (clipper->flat) {
- const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
+ const struct draw_vertex_shader *vs = stage->draw->vertex_shader;
uint i;
clipper->num_color_attribs = 0;
- for (i = 0; i < vs->num_outputs; i++) {
- if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
- vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
+ for (i = 0; i < vs->info.num_outputs; i++) {
+ if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
+ vs->info.output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
clipper->color_attribs[clipper->num_color_attribs++] = i;
}
}
diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c
index 7dd1c6f6fa..428b6209e0 100644
--- a/src/gallium/auxiliary/draw/draw_context.c
+++ b/src/gallium/auxiliary/draw/draw_context.c
@@ -48,7 +48,8 @@ struct draw_context *draw_create( void )
#endif
/* create pipeline stages */
- draw->pipeline.wide = draw_wide_stage( draw );
+ draw->pipeline.wide_line = draw_wide_line_stage( draw );
+ draw->pipeline.wide_point = draw_wide_point_stage( draw );
draw->pipeline.stipple = draw_stipple_stage( draw );
draw->pipeline.unfilled = draw_unfilled_stage( draw );
draw->pipeline.twoside = draw_twoside_stage( draw );
@@ -80,8 +81,9 @@ struct draw_context *draw_create( void )
draw->shader_queue_flush = draw_vertex_shader_queue_flush;
- draw->convert_wide_points = TRUE;
- draw->convert_wide_lines = TRUE;
+ /* these defaults are oriented toward the needs of softpipe */
+ draw->wide_point_threshold = 1000000.0; /* infinity */
+ draw->wide_line_threshold = 1.0;
draw->reduced_prim = ~0; /* != any of PIPE_PRIM_x */
@@ -94,7 +96,8 @@ struct draw_context *draw_create( void )
void draw_destroy( struct draw_context *draw )
{
- draw->pipeline.wide->destroy( draw->pipeline.wide );
+ draw->pipeline.wide_line->destroy( draw->pipeline.wide_line );
+ draw->pipeline.wide_point->destroy( draw->pipeline.wide_point );
draw->pipeline.stipple->destroy( draw->pipeline.stipple );
draw->pipeline.unfilled->destroy( draw->pipeline.unfilled );
draw->pipeline.twoside->destroy( draw->pipeline.twoside );
@@ -220,26 +223,26 @@ draw_set_mapped_constant_buffer(struct draw_context *draw,
/**
- * Tells the draw module whether to convert wide points (size != 1)
- * into triangles.
+ * Tells the draw module to draw points with triangles if their size
+ * is greater than this threshold.
*/
void
-draw_convert_wide_points(struct draw_context *draw, boolean enable)
+draw_wide_point_threshold(struct draw_context *draw, float threshold)
{
draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
- draw->convert_wide_points = enable;
+ draw->wide_point_threshold = threshold;
}
/**
- * Tells the draw module whether to convert wide lines (width != 1)
- * into triangles.
+ * Tells the draw module to draw lines with triangles if their width
+ * is greater than this threshold.
*/
void
-draw_convert_wide_lines(struct draw_context *draw, boolean enable)
+draw_wide_line_threshold(struct draw_context *draw, float threshold)
{
draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
- draw->convert_wide_lines = enable;
+ draw->wide_line_threshold = threshold;
}
@@ -262,11 +265,11 @@ int
draw_find_vs_output(struct draw_context *draw,
uint semantic_name, uint semantic_index)
{
- const struct pipe_shader_state *vs = draw->vertex_shader->state;
+ const struct draw_vertex_shader *vs = draw->vertex_shader;
uint i;
- for (i = 0; i < vs->num_outputs; i++) {
- if (vs->output_semantic_name[i] == semantic_name &&
- vs->output_semantic_index[i] == semantic_index)
+ 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;
}
@@ -282,6 +285,19 @@ draw_find_vs_output(struct draw_context *draw,
/**
+ * Return number of vertex shader outputs.
+ */
+uint
+draw_num_vs_outputs(struct draw_context *draw)
+{
+ uint count = draw->vertex_shader->info.num_outputs;
+ if (draw->extra_vp_outputs.slot >= 0)
+ count++;
+ return count;
+}
+
+
+/**
* Allocate space for temporary post-transform vertices, such as for clipping.
*/
void draw_alloc_temp_verts( struct draw_stage *stage, unsigned nr )
diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h
index c25301f71d..ab87b4127c 100644
--- a/src/gallium/auxiliary/draw/draw_context.h
+++ b/src/gallium/auxiliary/draw/draw_context.h
@@ -90,9 +90,9 @@ void draw_set_rasterizer_state( struct draw_context *draw,
void draw_set_rasterize_stage( struct draw_context *draw,
struct draw_stage *stage );
-void draw_convert_wide_points(struct draw_context *draw, boolean enable);
+void draw_wide_point_threshold(struct draw_context *draw, float threshold);
-void draw_convert_wide_lines(struct draw_context *draw, boolean enable);
+void draw_wide_line_threshold(struct draw_context *draw, float threshold);
boolean draw_use_sse(struct draw_context *draw);
@@ -110,6 +110,10 @@ int
draw_find_vs_output(struct draw_context *draw,
uint semantic_name, uint semantic_index);
+uint
+draw_num_vs_outputs(struct draw_context *draw);
+
+
/*
* Vertex shader functions
diff --git a/src/gallium/auxiliary/draw/draw_flatshade.c b/src/gallium/auxiliary/draw/draw_flatshade.c
index 4398abbc60..ccad71d695 100644
--- a/src/gallium/auxiliary/draw/draw_flatshade.c
+++ b/src/gallium/auxiliary/draw/draw_flatshade.c
@@ -128,14 +128,14 @@ static void flatshade_point( struct draw_stage *stage,
static void flatshade_init_state( struct draw_stage *stage )
{
struct flat_stage *flat = flat_stage(stage);
- const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
+ const struct draw_vertex_shader *vs = stage->draw->vertex_shader;
uint i;
/* Find which vertex shader outputs are colors, make a list */
flat->num_color_attribs = 0;
- for (i = 0; i < vs->num_outputs; i++) {
- if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
- vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
+ for (i = 0; i < vs->info.num_outputs; i++) {
+ if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
+ vs->info.output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
flat->color_attribs[flat->num_color_attribs++] = i;
}
}
diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h
index 6abced139b..c732d723a7 100644
--- a/src/gallium/auxiliary/draw/draw_private.h
+++ b/src/gallium/auxiliary/draw/draw_private.h
@@ -46,6 +46,7 @@
#include "rtasm/rtasm_x86sse.h"
#include "tgsi/exec/tgsi_exec.h"
+#include "tgsi/util/tgsi_scan.h"
struct pipe_context;
@@ -134,6 +135,8 @@ struct draw_vertex_shader {
*/
const struct pipe_shader_state *state;
+ struct tgsi_shader_info info;
+
void (*prepare)( struct draw_vertex_shader *shader,
struct draw_context *draw );
@@ -183,7 +186,8 @@ struct draw_context
struct draw_stage *aapoint;
struct draw_stage *aaline;
struct draw_stage *pstipple;
- struct draw_stage *wide;
+ struct draw_stage *wide_line;
+ struct draw_stage *wide_point;
struct draw_stage *rasterize;
} pipeline;
@@ -215,8 +219,8 @@ struct draw_context
float plane[12][4];
unsigned nr_planes;
- boolean convert_wide_points; /**< convert wide points to tris? */
- boolean convert_wide_lines; /**< convert wide lines to tris? */
+ float wide_point_threshold; /**< convert pnts to tris if larger than this */
+ float wide_line_threshold; /**< convert lines to tris if wider than this */
boolean use_sse;
/* If a prim stage introduces new vertex attributes, they'll be stored here
@@ -301,7 +305,8 @@ extern struct draw_stage *draw_clip_stage( struct draw_context *context );
extern struct draw_stage *draw_flatshade_stage( struct draw_context *context );
extern struct draw_stage *draw_cull_stage( struct draw_context *context );
extern struct draw_stage *draw_stipple_stage( struct draw_context *context );
-extern struct draw_stage *draw_wide_stage( struct draw_context *context );
+extern struct draw_stage *draw_wide_line_stage( struct draw_context *context );
+extern struct draw_stage *draw_wide_point_stage( struct draw_context *context );
extern struct draw_stage *draw_validate_stage( struct draw_context *context );
diff --git a/src/gallium/auxiliary/draw/draw_pstipple.c b/src/gallium/auxiliary/draw/draw_pstipple.c
index 1ab04cd959..f6200aa820 100644
--- a/src/gallium/auxiliary/draw/draw_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pstipple.c
@@ -330,11 +330,13 @@ generate_pstip_fs(struct pstip_stage *pstip)
pstip->sampler_unit = transform.maxSampler + 1;
+#if 1 /* XXX remove */
if (transform.wincoordInput < 0) {
pstip_fs.input_semantic_name[pstip_fs.num_inputs] = TGSI_SEMANTIC_POSITION;
pstip_fs.input_semantic_index[pstip_fs.num_inputs] = (ubyte)transform.maxInput;
pstip_fs.num_inputs++;
}
+#endif
pstip->fs->pstip_fs = pstip->driver_create_fs_state(pstip->pipe, &pstip_fs);
}
@@ -348,12 +350,13 @@ pstip_update_texture(struct pstip_stage *pstip)
{
static const uint bit31 = 1 << 31;
struct pipe_context *pipe = pstip->pipe;
+ struct pipe_screen *screen = pipe->screen;
struct pipe_surface *surface;
const uint *stipple = pstip->state.stipple->stipple;
uint i, j;
ubyte *data;
- surface = pipe->get_tex_surface(pipe, pstip->texture, 0, 0, 0);
+ surface = screen->get_tex_surface(screen, pstip->texture, 0, 0, 0);
data = pipe_surface_map(surface);
/*
@@ -389,6 +392,7 @@ static void
pstip_create_texture(struct pstip_stage *pstip)
{
struct pipe_context *pipe = pstip->pipe;
+ struct pipe_screen *screen = pipe->screen;
struct pipe_texture texTemp;
memset(&texTemp, 0, sizeof(texTemp));
@@ -400,7 +404,7 @@ pstip_create_texture(struct pstip_stage *pstip)
texTemp.depth[0] = 1;
texTemp.cpp = 1;
- pstip->texture = pipe->texture_create(pipe, &texTemp);
+ pstip->texture = screen->texture_create(screen, &texTemp);
//pstip_update_texture(pstip);
}
diff --git a/src/gallium/auxiliary/draw/draw_twoside.c b/src/gallium/auxiliary/draw/draw_twoside.c
index 1c38957987..3debaac282 100644
--- a/src/gallium/auxiliary/draw/draw_twoside.c
+++ b/src/gallium/auxiliary/draw/draw_twoside.c
@@ -119,7 +119,7 @@ static void twoside_first_tri( struct draw_stage *stage,
struct prim_header *header )
{
struct twoside_stage *twoside = twoside_stage(stage);
- const struct pipe_shader_state *vs = stage->draw->vertex_shader->state;
+ const struct draw_vertex_shader *vs = stage->draw->vertex_shader;
uint i;
twoside->attrib_front0 = 0;
@@ -128,15 +128,15 @@ static void twoside_first_tri( struct draw_stage *stage,
twoside->attrib_back1 = 0;
/* Find which vertex shader outputs are front/back colors */
- for (i = 0; i < vs->num_outputs; i++) {
- if (vs->output_semantic_name[i] == TGSI_SEMANTIC_COLOR) {
- if (vs->output_semantic_index[i] == 0)
+ for (i = 0; i < vs->info.num_outputs; i++) {
+ if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_COLOR) {
+ if (vs->info.output_semantic_index[i] == 0)
twoside->attrib_front0 = i;
else
twoside->attrib_front1 = i;
}
- if (vs->output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
- if (vs->output_semantic_index[i] == 0)
+ if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
+ if (vs->info.output_semantic_index[i] == 0)
twoside->attrib_back0 = i;
else
twoside->attrib_back1 = i;
diff --git a/src/gallium/auxiliary/draw/draw_validate.c b/src/gallium/auxiliary/draw/draw_validate.c
index 3a19dd4cd7..084eee9b6e 100644
--- a/src/gallium/auxiliary/draw/draw_validate.c
+++ b/src/gallium/auxiliary/draw/draw_validate.c
@@ -52,6 +52,18 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
*/
stage->next = next;
+ /* drawing wide lines? */
+ wide_lines = (draw->rasterizer->line_width > draw->wide_line_threshold
+ && !draw->rasterizer->line_smooth);
+
+ /* drawing large points? */
+ if (draw->rasterizer->point_smooth && draw->pipeline.aapoint)
+ wide_points = FALSE;
+ else if (draw->rasterizer->point_size > draw->wide_point_threshold)
+ wide_points = TRUE;
+ else
+ wide_points = FALSE;
+
/*
* NOTE: we build up the pipeline in end-to-start order.
*
@@ -69,21 +81,14 @@ static struct draw_stage *validate_pipeline( struct draw_stage *stage )
next = draw->pipeline.aapoint;
}
- /* drawing wide lines? */
- wide_lines = (draw->rasterizer->line_width != 1.0
- && draw->convert_wide_lines
- && !draw->rasterizer->line_smooth);
+ if (wide_lines) {
+ draw->pipeline.wide_line->next = next;
+ next = draw->pipeline.wide_line;
+ }
- /* drawing large points? */
- wide_points = (draw->rasterizer->point_size != 1.0
- && draw->convert_wide_points
- && !draw->pipeline.aapoint);
-
- if (wide_lines ||
- wide_points ||
- draw->rasterizer->point_sprite) {
- draw->pipeline.wide->next = next;
- next = draw->pipeline.wide;
+ if (wide_points || draw->rasterizer->point_sprite) {
+ draw->pipeline.wide_point->next = next;
+ next = draw->pipeline.wide_point;
}
if (draw->rasterizer->line_stipple_enable) {
diff --git a/src/gallium/auxiliary/draw/draw_vertex_fetch.c b/src/gallium/auxiliary/draw/draw_vertex_fetch.c
index e13df04605..cb8cdd04a3 100644
--- a/src/gallium/auxiliary/draw/draw_vertex_fetch.c
+++ b/src/gallium/auxiliary/draw/draw_vertex_fetch.c
@@ -473,7 +473,7 @@ void draw_update_vertex_fetch( struct draw_context *draw )
if (!draw->vertex_shader)
return;
- nr_attrs = draw->vertex_shader->state->num_inputs;
+ nr_attrs = draw->vertex_shader->info.num_inputs;
for (i = 0; i < nr_attrs; i++) {
unsigned buf = draw->vertex_element[i].vertex_buffer_index;
diff --git a/src/gallium/auxiliary/draw/draw_vertex_shader.c b/src/gallium/auxiliary/draw/draw_vertex_shader.c
index 5d2f5c9c43..1e95355555 100644
--- a/src/gallium/auxiliary/draw/draw_vertex_shader.c
+++ b/src/gallium/auxiliary/draw/draw_vertex_shader.c
@@ -91,15 +91,16 @@ draw_create_vertex_shader(struct draw_context *draw,
struct draw_vertex_shader *vs;
vs = draw_create_vs_llvm( draw, shader );
- if (vs)
- return vs;
+ if (!vs) {
+ vs = draw_create_vs_sse( draw, shader );
+ if (!vs) {
+ vs = draw_create_vs_exec( draw, shader );
+ }
+ }
+ assert(vs);
- vs = draw_create_vs_sse( draw, shader );
- if (vs)
- return vs;
+ tgsi_scan_shader(shader->tokens, &vs->info);
- vs = draw_create_vs_exec( draw, shader );
- assert(vs);
return vs;
}
@@ -111,7 +112,7 @@ draw_bind_vertex_shader(struct draw_context *draw,
draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
draw->vertex_shader = dvs;
- draw->num_vs_outputs = dvs->state->num_outputs;
+ draw->num_vs_outputs = dvs->info.num_outputs;
tgsi_exec_machine_init(&draw->machine);
diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c
index 8588879400..583812aadd 100644
--- a/src/gallium/auxiliary/draw/draw_vs_exec.c
+++ b/src/gallium/auxiliary/draw/draw_vs_exec.c
@@ -103,7 +103,7 @@ vs_exec_run( struct draw_vertex_shader *shader,
const float *trans = draw->viewport.translate;
assert(count <= 4);
- assert(draw->vertex_shader->state->output_semantic_name[0]
+ assert(draw->vertex_shader->info.output_semantic_name[0]
== TGSI_SEMANTIC_POSITION);
machine->Consts = (float (*)[4]) draw->user.constants;
diff --git a/src/gallium/auxiliary/draw/draw_vs_sse.c b/src/gallium/auxiliary/draw/draw_vs_sse.c
index 11ef0c503d..0b8bc2bf14 100644
--- a/src/gallium/auxiliary/draw/draw_vs_sse.c
+++ b/src/gallium/auxiliary/draw/draw_vs_sse.c
@@ -119,7 +119,7 @@ vs_sse_run( struct draw_vertex_shader *base,
const float *trans = draw->viewport.translate;
assert(count <= 4);
- assert(draw->vertex_shader->state->output_semantic_name[0]
+ assert(draw->vertex_shader->info.output_semantic_name[0]
== TGSI_SEMANTIC_POSITION);
/* Consts does not require 16 byte alignment. */
diff --git a/src/gallium/auxiliary/draw/draw_wide_line.c b/src/gallium/auxiliary/draw/draw_wide_line.c
new file mode 100644
index 0000000000..946a983f00
--- /dev/null
+++ b/src/gallium/auxiliary/draw/draw_wide_line.c
@@ -0,0 +1,187 @@
+/**************************************************************************
+ *
+ * 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 "pipe/p_defines.h"
+#include "pipe/p_shader_tokens.h"
+#include "draw_private.h"
+
+
+struct wideline_stage {
+ struct draw_stage stage;
+
+ float half_line_width;
+};
+
+
+
+static INLINE struct wideline_stage *wideline_stage( struct draw_stage *stage )
+{
+ return (struct wideline_stage *)stage;
+}
+
+
+static void wideline_point( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ stage->next->point( stage->next, header );
+}
+
+
+static void wideline_tri( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ stage->next->tri(stage->next, header);
+}
+
+
+/**
+ * Draw a wide line by drawing a quad (two triangles).
+ * XXX need to disable polygon stipple.
+ */
+static void wideline_line( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ /*const struct wideline_stage *wide = wideline_stage(stage);*/
+ const float half_width = 0.5f * stage->draw->rasterizer->line_width;
+
+ struct prim_header tri;
+
+ struct vertex_header *v0 = dup_vert(stage, header->v[0], 0);
+ struct vertex_header *v1 = dup_vert(stage, header->v[0], 1);
+ struct vertex_header *v2 = dup_vert(stage, header->v[1], 2);
+ struct vertex_header *v3 = dup_vert(stage, header->v[1], 3);
+
+ float *pos0 = v0->data[0];
+ float *pos1 = v1->data[0];
+ float *pos2 = v2->data[0];
+ float *pos3 = v3->data[0];
+
+ const float dx = FABSF(pos0[0] - pos2[0]);
+ const float dy = FABSF(pos0[1] - pos2[1]);
+
+ /*
+ * Draw wide line as a quad (two tris) by "stretching" the line along
+ * X or Y.
+ * We need to tweak coords in several ways to be conformant here.
+ */
+
+ if (dx > dy) {
+ /* x-major line */
+ pos0[1] = pos0[1] - half_width - 0.25f;
+ pos1[1] = pos1[1] + half_width - 0.25f;
+ pos2[1] = pos2[1] - half_width - 0.25f;
+ pos3[1] = pos3[1] + half_width - 0.25f;
+ if (pos0[0] < pos2[0]) {
+ /* left to right line */
+ pos0[0] -= 0.5f;
+ pos1[0] -= 0.5f;
+ pos2[0] -= 0.5f;
+ pos3[0] -= 0.5f;
+ }
+ else {
+ /* right to left line */
+ pos0[0] += 0.5f;
+ pos1[0] += 0.5f;
+ pos2[0] += 0.5f;
+ pos3[0] += 0.5f;
+ }
+ }
+ else {
+ /* y-major line */
+ pos0[0] = pos0[0] - half_width + 0.25f;
+ pos1[0] = pos1[0] + half_width + 0.25f;
+ pos2[0] = pos2[0] - half_width + 0.25f;
+ pos3[0] = pos3[0] + half_width + 0.25f;
+ if (pos0[1] < pos2[1]) {
+ /* top to bottom line */
+ pos0[1] -= 0.5f;
+ pos1[1] -= 0.5f;
+ pos2[1] -= 0.5f;
+ pos3[1] -= 0.5f;
+ }
+ else {
+ /* bottom to top line */
+ pos0[1] += 0.5f;
+ pos1[1] += 0.5f;
+ pos2[1] += 0.5f;
+ pos3[1] += 0.5f;
+ }
+ }
+
+ tri.det = header->det; /* only the sign matters */
+ tri.v[0] = v0;
+ tri.v[1] = v2;
+ tri.v[2] = v3;
+ stage->next->tri( stage->next, &tri );
+
+ tri.v[0] = v0;
+ tri.v[1] = v3;
+ tri.v[2] = v1;
+ stage->next->tri( stage->next, &tri );
+}
+
+
+static void wideline_flush( struct draw_stage *stage, unsigned flags )
+{
+ stage->next->flush( stage->next, flags );
+}
+
+
+static void wideline_reset_stipple_counter( struct draw_stage *stage )
+{
+ stage->next->reset_stipple_counter( stage->next );
+}
+
+
+static void wideline_destroy( struct draw_stage *stage )
+{
+ draw_free_temp_verts( stage );
+ FREE( stage );
+}
+
+
+struct draw_stage *draw_wide_line_stage( struct draw_context *draw )
+{
+ struct wideline_stage *wide = CALLOC_STRUCT(wideline_stage);
+
+ draw_alloc_temp_verts( &wide->stage, 4 );
+
+ wide->stage.draw = draw;
+ wide->stage.next = NULL;
+ wide->stage.point = wideline_point;
+ wide->stage.line = wideline_line;
+ wide->stage.tri = wideline_tri;
+ wide->stage.flush = wideline_flush;
+ wide->stage.reset_stipple_counter = wideline_reset_stipple_counter;
+ wide->stage.destroy = wideline_destroy;
+
+ return &wide->stage;
+}
diff --git a/src/gallium/auxiliary/draw/draw_wide_point.c b/src/gallium/auxiliary/draw/draw_wide_point.c
new file mode 100644
index 0000000000..8f877a102a
--- /dev/null
+++ b/src/gallium/auxiliary/draw/draw_wide_point.c
@@ -0,0 +1,257 @@
+/**************************************************************************
+ *
+ * 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 "pipe/p_defines.h"
+#include "pipe/p_shader_tokens.h"
+#include "draw_private.h"
+
+
+struct widepoint_stage {
+ struct draw_stage stage;
+
+ float half_point_size;
+
+ uint texcoord_slot[PIPE_MAX_SHADER_OUTPUTS];
+ uint texcoord_mode[PIPE_MAX_SHADER_OUTPUTS];
+ uint num_texcoords;
+
+ int psize_slot;
+};
+
+
+
+static INLINE struct widepoint_stage *
+widepoint_stage( struct draw_stage *stage )
+{
+ return (struct widepoint_stage *)stage;
+}
+
+
+static void passthrough_point( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ stage->next->point( stage->next, header );
+}
+
+static void widepoint_line( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ stage->next->line(stage->next, header);
+}
+
+static void widepoint_tri( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ stage->next->tri(stage->next, header);
+}
+
+
+/**
+ * Set the vertex texcoords for sprite mode.
+ * Coords may be left untouched or set to a right-side-up or upside-down
+ * orientation.
+ */
+static void set_texcoords(const struct widepoint_stage *wide,
+ struct vertex_header *v, const float tc[4])
+{
+ uint i;
+ for (i = 0; i < wide->num_texcoords; i++) {
+ if (wide->texcoord_mode[i] != PIPE_SPRITE_COORD_NONE) {
+ uint j = wide->texcoord_slot[i];
+ v->data[j][0] = tc[0];
+ if (wide->texcoord_mode[i] == PIPE_SPRITE_COORD_LOWER_LEFT)
+ v->data[j][1] = 1.0f - tc[1];
+ else
+ v->data[j][1] = tc[1];
+ v->data[j][2] = tc[2];
+ v->data[j][3] = tc[3];
+ }
+ }
+}
+
+
+/* If there are lots of sprite points (and why wouldn't there be?) it
+ * would probably be more sensible to change hardware setup to
+ * optimize this rather than doing the whole thing in software like
+ * this.
+ */
+static void widepoint_point( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ const struct widepoint_stage *wide = widepoint_stage(stage);
+ const boolean sprite = (boolean) stage->draw->rasterizer->point_sprite;
+ float half_size;
+ float left_adj, right_adj;
+
+ struct prim_header tri;
+
+ /* four dups of original vertex */
+ struct vertex_header *v0 = dup_vert(stage, header->v[0], 0);
+ struct vertex_header *v1 = dup_vert(stage, header->v[0], 1);
+ struct vertex_header *v2 = dup_vert(stage, header->v[0], 2);
+ struct vertex_header *v3 = dup_vert(stage, header->v[0], 3);
+
+ float *pos0 = v0->data[0];
+ float *pos1 = v1->data[0];
+ float *pos2 = v2->data[0];
+ float *pos3 = v3->data[0];
+
+ /* point size is either per-vertex or fixed size */
+ if (wide->psize_slot >= 0) {
+ half_size = 0.5f * header->v[0]->data[wide->psize_slot][0];
+ }
+ else {
+ half_size = wide->half_point_size;
+ }
+
+ left_adj = -half_size; /* + 0.25f;*/
+ right_adj = half_size; /* + 0.25f;*/
+
+ pos0[0] += left_adj;
+ pos0[1] -= half_size;
+
+ pos1[0] += left_adj;
+ pos1[1] += half_size;
+
+ pos2[0] += right_adj;
+ pos2[1] -= half_size;
+
+ pos3[0] += right_adj;
+ pos3[1] += half_size;
+
+ if (sprite) {
+ static const float tex00[4] = { 0, 0, 0, 1 };
+ static const float tex01[4] = { 0, 1, 0, 1 };
+ static const float tex11[4] = { 1, 1, 0, 1 };
+ static const float tex10[4] = { 1, 0, 0, 1 };
+ set_texcoords( wide, v0, tex00 );
+ set_texcoords( wide, v1, tex01 );
+ set_texcoords( wide, v2, tex10 );
+ set_texcoords( wide, v3, tex11 );
+ }
+
+ tri.det = header->det; /* only the sign matters */
+ tri.v[0] = v0;
+ tri.v[1] = v2;
+ tri.v[2] = v3;
+ stage->next->tri( stage->next, &tri );
+
+ tri.v[0] = v0;
+ tri.v[1] = v3;
+ tri.v[2] = v1;
+ stage->next->tri( stage->next, &tri );
+}
+
+
+static void widepoint_first_point( struct draw_stage *stage,
+ struct prim_header *header )
+{
+ struct widepoint_stage *wide = widepoint_stage(stage);
+ struct draw_context *draw = stage->draw;
+
+ wide->half_point_size = 0.5f * draw->rasterizer->point_size;
+
+ /* XXX we won't know the real size if it's computed by the vertex shader! */
+ if (draw->rasterizer->point_size > draw->wide_point_threshold) {
+ stage->point = widepoint_point;
+ }
+ else {
+ stage->point = passthrough_point;
+ }
+
+ if (draw->rasterizer->point_sprite) {
+ /* find vertex shader texcoord outputs */
+ const struct draw_vertex_shader *vs = draw->vertex_shader;
+ uint i, j = 0;
+ for (i = 0; i < vs->info.num_outputs; i++) {
+ if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_GENERIC) {
+ wide->texcoord_slot[j] = i;
+ wide->texcoord_mode[j] = draw->rasterizer->sprite_coord_mode[j];
+ j++;
+ }
+ }
+ wide->num_texcoords = j;
+ }
+
+ wide->psize_slot = -1;
+ if (draw->rasterizer->point_size_per_vertex) {
+ /* find PSIZ vertex output */
+ const struct draw_vertex_shader *vs = draw->vertex_shader;
+ uint i;
+ for (i = 0; i < vs->info.num_outputs; i++) {
+ if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) {
+ wide->psize_slot = i;
+ break;
+ }
+ }
+ }
+
+ stage->point( stage, header );
+}
+
+
+static void widepoint_flush( struct draw_stage *stage, unsigned flags )
+{
+ stage->point = widepoint_first_point;
+ stage->next->flush( stage->next, flags );
+}
+
+
+static void widepoint_reset_stipple_counter( struct draw_stage *stage )
+{
+ stage->next->reset_stipple_counter( stage->next );
+}
+
+
+static void widepoint_destroy( struct draw_stage *stage )
+{
+ draw_free_temp_verts( stage );
+ FREE( stage );
+}
+
+
+struct draw_stage *draw_wide_point_stage( struct draw_context *draw )
+{
+ struct widepoint_stage *wide = CALLOC_STRUCT(widepoint_stage);
+
+ draw_alloc_temp_verts( &wide->stage, 4 );
+
+ wide->stage.draw = draw;
+ wide->stage.next = NULL;
+ wide->stage.point = widepoint_first_point;
+ wide->stage.line = widepoint_line;
+ wide->stage.tri = widepoint_tri;
+ wide->stage.flush = widepoint_flush;
+ wide->stage.reset_stipple_counter = widepoint_reset_stipple_counter;
+ wide->stage.destroy = widepoint_destroy;
+
+ return &wide->stage;
+}
diff --git a/src/gallium/auxiliary/draw/draw_wide_prims.c b/src/gallium/auxiliary/draw/draw_wide_prims.c
index 1f8069bdca..d6bff110b4 100644
--- a/src/gallium/auxiliary/draw/draw_wide_prims.c
+++ b/src/gallium/auxiliary/draw/draw_wide_prims.c
@@ -219,8 +219,8 @@ static void wide_point( struct draw_stage *stage,
half_size = wide->half_point_size;
}
- left_adj = -half_size + 0.25f;
- right_adj = half_size + 0.25f;
+ left_adj = -half_size; /* + 0.25f;*/
+ right_adj = half_size; /* + 0.25f;*/
pos0[0] += left_adj;
pos0[1] -= half_size;
@@ -266,7 +266,8 @@ static void wide_first_point( struct draw_stage *stage,
wide->half_point_size = 0.5f * draw->rasterizer->point_size;
- if (draw->rasterizer->point_size != 1.0) {
+ /* XXX we won't know the real size if it's computed by the vertex shader! */
+ if (draw->rasterizer->point_size > draw->wide_point_threshold) {
stage->point = wide_point;
}
else {
@@ -277,8 +278,8 @@ static void wide_first_point( struct draw_stage *stage,
/* find vertex shader texcoord outputs */
const struct draw_vertex_shader *vs = draw->vertex_shader;
uint i, j = 0;
- for (i = 0; i < vs->state->num_outputs; i++) {
- if (vs->state->output_semantic_name[i] == TGSI_SEMANTIC_GENERIC) {
+ for (i = 0; i < vs->info.num_outputs; i++) {
+ if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_GENERIC) {
wide->texcoord_slot[j] = i;
wide->texcoord_mode[j] = draw->rasterizer->sprite_coord_mode[j];
j++;
@@ -293,8 +294,8 @@ static void wide_first_point( struct draw_stage *stage,
/* find PSIZ vertex output */
const struct draw_vertex_shader *vs = draw->vertex_shader;
uint i;
- for (i = 0; i < vs->state->num_outputs; i++) {
- if (vs->state->output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) {
+ for (i = 0; i < vs->info.num_outputs; i++) {
+ if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_PSIZE) {
wide->psize_slot = i;
break;
}
diff --git a/src/gallium/auxiliary/gallivm/gallivm.h b/src/gallium/auxiliary/gallivm/gallivm.h
index 92da4bca7f..57912a952f 100644
--- a/src/gallium/auxiliary/gallivm/gallivm.h
+++ b/src/gallium/auxiliary/gallivm/gallivm.h
@@ -97,7 +97,7 @@ void gallivm_cpu_engine_delete(struct gallivm_cpu_engine *ee);
#endif /* MESA_LLVM */
#if defined __cplusplus
-} // extern "C"
+}
#endif
#endif
diff --git a/src/gallium/auxiliary/gallivm/gallivm_p.h b/src/gallium/auxiliary/gallivm/gallivm_p.h
index cfe7b1901b..ebf3e11cd5 100644
--- a/src/gallium/auxiliary/gallivm/gallivm_p.h
+++ b/src/gallium/auxiliary/gallivm/gallivm_p.h
@@ -32,7 +32,7 @@ struct gallivm_ir {
int num_components;
int num_consts;
- //FIXME: this might not be enough for some shaders
+ /* FIXME: this might not be enough for some shaders */
struct gallivm_interpolate interpolators[32*4];
int num_interp;
};
@@ -46,7 +46,7 @@ struct gallivm_prog {
int num_consts;
- //FIXME: this might not be enough for some shaders
+ /* FIXME: this might not be enough for some shaders */
struct gallivm_interpolate interpolators[32*4];
int num_interp;
};
@@ -104,7 +104,7 @@ static INLINE int gallivm_w_swizzle(int swizzle)
#endif /* MESA_LLVM */
#if defined __cplusplus
-} // extern "C"
+}
#endif
#endif
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
index f5b5f4052f..4b09c80b2a 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
@@ -37,7 +37,7 @@
* There is no obligation of a winsys driver to use this library. And a pipe
* driver should be completly agnostic about it.
*
- * \author José Fonseca <jrfonseca@tungstengraphics.com>
+ * \author Jos� Fonseca <jrfonseca@tungstengraphics.com>
*/
#ifndef PB_BUFFER_H_
@@ -50,6 +50,11 @@
#include "pipe/p_inlines.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
struct pb_vtbl;
/**
@@ -200,4 +205,8 @@ void
pb_init_winsys(struct pipe_winsys *winsys);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*PB_BUFFER_H_*/
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h
index c40b9c75e1..50d5891bdb 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h
@@ -44,7 +44,7 @@
* Between the handle's destruction, and the fence signalling, the buffer is
* stored in a fenced buffer list.
*
- * \author José Fonseca <jrfonseca@tungstengraphics.com>
+ * \author José Fonseca <jrfonseca@tungstengraphics.com>
*/
#ifndef PB_BUFFER_FENCED_H_
@@ -54,6 +54,11 @@
#include "pipe/p_debug.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
struct pipe_winsys;
struct pipe_buffer;
struct pipe_fence_handle;
@@ -114,4 +119,8 @@ buffer_fence(struct pb_buffer *buf,
struct pipe_fence_handle *fence);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*PB_BUFFER_FENCED_H_*/
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
index 1ddf784c97..0cf8e92e37 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
@@ -43,7 +43,7 @@
* - the fenced buffer manager, which will delay buffer destruction until the
* the moment the card finishing processing it.
*
- * \author José Fonseca <jrfonseca@tungstengraphics.com>
+ * \author José Fonseca <jrfonseca@tungstengraphics.com>
*/
#ifndef PB_BUFMGR_H_
@@ -53,6 +53,11 @@
#include <stddef.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
struct pb_desc;
struct pipe_buffer;
struct pipe_winsys;
@@ -123,4 +128,8 @@ fenced_bufmgr_create(struct pb_manager *provider,
struct pipe_winsys *winsys);
+#ifdef __cplusplus
+}
+#endif
+
#endif /*PB_BUFMGR_H_*/
diff --git a/src/gallium/auxiliary/tgsi/exec/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/exec/tgsi_sse2.c
index 779b901f2b..0da3b0bdb7 100755
--- a/src/gallium/auxiliary/tgsi/exec/tgsi_sse2.c
+++ b/src/gallium/auxiliary/tgsi/exec/tgsi_sse2.c
@@ -1268,7 +1268,7 @@ emit_store(
break;
case TGSI_SAT_ZERO_ONE:
-// assert( 0 );
+ /* assert( 0 ); */
break;
case TGSI_SAT_MINUS_PLUS_ONE:
@@ -2268,7 +2268,7 @@ tgsi_emit_sse2(
&parse.FullToken.FullInstruction );
if (!ok) {
- debug_printf("failed to translate tgsi opcode %d\n",
+ debug_printf("failed to translate tgsi opcode %d to SSE\n",
parse.FullToken.FullInstruction.Instruction.Opcode );
}
break;
@@ -2276,7 +2276,7 @@ tgsi_emit_sse2(
case TGSI_TOKEN_TYPE_IMMEDIATE:
/* XXX implement this */
ok = 0;
- debug_printf("failed to emit immediate value\n");
+ debug_printf("failed to emit immediate value to SSE\n");
break;
default:
@@ -2358,7 +2358,7 @@ tgsi_emit_sse2_fs(
&parse.FullToken.FullInstruction );
if (!ok) {
- debug_printf("failed to translate tgsi opcode %d\n",
+ debug_printf("failed to translate tgsi opcode %d to SSE\n",
parse.FullToken.FullInstruction.Instruction.Opcode );
}
break;
@@ -2366,7 +2366,7 @@ tgsi_emit_sse2_fs(
case TGSI_TOKEN_TYPE_IMMEDIATE:
/* XXX implement this */
ok = 0;
- debug_printf("failed to emit immediate value\n");
+ debug_printf("failed to emit immediate value to SSE\n");
break;
default:
diff --git a/src/gallium/auxiliary/tgsi/exec/tgsi_sse2.h b/src/gallium/auxiliary/tgsi/exec/tgsi_sse2.h
index 9bee371766..63b8ef3911 100755
--- a/src/gallium/auxiliary/tgsi/exec/tgsi_sse2.h
+++ b/src/gallium/auxiliary/tgsi/exec/tgsi_sse2.h
@@ -3,7 +3,7 @@
#if defined __cplusplus
extern "C" {
-#endif // defined __cplusplus
+#endif
struct tgsi_token;
struct x86_function;
@@ -19,8 +19,8 @@ tgsi_emit_sse2_fs(
struct x86_function *function );
#if defined __cplusplus
-} // extern "C"
-#endif // defined __cplusplus
+}
+#endif
-#endif // !defined TGSI_SSE2_H
+#endif /* TGSI_SSE2_H */
diff --git a/src/gallium/auxiliary/tgsi/util/tgsi_build.h b/src/gallium/auxiliary/tgsi/util/tgsi_build.h
index 116c78abf3..607860e7fc 100644
--- a/src/gallium/auxiliary/tgsi/util/tgsi_build.h
+++ b/src/gallium/auxiliary/tgsi/util/tgsi_build.h
@@ -3,7 +3,7 @@
#if defined __cplusplus
extern "C" {
-#endif // defined __cplusplus
+#endif
/*
* version
@@ -313,8 +313,8 @@ tgsi_build_dst_register_ext_modulate(
struct tgsi_header *header );
#if defined __cplusplus
-} // extern "C"
-#endif // defined __cplusplus
+}
+#endif
-#endif // !defined TGSI_BUILD_H
+#endif /* TGSI_BUILD_H */
diff --git a/src/gallium/auxiliary/tgsi/util/tgsi_dump.c b/src/gallium/auxiliary/tgsi/util/tgsi_dump.c
index ff74e6117c..59be14a748 100644
--- a/src/gallium/auxiliary/tgsi/util/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/util/tgsi_dump.c
@@ -664,6 +664,19 @@ static const char *TGSI_TEXTURES[] =
"TEXTURE_SHADOWRECT"
};
+static const char *TGSI_TEXTURES_SHORT[] =
+{
+ "UNKNOWN",
+ "1D",
+ "2D",
+ "3D",
+ "CUBE",
+ "RECT",
+ "SHADOW1D",
+ "SHADOW2D",
+ "SHADOWRECT"
+};
+
static const char *TGSI_SRC_REGISTER_EXTS[] =
{
"SRC_REGISTER_EXT_TYPE_SWZ",
@@ -1037,6 +1050,11 @@ dump_instruction_short(
first_reg = FALSE;
}
+ if (inst->InstructionExtTexture.Texture != TGSI_TEXTURE_UNKNOWN) {
+ TXT( ", " );
+ ENM( inst->InstructionExtTexture.Texture, TGSI_TEXTURES_SHORT );
+ }
+
switch( inst->Instruction.Opcode ) {
case TGSI_OPCODE_IF:
case TGSI_OPCODE_ELSE:
diff --git a/src/gallium/auxiliary/tgsi/util/tgsi_dump.h b/src/gallium/auxiliary/tgsi/util/tgsi_dump.h
index 1adc9db251..b983b38226 100644
--- a/src/gallium/auxiliary/tgsi/util/tgsi_dump.h
+++ b/src/gallium/auxiliary/tgsi/util/tgsi_dump.h
@@ -3,7 +3,7 @@
#if defined __cplusplus
extern "C" {
-#endif // defined __cplusplus
+#endif
#define TGSI_DUMP_VERBOSE 1
#define TGSI_DUMP_NO_IGNORED 2
@@ -21,8 +21,8 @@ tgsi_dump_str(
unsigned flags );
#if defined __cplusplus
-} // extern "C"
-#endif // defined __cplusplus
+}
+#endif
-#endif // !defined TGSI_DUMP_H
+#endif /* TGSI_DUMP_H */
diff --git a/src/gallium/auxiliary/tgsi/util/tgsi_parse.h b/src/gallium/auxiliary/tgsi/util/tgsi_parse.h
index 9372da8d5d..5ccb5bfcf6 100644
--- a/src/gallium/auxiliary/tgsi/util/tgsi_parse.h
+++ b/src/gallium/auxiliary/tgsi/util/tgsi_parse.h
@@ -3,7 +3,7 @@
#if defined __cplusplus
extern "C" {
-#endif // defined __cplusplus
+#endif
struct tgsi_full_version
{
@@ -114,8 +114,8 @@ tgsi_parse_token(
struct tgsi_parse_context *ctx );
#if defined __cplusplus
-} // extern "C"
-#endif // defined __cplusplus
+}
+#endif
-#endif // !defined TGSI_PARSE_H
+#endif /* TGSI_PARSE_H */
diff --git a/src/gallium/auxiliary/tgsi/util/tgsi_scan.c b/src/gallium/auxiliary/tgsi/util/tgsi_scan.c
index 4b99ac37cc..ea4a72967d 100644
--- a/src/gallium/auxiliary/tgsi/util/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/util/tgsi_scan.c
@@ -37,6 +37,7 @@
#include "tgsi/util/tgsi_parse.h"
#include "tgsi/util/tgsi_build.h"
+#include "pipe/p_util.h"
@@ -46,10 +47,12 @@ void
tgsi_scan_shader(const struct tgsi_token *tokens,
struct tgsi_shader_info *info)
{
- uint procType;
+ uint procType, i;
struct tgsi_parse_context parse;
memset(info, 0, sizeof(*info));
+ for (i = 0; i < TGSI_FILE_COUNT; i++)
+ info->file_max[i] = -1;
/**
** Setup to begin parsing input shader
@@ -69,6 +72,8 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
*/
while( !tgsi_parse_end_of_tokens( &parse ) ) {
+ info->num_tokens++;
+
tgsi_parse_token( &parse );
switch( parse.FullToken.Token.Type ) {
@@ -91,8 +96,27 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
for (i = fulldecl->u.DeclarationRange.First;
i <= fulldecl->u.DeclarationRange.Last;
i++) {
+
+ /* only first 32 regs will appear in this bitfield */
info->file_mask[file] |= (1 << i);
info->file_count[file]++;
+ info->file_max[file] = MAX2(info->file_max[file], (int)i);
+
+ if (file == TGSI_FILE_INPUT) {
+ info->input_semantic_name[info->num_inputs]
+ = (ubyte)fulldecl->Semantic.SemanticName;
+ info->input_semantic_index[info->num_inputs]
+ = (ubyte)fulldecl->Semantic.SemanticIndex;
+ info->num_inputs++;
+ }
+
+ if (file == TGSI_FILE_OUTPUT) {
+ info->output_semantic_name[info->num_outputs]
+ = (ubyte)fulldecl->Semantic.SemanticName;
+ info->output_semantic_index[info->num_outputs]
+ = (ubyte)fulldecl->Semantic.SemanticIndex;
+ info->num_outputs++;
+ }
/* special case */
if (procType == TGSI_PROCESSOR_FRAGMENT &&
@@ -113,5 +137,8 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
}
}
+ info->uses_kill = (info->opcode_count[TGSI_OPCODE_KIL] ||
+ info->opcode_count[TGSI_OPCODE_KILP]);
+
tgsi_parse_free (&parse);
}
diff --git a/src/gallium/auxiliary/tgsi/util/tgsi_scan.h b/src/gallium/auxiliary/tgsi/util/tgsi_scan.h
index 757446437c..0530bc6b51 100644
--- a/src/gallium/auxiliary/tgsi/util/tgsi_scan.h
+++ b/src/gallium/auxiliary/tgsi/util/tgsi_scan.h
@@ -29,7 +29,8 @@
#define TGSI_SCAN_H
-#include "pipe/p_util.h"
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
#include "pipe/p_shader_tokens.h"
@@ -38,14 +39,26 @@
*/
struct tgsi_shader_info
{
+ uint num_tokens;
+
+ /* XXX eventually remove the corresponding fields from pipe_shader_state: */
+ ubyte num_inputs;
+ ubyte num_outputs;
+ ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; /**< TGSI_SEMANTIC_x */
+ ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
+ ubyte output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; /**< TGSI_SEMANTIC_x */
+ ubyte output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
+
uint file_mask[TGSI_FILE_COUNT]; /**< bitmask of declared registers */
uint file_count[TGSI_FILE_COUNT]; /**< number of declared registers */
+ int file_max[TGSI_FILE_COUNT]; /**< highest index of declared registers */
uint immediate_count; /**< number of immediates declared */
uint opcode_count[TGSI_OPCODE_LAST]; /**< opcode histogram */
boolean writes_z; /**< does fragment shader write Z value? */
+ boolean uses_kill; /**< KIL or KILP instruction used? */
};
diff --git a/src/gallium/auxiliary/tgsi/util/tgsi_util.h b/src/gallium/auxiliary/tgsi/util/tgsi_util.h
index ef14446f0e..45f5f0be0e 100644
--- a/src/gallium/auxiliary/tgsi/util/tgsi_util.h
+++ b/src/gallium/auxiliary/tgsi/util/tgsi_util.h
@@ -3,7 +3,7 @@
#if defined __cplusplus
extern "C" {
-#endif // defined __cplusplus
+#endif
void *
tgsi_align_128bit(
@@ -63,8 +63,8 @@ tgsi_util_set_full_src_register_sign_mode(
unsigned sign_mode );
#if defined __cplusplus
-} // extern "C"
-#endif // defined __cplusplus
+}
+#endif
-#endif // !defined TGSI_UTIL_H
+#endif /* TGSI_UTIL_H */
diff --git a/src/gallium/drivers/cell/ppu/Makefile b/src/gallium/drivers/cell/ppu/Makefile
index 164dde762c..d38fa6ce07 100644
--- a/src/gallium/drivers/cell/ppu/Makefile
+++ b/src/gallium/drivers/cell/ppu/Makefile
@@ -29,6 +29,7 @@ SOURCES = \
cell_state_emit.c \
cell_state_shader.c \
cell_pipe_state.c \
+ cell_screen.c \
cell_state_vertex.c \
cell_spu.c \
cell_surface.c \
diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c
index 98c314f45c..ccbbd1d331 100644
--- a/src/gallium/drivers/cell/ppu/cell_context.c
+++ b/src/gallium/drivers/cell/ppu/cell_context.c
@@ -37,9 +37,12 @@
#include "pipe/p_format.h"
#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
-#include "cell/common.h"
+#include "pipe/p_screen.h"
+
#include "draw/draw_context.h"
#include "draw/draw_private.h"
+
+#include "cell/common.h"
#include "cell_clear.h"
#include "cell_context.h"
#include "cell_draw_arrays.h"
@@ -54,99 +57,6 @@
-static boolean
-cell_is_format_supported( struct pipe_context *pipe,
- enum pipe_format format, uint type )
-{
- /*struct cell_context *cell = cell_context( pipe );*/
-
- 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;
- default:
- assert(0);
- return FALSE;
- }
-}
-
-
-static int cell_get_param(struct pipe_context *pipe, int param)
-{
- 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 )
{
@@ -174,7 +84,8 @@ cell_draw_create(struct cell_context *cell)
struct pipe_context *
-cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws)
+cell_create_context(struct pipe_screen *screen,
+ struct cell_winsys *cws)
{
struct cell_context *cell;
uint spu, buf;
@@ -187,17 +98,10 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws)
memset(cell, 0, sizeof(*cell));
cell->winsys = cws;
- cell->pipe.winsys = winsys;
+ cell->pipe.winsys = screen->winsys;
+ cell->pipe.screen = screen;
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.set_vertex_buffer = cell_set_vertex_buffer;
cell->pipe.set_vertex_element = cell_set_vertex_element;
@@ -224,10 +128,17 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws)
cell_init_vbuf(cell);
draw_set_rasterize_stage(cell->draw, cell->vbuf);
+ /* convert all points/lines to tris for the time being */
+ draw_wide_point_threshold(cell->draw, 0.0);
+ draw_wide_line_threshold(cell->draw, 0.0);
+
/*
* SPU stuff
*/
cell->num_spus = 6;
+ /* XXX is this in SDK 3.0 only?
+ cell->num_spus = spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);
+ */
cell_start_spus(cell);
diff --git a/src/gallium/drivers/cell/ppu/cell_context.h b/src/gallium/drivers/cell/ppu/cell_context.h
index 1433a4925f..bf27289f3f 100644
--- a/src/gallium/drivers/cell/ppu/cell_context.h
+++ b/src/gallium/drivers/cell/ppu/cell_context.h
@@ -128,7 +128,7 @@ cell_context(struct pipe_context *pipe)
extern struct pipe_context *
-cell_create_context(struct pipe_winsys *ws, struct cell_winsys *cws);
+cell_create_context(struct pipe_screen *screen, struct cell_winsys *cws);
extern void
cell_vertex_shader_queue_flush(struct draw_context *draw);
diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
index 95bfc29fbe..075e0a0c47 100644
--- a/src/gallium/drivers/cell/ppu/cell_pipe_state.c
+++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
@@ -242,8 +242,7 @@ cell_set_sampler_texture(struct pipe_context *pipe,
draw_flush(cell->draw);
- pipe_texture_reference(pipe,
- (struct pipe_texture **) &cell->texture[sampler],
+ pipe_texture_reference((struct pipe_texture **) &cell->texture[sampler],
texture);
cell_update_texture_mapping(cell);
diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c
new file mode 100644
index 0000000000..124670df25
--- /dev/null
+++ b/src/gallium/drivers/cell/ppu/cell_screen.c
@@ -0,0 +1,166 @@
+/**************************************************************************
+ *
+ * Copyright 2008 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 "pipe/p_winsys.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_screen.h"
+
+#include "cell_screen.h"
+#include "cell_texture.h"
+#include "cell_winsys.h"
+
+
+static const char *
+cell_get_vendor(struct pipe_screen *screen)
+{
+ return "Tungsten Graphics, Inc.";
+}
+
+
+static const char *
+cell_get_name(struct pipe_screen *screen)
+{
+ return "Cell";
+}
+
+
+static int
+cell_get_param(struct pipe_screen *screen, int param)
+{
+ 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_screen *screen, 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 boolean
+cell_is_format_supported( struct pipe_screen *screen,
+ enum pipe_format format, uint type )
+{
+ 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;
+ default:
+ assert(0);
+ return FALSE;
+ }
+}
+
+
+static void
+cell_destroy_screen( struct pipe_screen *screen )
+{
+ FREE(screen);
+}
+
+
+/**
+ * Create a new pipe_screen object
+ * Note: we're not presently subclassing pipe_screen (no cell_screen) but
+ * that would be the place to put SPU thread/context info...
+ */
+struct pipe_screen *
+cell_create_screen(struct pipe_winsys *winsys)
+{
+ struct pipe_screen *screen = CALLOC_STRUCT(pipe_screen);
+
+ if (!screen)
+ return NULL;
+
+ screen->winsys = winsys;
+
+ screen->destroy = cell_destroy_screen;
+
+ screen->get_name = cell_get_name;
+ screen->get_vendor = cell_get_vendor;
+ screen->get_param = cell_get_param;
+ screen->get_paramf = cell_get_paramf;
+ screen->is_format_supported = cell_is_format_supported;
+
+ cell_init_screen_texture_funcs(screen);
+
+ return screen;
+}
diff --git a/src/gallium/drivers/cell/ppu/cell_screen.h b/src/gallium/drivers/cell/ppu/cell_screen.h
new file mode 100644
index 0000000000..c7e15889d6
--- /dev/null
+++ b/src/gallium/drivers/cell/ppu/cell_screen.h
@@ -0,0 +1,41 @@
+/**************************************************************************
+ *
+ * Copyright 2008 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_SCREEN_H
+#define CELL_SCREEN_H
+
+
+struct pipe_screen;
+struct pipe_winsys;
+
+
+extern struct pipe_screen *
+cell_create_screen(struct pipe_winsys *winsys);
+
+
+#endif /* CELL_SCREEN_H */
diff --git a/src/gallium/drivers/cell/ppu/cell_spu.c b/src/gallium/drivers/cell/ppu/cell_spu.c
index 419e74dc40..973c0b1aa1 100644
--- a/src/gallium/drivers/cell/ppu/cell_spu.c
+++ b/src/gallium/drivers/cell/ppu/cell_spu.c
@@ -97,8 +97,18 @@ static void *cell_thread_function(void *arg)
void
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");
+ abort();
+ }
+
+ one_time_init = TRUE;
+
assert(cell->num_spus <= MAX_SPUS);
ASSERT_ALIGN16(&cell_global.command[0]);
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c
index 0edefa5f05..e235421107 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.c
+++ b/src/gallium/drivers/cell/ppu/cell_texture.c
@@ -80,21 +80,23 @@ cell_texture_layout(struct cell_texture * spt)
static struct pipe_texture *
-cell_texture_create(struct pipe_context *pipe,
- const struct pipe_texture *templat)
+cell_texture_create_screen(struct pipe_screen *screen,
+ const struct pipe_texture *templat)
{
+ struct pipe_winsys *ws = screen->winsys;
struct cell_texture *spt = CALLOC_STRUCT(cell_texture);
if (!spt)
return NULL;
spt->base = *templat;
spt->base.refcount = 1;
+ spt->base.screen = screen;
cell_texture_layout(spt);
- spt->buffer = pipe->winsys->buffer_create(pipe->winsys, 32,
- PIPE_BUFFER_USAGE_PIXEL,
- spt->buffer_size);
+ spt->buffer = ws->buffer_create(ws, 32,
+ PIPE_BUFFER_USAGE_PIXEL,
+ spt->buffer_size);
if (!spt->buffer) {
FREE(spt);
@@ -106,7 +108,8 @@ cell_texture_create(struct pipe_context *pipe,
static void
-cell_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
+cell_texture_release_screen(struct pipe_screen *screen,
+ struct pipe_texture **pt)
{
if (!*pt)
return;
@@ -122,7 +125,7 @@ cell_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
DBG("%s deleting %p\n", __FUNCTION__, (void *) spt);
*/
- pipe_buffer_reference(pipe->winsys, &spt->buffer, NULL);
+ pipe_buffer_reference(screen->winsys, &spt->buffer, NULL);
FREE(spt);
}
@@ -138,22 +141,20 @@ cell_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
}
-/**
- * Called via pipe->get_tex_surface()
- */
static struct pipe_surface *
-cell_get_tex_surface(struct pipe_context *pipe,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice)
+cell_get_tex_surface_screen(struct pipe_screen *screen,
+ struct pipe_texture *pt,
+ unsigned face, unsigned level, unsigned zslice)
{
+ struct pipe_winsys *ws = screen->winsys;
struct cell_texture *spt = cell_texture(pt);
struct pipe_surface *ps;
- ps = pipe->winsys->surface_alloc(pipe->winsys);
+ ps = ws->surface_alloc(ws);
if (ps) {
assert(ps->refcount);
assert(ps->winsys);
- pipe_buffer_reference(pipe->winsys, &ps->buffer, spt->buffer);
+ pipe_buffer_reference(ws, &ps->buffer, spt->buffer);
ps->format = pt->format;
ps->cpp = pt->cpp;
ps->width = pt->width[level];
@@ -208,6 +209,7 @@ static void
cell_tile_texture(struct cell_context *cell,
struct cell_texture *texture)
{
+ struct pipe_screen *screen = cell->pipe.screen;
uint face = 0, level = 0, zslice = 0;
struct pipe_surface *surf;
const uint w = texture->base.width[0], h = texture->base.height[0];
@@ -219,7 +221,7 @@ cell_tile_texture(struct cell_context *cell,
assert(w % TILE_SIZE == 0);
assert(h % TILE_SIZE == 0);
- surf = cell_get_tex_surface(&cell->pipe, &texture->base, face, level, zslice);
+ surf = screen->get_tex_surface(screen, &texture->base, face, level, zslice);
ASSERT(surf);
src = (const uint *) pipe_surface_map(surf);
@@ -265,8 +267,13 @@ cell_update_texture_mapping(struct cell_context *cell)
void
cell_init_texture_functions(struct cell_context *cell)
{
- cell->pipe.texture_create = cell_texture_create;
- cell->pipe.texture_release = cell_texture_release;
cell->pipe.texture_update = cell_texture_update;
- cell->pipe.get_tex_surface = cell_get_tex_surface;
+}
+
+void
+cell_init_screen_texture_funcs(struct pipe_screen *screen)
+{
+ screen->texture_create = cell_texture_create_screen;
+ screen->texture_release = cell_texture_release_screen;
+ screen->get_tex_surface = cell_get_tex_surface_screen;
}
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.h b/src/gallium/drivers/cell/ppu/cell_texture.h
index 824fb3e20f..fcee069d05 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.h
+++ b/src/gallium/drivers/cell/ppu/cell_texture.h
@@ -68,4 +68,8 @@ extern void
cell_init_texture_functions(struct cell_context *cell);
+extern void
+cell_init_screen_texture_funcs(struct pipe_screen *screen);
+
+
#endif /* CELL_TEXTURE_H */
diff --git a/src/gallium/drivers/cell/spu/spu_main.c b/src/gallium/drivers/cell/spu/spu_main.c
index cc4bafdb3a..59300028d4 100644
--- a/src/gallium/drivers/cell/spu/spu_main.c
+++ b/src/gallium/drivers/cell/spu/spu_main.c
@@ -286,6 +286,8 @@ cmd_state_texture(const struct cell_command_texture *texture)
{ spu.texture.width, spu.texture.height, 0.0, 0.0};
spu.tex_size_mask = (vector unsigned int)
{ spu.texture.width - 1, spu.texture.height - 1, 0, 0 };
+ spu.tex_size_x_mask = spu_splats(spu.texture.width - 1);
+ spu.tex_size_y_mask = spu_splats(spu.texture.height - 1);
}
diff --git a/src/gallium/drivers/cell/spu/spu_main.h b/src/gallium/drivers/cell/spu/spu_main.h
index d14f1abbe7..a13edd1702 100644
--- a/src/gallium/drivers/cell/spu/spu_main.h
+++ b/src/gallium/drivers/cell/spu/spu_main.h
@@ -107,6 +107,8 @@ struct spu_global
vector float tex_size;
vector unsigned int tex_size_mask; /**< == int(size - 1) */
+ vector unsigned int tex_size_x_mask; /**< == int(size - 1) */
+ vector unsigned int tex_size_y_mask; /**< == int(size - 1) */
vector float (*sample_texture)(vector float texcoord);
@@ -130,7 +132,6 @@ extern boolean Debug;
#define TAG_INDEX_BUFFER 16
#define TAG_BATCH_BUFFER 17
#define TAG_MISC 18
-#define TAG_TEXTURE_TILE 19
#define TAG_DCACHE0 20
#define TAG_DCACHE1 21
#define TAG_DCACHE2 22
diff --git a/src/gallium/drivers/cell/spu/spu_texture.c b/src/gallium/drivers/cell/spu/spu_texture.c
index 3962aaa4a9..67eb08196a 100644
--- a/src/gallium/drivers/cell/spu/spu_texture.c
+++ b/src/gallium/drivers/cell/spu/spu_texture.c
@@ -31,19 +31,7 @@
#include "spu_texture.h"
#include "spu_tile.h"
#include "spu_colorpack.h"
-
-
-/**
- * Number of texture tiles to cache.
- * Note that this will probably be the largest consumer of SPU local store/
- * memory for this driver!
- */
-#define CACHE_SIZE 16
-
-static tile_t tex_tiles[CACHE_SIZE] ALIGN16_ATTRIB;
-
-static vector unsigned int tex_tile_xy[CACHE_SIZE];
-
+#include "spu_dcache.h"
/**
@@ -52,78 +40,60 @@ static vector unsigned int tex_tile_xy[CACHE_SIZE];
void
invalidate_tex_cache(void)
{
- /* XXX memset? */
- uint i;
- for (i = 0; i < CACHE_SIZE; i++) {
- tex_tile_xy[i] = ((vector unsigned int) { ~0U, ~0U, ~0U, ~0U });
- }
+ spu_dcache_mark_dirty((unsigned) spu.texture.start,
+ 4 * spu.texture.width * spu.texture.height);
}
-/**
- * Return the cache pos/index which corresponds to tile (tx,ty)
- */
-static INLINE uint
-cache_pos(vector unsigned int txty)
+static uint
+get_texel(vec_uint4 coordinate)
{
- uint pos = (spu_extract(txty,0) + spu_extract(txty,1) * 4) % CACHE_SIZE;
- return pos;
+ vec_uint4 tmp;
+ unsigned x = spu_extract(coordinate, 0);
+ unsigned y = spu_extract(coordinate, 1);
+ const unsigned tiles_per_row = spu.texture.width / TILE_SIZE;
+ unsigned tile_offset = sizeof(tile_t) * ((y / TILE_SIZE * tiles_per_row)
+ + (x / TILE_SIZE));
+ unsigned texel_offset = 4 * (((y % TILE_SIZE) * TILE_SIZE)
+ + (x % TILE_SIZE));
+
+ spu_dcache_fetch_unaligned((qword *) & tmp,
+ spu.texture.start + tile_offset + texel_offset,
+ 4);
+ return spu_extract(tmp, 0);
}
-/**
- * Make sure the tile for texel (i,j) is present, return its position/index
- * in the cache.
- */
-static uint
-get_tex_tile(vector unsigned int ij)
+static void
+get_four_texels(vec_uint4 x, vec_uint4 y, vec_uint4 *texels)
{
- /* tile address: tx,ty */
- const vector unsigned int txty = spu_rlmask(ij, -5); /* divide by 32 */
- const uint pos = cache_pos(txty);
-
- if ((spu_extract(tex_tile_xy[pos], 0) != spu_extract(txty, 0)) ||
- (spu_extract(tex_tile_xy[pos], 1) != spu_extract(txty, 1))) {
-
- /* texture cache miss, fetch tile from main memory */
- const uint tiles_per_row = spu.texture.width / TILE_SIZE;
- const uint bytes_per_tile = sizeof(tile_t);
- const void *src = (const ubyte *) spu.texture.start
- + (spu_extract(txty,1) * tiles_per_row + spu_extract(txty,0)) * bytes_per_tile;
-
- printf("SPU %u: tex cache miss at %d, %d pos=%u old=%d,%d\n",
- spu.init.id,
- spu_extract(txty,0),
- spu_extract(txty,1),
- pos,
- spu_extract(tex_tile_xy[pos],0),
- spu_extract(tex_tile_xy[pos],1));
-
- ASSERT_ALIGN16(tex_tiles[pos].ui);
- ASSERT_ALIGN16(src);
-
- mfc_get(tex_tiles[pos].ui, /* dest */
- (unsigned int) src,
- bytes_per_tile, /* size */
- TAG_TEXTURE_TILE,
- 0, /* tid */
- 0 /* rid */);
-
- wait_on_mask(1 << TAG_TEXTURE_TILE);
-
- tex_tile_xy[pos] = txty;
- }
- else {
-#if 0
- printf("SPU %u: tex cache HIT at %d, %d\n",
- spu.init.id, tx, ty);
-#endif
- }
-
- return pos;
+ const unsigned texture_ea = (uintptr_t) spu.texture.start;
+ vec_uint4 tile_x = spu_rlmask(x, -5);
+ vec_uint4 tile_y = spu_rlmask(y, -5);
+ const qword offset_x = si_andi((qword) x, 0x1f);
+ const qword offset_y = si_andi((qword) y, 0x1f);
+
+ const qword tiles_per_row = (qword) spu_splats(spu.texture.width / TILE_SIZE);
+ const qword tile_size = (qword) spu_splats(sizeof(tile_t));
+
+ qword tile_offset = si_mpya((qword) tile_y, tiles_per_row, (qword) tile_x);
+ tile_offset = si_mpy((qword) tile_offset, tile_size);
+
+ qword texel_offset = si_a(si_mpyui(offset_y, 32), offset_x);
+ texel_offset = si_mpyui(texel_offset, 4);
+
+ vec_uint4 offset = (vec_uint4) si_a(tile_offset, texel_offset);
+
+ spu_dcache_fetch_unaligned((qword *) & texels[0],
+ texture_ea + spu_extract(offset, 0), 4);
+ spu_dcache_fetch_unaligned((qword *) & texels[1],
+ texture_ea + spu_extract(offset, 1), 4);
+ spu_dcache_fetch_unaligned((qword *) & texels[2],
+ texture_ea + spu_extract(offset, 2), 4);
+ spu_dcache_fetch_unaligned((qword *) & texels[3],
+ texture_ea + spu_extract(offset, 3), 4);
}
-
/**
* Get texture sample at texcoord.
* XXX this is extremely primitive for now.
@@ -134,9 +104,7 @@ sample_texture_nearest(vector float texcoord)
vector float tc = spu_mul(texcoord, spu.tex_size);
vector unsigned int itc = spu_convtu(tc, 0); /* convert to int */
itc = spu_and(itc, spu.tex_size_mask); /* mask (GL_REPEAT) */
- vector unsigned int ij = spu_and(itc, TILE_SIZE-1); /* intra tile addr */
- uint pos = get_tex_tile(itc);
- uint texel = tex_tiles[pos].ui[spu_extract(ij, 1)][spu_extract(ij, 0)];
+ uint texel = get_texel(itc);
return spu_unpack_A8R8G8B8(texel);
}
@@ -144,49 +112,33 @@ sample_texture_nearest(vector float texcoord)
vector float
sample_texture_bilinear(vector float texcoord)
{
- static const vector unsigned int offset10 = {1, 0, 0, 0};
- static const vector unsigned int offset01 = {0, 1, 0, 0};
+ static const vec_uint4 offset_x = {0, 0, 1, 1};
+ static const vec_uint4 offset_y = {0, 1, 0, 1};
vector float tc = spu_mul(texcoord, spu.tex_size);
tc = spu_add(tc, spu_splats(-0.5f)); /* half texel bias */
/* integer texcoords S,T: */
- vector unsigned int itc00 = spu_convtu(tc, 0); /* convert to int */
- vector unsigned int itc01 = spu_add(itc00, offset01);
- vector unsigned int itc10 = spu_add(itc00, offset10);
- vector unsigned int itc11 = spu_add(itc10, offset01);
-
- /* mask (GL_REPEAT) */
- itc00 = spu_and(itc00, spu.tex_size_mask);
- itc01 = spu_and(itc01, spu.tex_size_mask);
- itc10 = spu_and(itc10, spu.tex_size_mask);
- itc11 = spu_and(itc11, spu.tex_size_mask);
-
- /* intra tile addr */
- vector unsigned int ij00 = spu_and(itc00, TILE_SIZE-1);
- vector unsigned int ij01 = spu_and(itc01, TILE_SIZE-1);
- vector unsigned int ij10 = spu_and(itc10, TILE_SIZE-1);
- vector unsigned int ij11 = spu_and(itc11, TILE_SIZE-1);
-
- /* get tile cache positions */
- uint pos00 = get_tex_tile(itc00);
- uint pos01, pos10, pos11;
- if ((spu_extract(ij00, 0) < TILE_SIZE-1) &&
- (spu_extract(ij00, 1) < TILE_SIZE-1)) {
- /* all texels are in the same tile */
- pos01 = pos10 = pos11 = pos00;
- }
- else {
- pos01 = get_tex_tile(itc01);
- pos10 = get_tex_tile(itc10);
- pos11 = get_tex_tile(itc11);
- }
-
- /* get texels from tiles and convert to float[4] */
- vector float texel00 = spu_unpack_A8R8G8B8(tex_tiles[pos00].ui[spu_extract(ij00, 1)][spu_extract(ij00, 0)]);
- vector float texel01 = spu_unpack_A8R8G8B8(tex_tiles[pos01].ui[spu_extract(ij01, 1)][spu_extract(ij01, 0)]);
- vector float texel10 = spu_unpack_A8R8G8B8(tex_tiles[pos10].ui[spu_extract(ij10, 1)][spu_extract(ij10, 0)]);
- vector float texel11 = spu_unpack_A8R8G8B8(tex_tiles[pos11].ui[spu_extract(ij11, 1)][spu_extract(ij11, 0)]);
+ vec_uint4 itc = spu_convtu(tc, 0); /* convert to int */
+
+ vec_uint4 texels[4];
+
+ vec_uint4 x = spu_splats(spu_extract(itc, 0));
+ vec_uint4 y = spu_splats(spu_extract(itc, 1));
+
+ x = spu_add(x, offset_x);
+ y = spu_add(y, offset_y);
+
+ x = spu_and(x, spu.tex_size_x_mask);
+ y = spu_and(y, spu.tex_size_y_mask);
+
+ get_four_texels(x, y, texels);
+
+ vector float texel00 = spu_unpack_A8R8G8B8(spu_extract(texels[0], 0));
+ vector float texel01 = spu_unpack_A8R8G8B8(spu_extract(texels[1], 0));
+ vector float texel10 = spu_unpack_A8R8G8B8(spu_extract(texels[2], 0));
+ vector float texel11 = spu_unpack_A8R8G8B8(spu_extract(texels[3], 0));
+
/* Compute weighting factors in [0,1]
* Multiply texcoord by 1024, AND with 1023, convert back to float.
diff --git a/src/gallium/drivers/failover/fo_context.c b/src/gallium/drivers/failover/fo_context.c
index 156f7399b0..afc0d7eb1e 100644
--- a/src/gallium/drivers/failover/fo_context.c
+++ b/src/gallium/drivers/failover/fo_context.c
@@ -117,12 +117,15 @@ struct pipe_context *failover_create( struct pipe_context *hw,
failover->hw = hw;
failover->sw = sw;
failover->pipe.winsys = hw->winsys;
+ failover->pipe.screen = hw->screen;
failover->pipe.destroy = failover_destroy;
+#if 0
failover->pipe.is_format_supported = hw->is_format_supported;
failover->pipe.get_name = hw->get_name;
failover->pipe.get_vendor = hw->get_vendor;
failover->pipe.get_param = hw->get_param;
failover->pipe.get_paramf = hw->get_paramf;
+#endif
failover->pipe.draw_arrays = failover_draw_arrays;
failover->pipe.draw_elements = failover_draw_elements;
@@ -140,10 +143,12 @@ struct pipe_context *failover_create( struct pipe_context *hw,
failover->pipe.surface_copy = hw->surface_copy;
failover->pipe.surface_fill = hw->surface_fill;
+#if 0
failover->pipe.texture_create = hw->texture_create;
failover->pipe.texture_release = hw->texture_release;
- failover->pipe.texture_update = hw->texture_update;
failover->pipe.get_tex_surface = hw->get_tex_surface;
+#endif
+ failover->pipe.texture_update = hw->texture_update;
failover->pipe.flush = hw->flush;
diff --git a/src/gallium/drivers/i915simple/Makefile b/src/gallium/drivers/i915simple/Makefile
index 2a75f5d57c..41a61a0020 100644
--- a/src/gallium/drivers/i915simple/Makefile
+++ b/src/gallium/drivers/i915simple/Makefile
@@ -17,7 +17,7 @@ C_SOURCES = \
i915_state_derived.c \
i915_state_emit.c \
i915_state_sampler.c \
- i915_strings.c \
+ i915_screen.c \
i915_prim_emit.c \
i915_prim_vbuf.c \
i915_texture.c \
diff --git a/src/gallium/drivers/i915simple/SConscript b/src/gallium/drivers/i915simple/SConscript
index f5fb96b995..2366e1247f 100644
--- a/src/gallium/drivers/i915simple/SConscript
+++ b/src/gallium/drivers/i915simple/SConscript
@@ -15,13 +15,13 @@ i915simple = env.ConvenienceLibrary(
'i915_fpc_translate.c',
'i915_prim_emit.c',
'i915_prim_vbuf.c',
+ 'i915_screen.c',
'i915_state.c',
'i915_state_derived.c',
'i915_state_dynamic.c',
'i915_state_emit.c',
'i915_state_immediate.c',
'i915_state_sampler.c',
- 'i915_strings.c',
'i915_surface.c',
'i915_texture.c',
])
diff --git a/src/gallium/drivers/i915simple/i915_context.c b/src/gallium/drivers/i915simple/i915_context.c
index c3955bbd2d..15ff2360b7 100644
--- a/src/gallium/drivers/i915simple/i915_context.c
+++ b/src/gallium/drivers/i915simple/i915_context.c
@@ -36,120 +36,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
#include "pipe/p_util.h"
-
-
-/**
- * Query format support for creating a texture, drawing surface, etc.
- * \param format the format to test
- * \param type one of PIPE_TEXTURE, PIPE_SURFACE
- */
-static boolean
-i915_is_format_supported( struct pipe_context *pipe,
- enum pipe_format format, uint type )
-{
- static const enum pipe_format tex_supported[] = {
- PIPE_FORMAT_R8G8B8A8_UNORM,
- PIPE_FORMAT_A8R8G8B8_UNORM,
- PIPE_FORMAT_R5G6B5_UNORM,
- PIPE_FORMAT_U_L8,
- PIPE_FORMAT_U_A8,
- PIPE_FORMAT_U_I8,
- PIPE_FORMAT_U_A8_L8,
- PIPE_FORMAT_YCBCR,
- PIPE_FORMAT_YCBCR_REV,
- PIPE_FORMAT_S8Z24_UNORM,
- PIPE_FORMAT_NONE /* list terminator */
- };
- static const enum pipe_format surface_supported[] = {
- PIPE_FORMAT_A8R8G8B8_UNORM,
- PIPE_FORMAT_R5G6B5_UNORM,
- PIPE_FORMAT_S8Z24_UNORM,
- /*PIPE_FORMAT_R16G16B16A16_SNORM,*/
- PIPE_FORMAT_NONE /* list terminator */
- };
- const enum pipe_format *list;
- uint i;
-
- switch (type) {
- case PIPE_TEXTURE:
- list = tex_supported;
- break;
- case PIPE_SURFACE:
- list = surface_supported;
- break;
- default:
- assert(0);
- }
-
- for (i = 0; list[i] != PIPE_FORMAT_NONE; i++) {
- if (list[i] == format)
- return TRUE;
- }
-
- return FALSE;
-}
-
-
-static int
-i915_get_param(struct pipe_context *pipe, int param)
-{
- 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 0;
- case PIPE_CAP_S3TC:
- return 0;
- case PIPE_CAP_ANISOTROPIC_FILTER:
- return 0;
- case PIPE_CAP_POINT_SPRITE:
- return 0;
- case PIPE_CAP_MAX_RENDER_TARGETS:
- return 1;
- case PIPE_CAP_OCCLUSION_QUERY:
- return 0;
- case PIPE_CAP_TEXTURE_SHADOW_MAP:
- return 1;
- case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
- return 11; /* max 1024x1024 */
- case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
- return 8; /* max 128x128x128 */
- case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
- return 11; /* max 1024x1024 */
- default:
- return 0;
- }
-}
-
-
-static float
-i915_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 7.5;
-
- case PIPE_CAP_MAX_POINT_WIDTH:
- /* fall-through */
- case PIPE_CAP_MAX_POINT_WIDTH_AA:
- return 255.0;
-
- case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
- return 4.0;
-
- case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
- return 16.0;
-
- default:
- return 0;
- }
-}
+#include "pipe/p_screen.h"
static void i915_destroy( struct pipe_context *pipe )
@@ -162,8 +49,6 @@ static void i915_destroy( struct pipe_context *pipe )
}
-
-
static boolean
i915_draw_elements( struct pipe_context *pipe,
struct pipe_buffer *indexBuffer,
@@ -234,33 +119,11 @@ static boolean i915_draw_arrays( struct pipe_context *pipe,
-struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
- struct i915_winsys *i915_winsys,
- unsigned pci_id )
+struct pipe_context *i915_create_context( struct pipe_screen *screen,
+ struct pipe_winsys *pipe_winsys,
+ struct i915_winsys *i915_winsys )
{
struct i915_context *i915;
- unsigned is_i945 = 0;
-
- switch (pci_id) {
- case PCI_CHIP_I915_G:
- case PCI_CHIP_I915_GM:
- break;
-
- case PCI_CHIP_I945_G:
- case PCI_CHIP_I945_GM:
- case PCI_CHIP_I945_GME:
- case PCI_CHIP_G33_G:
- case PCI_CHIP_Q33_G:
- case PCI_CHIP_Q35_G:
- is_i945 = 1;
- break;
-
- default:
- pipe_winsys->printf(pipe_winsys,
- "%s: unknown pci id 0x%x, cannot create context\n",
- __FUNCTION__, pci_id);
- return NULL;
- }
i915 = CALLOC_STRUCT(i915_context);
if (i915 == NULL)
@@ -268,11 +131,9 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
i915->winsys = i915_winsys;
i915->pipe.winsys = pipe_winsys;
+ i915->pipe.screen = screen;
i915->pipe.destroy = i915_destroy;
- i915->pipe.is_format_supported = i915_is_format_supported;
- i915->pipe.get_param = i915_get_param;
- i915->pipe.get_paramf = i915_get_paramf;
i915->pipe.clear = i915_clear;
@@ -295,15 +156,11 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
i915_init_surface_functions(i915);
i915_init_state_functions(i915);
i915_init_flush_functions(i915);
- i915_init_string_functions(i915);
i915_init_texture_functions(i915);
draw_install_aaline_stage(i915->draw, &i915->pipe);
draw_install_aapoint_stage(i915->draw, &i915->pipe);
- i915->pci_id = pci_id;
- i915->flags.is_i945 = is_i945;
-
i915->dirty = ~0;
i915->hardware_dirty = ~0;
@@ -311,11 +168,6 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
*/
i915->batch_start = NULL;
- /*
- * XXX we could plug GL selection/feedback into the drawing pipeline
- * by specifying a different setup/render stage.
- */
-
return &i915->pipe;
}
diff --git a/src/gallium/drivers/i915simple/i915_context.h b/src/gallium/drivers/i915simple/i915_context.h
index d32dded6bd..6401112f83 100644
--- a/src/gallium/drivers/i915simple/i915_context.h
+++ b/src/gallium/drivers/i915simple/i915_context.h
@@ -35,6 +35,8 @@
#include "draw/draw_vertex.h"
+#include "tgsi/util/tgsi_scan.h"
+
#define I915_TEX_UNITS 8
@@ -89,6 +91,9 @@
struct i915_fragment_shader
{
struct pipe_shader_state state;
+
+ struct tgsi_shader_info info;
+
uint *program;
uint program_len;
@@ -240,11 +245,6 @@ struct i915_context
unsigned hardware_dirty;
unsigned debug;
- unsigned pci_id;
-
- struct {
- unsigned is_i945:1;
- } flags;
};
/* A flag for each state_tracker state object:
@@ -320,6 +320,7 @@ void i915_init_string_functions( struct i915_context *i915 );
+
/***********************************************************************
* Inline conversion functions. These are better-typed than the
* macros used previously:
diff --git a/src/gallium/drivers/i915simple/i915_fpc.h b/src/gallium/drivers/i915simple/i915_fpc.h
index 250dfe6dbf..80a9576304 100644
--- a/src/gallium/drivers/i915simple/i915_fpc.h
+++ b/src/gallium/drivers/i915simple/i915_fpc.h
@@ -58,12 +58,6 @@ struct i915_fp_compile {
uint declarations[I915_PROGRAM_SIZE];
uint program[I915_PROGRAM_SIZE];
- uint input_semantic_name[PIPE_MAX_SHADER_INPUTS];
- uint input_semantic_index[PIPE_MAX_SHADER_INPUTS];
-
- uint output_semantic_name[PIPE_MAX_SHADER_OUTPUTS];
- uint output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
-
uint *csr; /**< Cursor, points into program. */
uint *decl; /**< Cursor, points into declarations. */
diff --git a/src/gallium/drivers/i915simple/i915_fpc_translate.c b/src/gallium/drivers/i915simple/i915_fpc_translate.c
index 76a2184e9a..c2d9a93c6c 100644
--- a/src/gallium/drivers/i915simple/i915_fpc_translate.c
+++ b/src/gallium/drivers/i915simple/i915_fpc_translate.c
@@ -162,8 +162,8 @@ src_vector(struct i915_fp_compile *p,
* We also use a texture coordinate to pass wpos when possible.
*/
- sem_name = p->input_semantic_name[index];
- sem_ind = p->input_semantic_index[index];
+ sem_name = p->shader->info.input_semantic_name[index];
+ sem_ind = p->shader->info.input_semantic_index[index];
switch (sem_name) {
case TGSI_SEMANTIC_POSITION:
@@ -265,7 +265,7 @@ get_result_vector(struct i915_fp_compile *p,
switch (dest->DstRegister.File) {
case TGSI_FILE_OUTPUT:
{
- uint sem_name = p->output_semantic_name[dest->DstRegister.Index];
+ uint sem_name = p->shader->info.output_semantic_name[dest->DstRegister.Index];
switch (sem_name) {
case TGSI_SEMANTIC_POSITION:
return UREG(REG_TYPE_OD, 0);
@@ -942,28 +942,6 @@ i915_translate_instructions(struct i915_fp_compile *p,
switch( parse.FullToken.Token.Type ) {
case TGSI_TOKEN_TYPE_DECLARATION:
if (parse.FullToken.FullDeclaration.Declaration.File
- == TGSI_FILE_INPUT) {
- /* save input register info for use in src_vector() */
- uint ind, sem, semi;
- ind = parse.FullToken.FullDeclaration.u.DeclarationRange.First;
- sem = parse.FullToken.FullDeclaration.Semantic.SemanticName;
- semi = parse.FullToken.FullDeclaration.Semantic.SemanticIndex;
- /*debug_printf("FS Input DECL [%u] sem %u\n", ind, sem);*/
- p->input_semantic_name[ind] = sem;
- p->input_semantic_index[ind] = semi;
- }
- else if (parse.FullToken.FullDeclaration.Declaration.File
- == TGSI_FILE_OUTPUT) {
- /* save output register info for use in get_result_vector() */
- uint ind, sem, semi;
- ind = parse.FullToken.FullDeclaration.u.DeclarationRange.First;
- sem = parse.FullToken.FullDeclaration.Semantic.SemanticName;
- semi = parse.FullToken.FullDeclaration.Semantic.SemanticIndex;
- /*debug_printf("FS Output DECL [%u] sem %u\n", ind, sem);*/
- p->output_semantic_name[ind] = sem;
- p->output_semantic_index[ind] = semi;
- }
- else if (parse.FullToken.FullDeclaration.Declaration.File
== TGSI_FILE_CONSTANT) {
uint i;
for (i = parse.FullToken.FullDeclaration.u.DeclarationRange.First;
@@ -981,6 +959,7 @@ i915_translate_instructions(struct i915_fp_compile *p,
i <= parse.FullToken.FullDeclaration.u.DeclarationRange.Last;
i++) {
assert(i < I915_MAX_TEMPORARY);
+ /* XXX just use shader->info->file_mask[TGSI_FILE_TEMPORARY] */
p->temp_flag |= (1 << i); /* mark temp as used */
}
}
@@ -1163,7 +1142,7 @@ i915_find_wpos_space(struct i915_fp_compile *p)
i915_program_error(p, "No free texcoord for wpos value");
}
#else
- if (p->shader->state.input_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
+ if (p->shader->info.input_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
/* frag shader using the fragment position input */
#if 0
assert(0);
@@ -1184,7 +1163,7 @@ static void
i915_fixup_depth_write(struct i915_fp_compile *p)
{
/* XXX assuming pos/depth is always in output[0] */
- if (p->shader->state.output_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
+ if (p->shader->info.output_semantic_name[0] == TGSI_SEMANTIC_POSITION) {
const uint depth = UREG(REG_TYPE_OD, 0);
i915_emit_arith(p,
diff --git a/src/gallium/drivers/i915simple/i915_screen.c b/src/gallium/drivers/i915simple/i915_screen.c
new file mode 100644
index 0000000000..8d7bf0b33e
--- /dev/null
+++ b/src/gallium/drivers/i915simple/i915_screen.c
@@ -0,0 +1,250 @@
+/**************************************************************************
+ *
+ * Copyright 2008 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 "pipe/p_winsys.h"
+
+#include "i915_reg.h"
+#include "i915_context.h"
+#include "i915_screen.h"
+#include "i915_texture.h"
+
+
+static const char *
+i915_get_vendor( struct pipe_screen *pscreen )
+{
+ return "Tungsten Graphics, Inc.";
+}
+
+
+static const char *
+i915_get_name( struct pipe_screen *pscreen )
+{
+ static char buffer[128];
+ const char *chipset;
+
+ switch (i915_screen(pscreen)->pci_id) {
+ case PCI_CHIP_I915_G:
+ chipset = "915G";
+ break;
+ case PCI_CHIP_I915_GM:
+ chipset = "915GM";
+ break;
+ case PCI_CHIP_I945_G:
+ chipset = "945G";
+ break;
+ case PCI_CHIP_I945_GM:
+ chipset = "945GM";
+ break;
+ case PCI_CHIP_I945_GME:
+ chipset = "945GME";
+ break;
+ case PCI_CHIP_G33_G:
+ chipset = "G33";
+ break;
+ case PCI_CHIP_Q35_G:
+ chipset = "Q35";
+ break;
+ case PCI_CHIP_Q33_G:
+ chipset = "Q33";
+ break;
+ default:
+ chipset = "unknown";
+ break;
+ }
+
+ sprintf(buffer, "i915 (chipset: %s)", chipset);
+ return buffer;
+}
+
+
+static int
+i915_get_param(struct pipe_screen *screen, int param)
+{
+ 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 0;
+ case PIPE_CAP_S3TC:
+ return 0;
+ case PIPE_CAP_ANISOTROPIC_FILTER:
+ return 0;
+ case PIPE_CAP_POINT_SPRITE:
+ return 0;
+ case PIPE_CAP_MAX_RENDER_TARGETS:
+ return 1;
+ case PIPE_CAP_OCCLUSION_QUERY:
+ return 0;
+ case PIPE_CAP_TEXTURE_SHADOW_MAP:
+ return 1;
+ case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
+ return 11; /* max 1024x1024 */
+ case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
+ return 8; /* max 128x128x128 */
+ case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
+ return 11; /* max 1024x1024 */
+ default:
+ return 0;
+ }
+}
+
+
+static float
+i915_get_paramf(struct pipe_screen *screen, int param)
+{
+ switch (param) {
+ case PIPE_CAP_MAX_LINE_WIDTH:
+ /* fall-through */
+ case PIPE_CAP_MAX_LINE_WIDTH_AA:
+ return 7.5;
+
+ case PIPE_CAP_MAX_POINT_WIDTH:
+ /* fall-through */
+ case PIPE_CAP_MAX_POINT_WIDTH_AA:
+ return 255.0;
+
+ case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
+ return 4.0;
+
+ case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
+ return 16.0;
+
+ default:
+ return 0;
+ }
+}
+
+
+static boolean
+i915_is_format_supported( struct pipe_screen *screen,
+ enum pipe_format format, uint type )
+{
+ static const enum pipe_format tex_supported[] = {
+ PIPE_FORMAT_R8G8B8A8_UNORM,
+ PIPE_FORMAT_A8R8G8B8_UNORM,
+ PIPE_FORMAT_R5G6B5_UNORM,
+ PIPE_FORMAT_U_L8,
+ PIPE_FORMAT_U_A8,
+ PIPE_FORMAT_U_I8,
+ PIPE_FORMAT_U_A8_L8,
+ PIPE_FORMAT_YCBCR,
+ PIPE_FORMAT_YCBCR_REV,
+ PIPE_FORMAT_S8Z24_UNORM,
+ PIPE_FORMAT_NONE /* list terminator */
+ };
+ static const enum pipe_format surface_supported[] = {
+ PIPE_FORMAT_A8R8G8B8_UNORM,
+ PIPE_FORMAT_R5G6B5_UNORM,
+ PIPE_FORMAT_S8Z24_UNORM,
+ /*PIPE_FORMAT_R16G16B16A16_SNORM,*/
+ PIPE_FORMAT_NONE /* list terminator */
+ };
+ const enum pipe_format *list;
+ uint i;
+
+ switch (type) {
+ case PIPE_TEXTURE:
+ list = tex_supported;
+ break;
+ case PIPE_SURFACE:
+ list = surface_supported;
+ break;
+ default:
+ assert(0);
+ }
+
+ for (i = 0; list[i] != PIPE_FORMAT_NONE; i++) {
+ if (list[i] == format)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+static void
+i915_destroy_screen( struct pipe_screen *screen )
+{
+ FREE(screen);
+}
+
+
+/**
+ * Create a new i915_screen object
+ */
+struct pipe_screen *
+i915_create_screen(struct pipe_winsys *winsys, uint pci_id)
+{
+ struct i915_screen *i915screen = CALLOC_STRUCT(i915_screen);
+
+ if (!i915screen)
+ return NULL;
+
+ switch (pci_id) {
+ case PCI_CHIP_I915_G:
+ case PCI_CHIP_I915_GM:
+ i915screen->is_i945 = FALSE;
+ break;
+
+ case PCI_CHIP_I945_G:
+ case PCI_CHIP_I945_GM:
+ case PCI_CHIP_I945_GME:
+ case PCI_CHIP_G33_G:
+ case PCI_CHIP_Q33_G:
+ case PCI_CHIP_Q35_G:
+ i915screen->is_i945 = TRUE;
+ break;
+
+ default:
+ winsys->printf(winsys,
+ "%s: unknown pci id 0x%x, cannot create screen\n",
+ __FUNCTION__, pci_id);
+ return NULL;
+ }
+
+ i915screen->pci_id = pci_id;
+
+ i915screen->screen.winsys = winsys;
+
+ i915screen->screen.destroy = i915_destroy_screen;
+
+ i915screen->screen.get_name = i915_get_name;
+ i915screen->screen.get_vendor = i915_get_vendor;
+ i915screen->screen.get_param = i915_get_param;
+ i915screen->screen.get_paramf = i915_get_paramf;
+ i915screen->screen.is_format_supported = i915_is_format_supported;
+
+ i915_init_screen_texture_functions(&i915screen->screen);
+
+ return &i915screen->screen;
+}
diff --git a/src/gallium/drivers/i965simple/brw_strings.c b/src/gallium/drivers/i915simple/i915_screen.h
index 3d9c50961f..73b0ff05ce 100644
--- a/src/gallium/drivers/i965simple/brw_strings.c
+++ b/src/gallium/drivers/i915simple/i915_screen.h
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,48 +25,45 @@
*
**************************************************************************/
-#include "brw_context.h"
-#include "brw_reg.h"
+#ifndef I915_SCREEN_H
+#define I915_SCREEN_H
-static const char *brw_get_vendor( struct pipe_context *pipe )
+
+#include "pipe/p_screen.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * Subclass of pipe_screen
+ */
+struct i915_screen
{
- return "Tungsten Graphics, Inc.";
-}
+ struct pipe_screen screen;
+ boolean is_i945;
+ uint pci_id;
+};
-static const char *brw_get_name( struct pipe_context *pipe )
+
+/** cast wrapper */
+static INLINE struct i915_screen *
+i915_screen(struct pipe_screen *pscreen)
{
- static char buffer[128];
- const char *chipset;
-
- switch (brw_context(pipe)->pci_id) {
- case PCI_CHIP_I965_Q:
- chipset = "Intel(R) 965Q";
- break;
- case PCI_CHIP_I965_G:
- case PCI_CHIP_I965_G_1:
- chipset = "Intel(R) 965G";
- break;
- case PCI_CHIP_I965_GM:
- chipset = "Intel(R) 965GM";
- break;
- case PCI_CHIP_I965_GME:
- chipset = "Intel(R) 965GME/GLE";
- break;
- default:
- chipset = "unknown";
- break;
- }
-
- sprintf(buffer, "i965 (chipset: %s)", chipset);
- return buffer;
+ return (struct i915_screen *) pscreen;
}
-void
-brw_init_string_functions(struct brw_context *brw)
-{
- brw->pipe.get_name = brw_get_name;
- brw->pipe.get_vendor = brw_get_vendor;
+extern struct pipe_screen *
+i915_create_screen(struct pipe_winsys *winsys, uint pci_id);
+
+
+#ifdef __cplusplus
}
+#endif
+
+#endif /* I915_SCREEN_H */
diff --git a/src/gallium/drivers/i915simple/i915_state.c b/src/gallium/drivers/i915simple/i915_state.c
index a35bdf941f..27af46bea0 100644
--- a/src/gallium/drivers/i915simple/i915_state.c
+++ b/src/gallium/drivers/i915simple/i915_state.c
@@ -429,6 +429,8 @@ i915_create_fs_state(struct pipe_context *pipe,
ifs->state = *templ;
+ tgsi_scan_shader(templ->tokens, &ifs->info);
+
/* The shader's compiled to i915 instructions here */
i915_translate_fragment_program(i915, ifs);
@@ -530,8 +532,7 @@ static void i915_set_sampler_texture(struct pipe_context *pipe,
{
struct i915_context *i915 = i915_context(pipe);
- pipe_texture_reference(pipe,
- (struct pipe_texture **) &i915->texture[sampler],
+ pipe_texture_reference((struct pipe_texture **) &i915->texture[sampler],
texture);
i915->dirty |= I915_NEW_TEXTURE;
diff --git a/src/gallium/drivers/i915simple/i915_state_derived.c b/src/gallium/drivers/i915simple/i915_state_derived.c
index 5cf70acdf3..4daccec6e0 100644
--- a/src/gallium/drivers/i915simple/i915_state_derived.c
+++ b/src/gallium/drivers/i915simple/i915_state_derived.c
@@ -43,7 +43,7 @@
*/
static void calculate_vertex_layout( struct i915_context *i915 )
{
- const struct pipe_shader_state *fs = &i915->fs->state;
+ const struct i915_fragment_shader *fs = i915->fs;
const enum interp_mode colorInterp = i915->rasterizer->color_interp;
struct vertex_info vinfo;
boolean texCoords[8], colors[2], fog, needW;
@@ -57,18 +57,18 @@ static void calculate_vertex_layout( struct i915_context *i915 )
/* Determine which fragment program inputs are needed. Setup HW vertex
* layout below, in the HW-specific attribute order.
*/
- for (i = 0; i < fs->num_inputs; i++) {
- switch (fs->input_semantic_name[i]) {
+ for (i = 0; i < fs->info.num_inputs; i++) {
+ switch (fs->info.input_semantic_name[i]) {
case TGSI_SEMANTIC_POSITION:
break;
case TGSI_SEMANTIC_COLOR:
- assert(fs->input_semantic_index[i] < 2);
- colors[fs->input_semantic_index[i]] = TRUE;
+ assert(fs->info.input_semantic_index[i] < 2);
+ colors[fs->info.input_semantic_index[i]] = TRUE;
break;
case TGSI_SEMANTIC_GENERIC:
/* usually a texcoord */
{
- const uint unit = fs->input_semantic_index[i];
+ const uint unit = fs->info.input_semantic_index[i];
assert(unit < 8);
texCoords[unit] = TRUE;
needW = TRUE;
diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c
index 1b415a94d4..ef5adff550 100644
--- a/src/gallium/drivers/i915simple/i915_texture.c
+++ b/src/gallium/drivers/i915simple/i915_texture.c
@@ -40,6 +40,7 @@
#include "i915_context.h"
#include "i915_texture.h"
#include "i915_debug.h"
+#include "i915_screen.h"
static unsigned minify( unsigned d )
@@ -187,7 +188,7 @@ static const int step_offsets[6][2] = {
static boolean
-i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
+i915_miptree_layout(struct i915_texture * tex)
{
struct pipe_texture *pt = &tex->base;
unsigned level;
@@ -311,7 +312,7 @@ i915_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
static boolean
-i945_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
+i945_miptree_layout(struct i915_texture * tex)
{
struct pipe_texture *pt = &tex->base;
unsigned level;
@@ -479,23 +480,25 @@ i945_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
static struct pipe_texture *
-i915_texture_create(struct pipe_context *pipe,
- const struct pipe_texture *templat)
+i915_texture_create_screen(struct pipe_screen *screen,
+ const struct pipe_texture *templat)
{
struct i915_texture *tex = CALLOC_STRUCT(i915_texture);
if (tex) {
- struct i915_context *i915 = i915_context(pipe);
+ struct i915_screen *i915screen = i915_screen(screen);
+ struct pipe_winsys *ws = screen->winsys;
tex->base = *templat;
tex->base.refcount = 1;
+ tex->base.screen = screen;
- if (i915->flags.is_i945 ? i945_miptree_layout(pipe, tex) :
- i915_miptree_layout(pipe, tex))
- tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64,
- PIPE_BUFFER_USAGE_PIXEL,
- tex->pitch * tex->base.cpp *
- tex->total_height);
+ if (i915screen->is_i945 ? i945_miptree_layout(tex) :
+ i915_miptree_layout(tex))
+ tex->buffer = ws->buffer_create(ws, 64,
+ PIPE_BUFFER_USAGE_PIXEL,
+ tex->pitch * tex->base.cpp *
+ tex->total_height);
if (!tex->buffer) {
FREE(tex);
@@ -508,7 +511,8 @@ i915_texture_create(struct pipe_context *pipe,
static void
-i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
+i915_texture_release_screen(struct pipe_screen *screen,
+ struct pipe_texture **pt)
{
if (!*pt)
return;
@@ -525,7 +529,7 @@ i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
- pipe_buffer_reference(pipe->winsys, &tex->buffer, NULL);
+ pipe_buffer_reference(screen->winsys, &tex->buffer, NULL);
for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
if (tex->image_offset[i])
@@ -548,11 +552,12 @@ i915_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
* XXX note: same as code in sp_surface.c
*/
static struct pipe_surface *
-i915_get_tex_surface(struct pipe_context *pipe,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice)
+i915_get_tex_surface_screen(struct pipe_screen *screen,
+ struct pipe_texture *pt,
+ unsigned face, unsigned level, unsigned zslice)
{
struct i915_texture *tex = (struct i915_texture *)pt;
+ struct pipe_winsys *ws = screen->winsys;
struct pipe_surface *ps;
unsigned offset; /* in bytes */
@@ -569,11 +574,11 @@ i915_get_tex_surface(struct pipe_context *pipe,
assert(zslice == 0);
}
- ps = pipe->winsys->surface_alloc(pipe->winsys);
+ ps = ws->surface_alloc(ws);
if (ps) {
assert(ps->refcount);
assert(ps->winsys);
- pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
+ pipe_buffer_reference(ws, &ps->buffer, tex->buffer);
ps->format = pt->format;
ps->cpp = pt->cpp;
ps->width = pt->width[level];
@@ -585,12 +590,17 @@ i915_get_tex_surface(struct pipe_context *pipe,
}
-
void
i915_init_texture_functions(struct i915_context *i915)
{
- i915->pipe.texture_create = i915_texture_create;
- i915->pipe.texture_release = i915_texture_release;
i915->pipe.texture_update = i915_texture_update;
- i915->pipe.get_tex_surface = i915_get_tex_surface;
+}
+
+
+void
+i915_init_screen_texture_functions(struct pipe_screen *screen)
+{
+ screen->texture_create = i915_texture_create_screen;
+ screen->texture_release = i915_texture_release_screen;
+ screen->get_tex_surface = i915_get_tex_surface_screen;
}
diff --git a/src/gallium/drivers/i915simple/i915_texture.h b/src/gallium/drivers/i915simple/i915_texture.h
index 6d8d41178f..7225016a9f 100644
--- a/src/gallium/drivers/i915simple/i915_texture.h
+++ b/src/gallium/drivers/i915simple/i915_texture.h
@@ -28,11 +28,16 @@
#ifndef I915_TEXTURE_H
#define I915_TEXTURE_H
-struct pipe_context;
+struct i915_context;
+struct pipe_screen;
extern void
i915_init_texture_functions(struct i915_context *i915);
+extern void
+i915_init_screen_texture_functions(struct pipe_screen *screen);
+
+
#endif /* I915_TEXTURE_H */
diff --git a/src/gallium/drivers/i915simple/i915_winsys.h b/src/gallium/drivers/i915simple/i915_winsys.h
index fe49710852..aea3003281 100644
--- a/src/gallium/drivers/i915simple/i915_winsys.h
+++ b/src/gallium/drivers/i915simple/i915_winsys.h
@@ -40,6 +40,11 @@
#include "pipe/p_defines.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
/* Pipe drivers are (meant to be!) independent of both GL and the
* window system. The window system provides a buffer manager and a
* set of additional hooks for things like command buffer submission,
@@ -52,6 +57,7 @@
struct pipe_buffer;
struct pipe_winsys;
+struct pipe_screen;
/**
@@ -107,9 +113,12 @@ struct i915_winsys {
#define I915_BUFFER_USAGE_LIT_VERTEX (PIPE_BUFFER_USAGE_CUSTOM << 0)
-struct pipe_context *i915_create( struct pipe_winsys *,
- struct i915_winsys *,
- unsigned pci_id );
+struct pipe_context *i915_create_context( struct pipe_screen *,
+ struct pipe_winsys *,
+ struct i915_winsys * );
+#ifdef __cplusplus
+}
+#endif
#endif
diff --git a/src/gallium/drivers/i965simple/Makefile b/src/gallium/drivers/i965simple/Makefile
index cc8580836c..e97146e57c 100644
--- a/src/gallium/drivers/i965simple/Makefile
+++ b/src/gallium/drivers/i965simple/Makefile
@@ -6,7 +6,7 @@ LIBNAME = i965simple
C_SOURCES = \
brw_blit.c \
brw_flush.c \
- brw_strings.c \
+ brw_screen.c \
brw_surface.c \
brw_cc.c \
brw_clip.c \
@@ -30,7 +30,6 @@ C_SOURCES = \
brw_sf.c \
brw_sf_emit.c \
brw_sf_state.c \
- brw_shader_info.c \
brw_state.c \
brw_state_batch.c \
brw_state_cache.c \
diff --git a/src/gallium/drivers/i965simple/SConscript b/src/gallium/drivers/i965simple/SConscript
index 74621de84c..c0825c4de3 100644
--- a/src/gallium/drivers/i965simple/SConscript
+++ b/src/gallium/drivers/i965simple/SConscript
@@ -29,13 +29,11 @@ i965simple = env.ConvenienceLibrary(
'brw_sf.c',
'brw_sf_emit.c',
'brw_sf_state.c',
- 'brw_shader_info.c',
'brw_state.c',
'brw_state_batch.c',
'brw_state_cache.c',
'brw_state_pool.c',
'brw_state_upload.c',
- 'brw_strings.c',
'brw_surface.c',
'brw_tex_layout.c',
'brw_urb.c',
diff --git a/src/gallium/drivers/i965simple/brw_context.c b/src/gallium/drivers/i965simple/brw_context.c
index 6fb840708e..7c908da672 100644
--- a/src/gallium/drivers/i965simple/brw_context.c
+++ b/src/gallium/drivers/i965simple/brw_context.c
@@ -40,15 +40,14 @@
#include "pipe/p_winsys.h"
#include "pipe/p_context.h"
#include "pipe/p_util.h"
+#include "pipe/p_screen.h"
-/***************************************
- * Mesa's Driver Functions
- ***************************************/
#ifndef BRW_DEBUG
int BRW_DEBUG = (0);
#endif
+
static void brw_destroy(struct pipe_context *pipe)
{
struct brw_context *brw = brw_context(pipe);
@@ -56,6 +55,7 @@ static void brw_destroy(struct pipe_context *pipe)
FREE(brw);
}
+
static void brw_clear(struct pipe_context *pipe, struct pipe_surface *ps,
unsigned clearValue)
{
@@ -71,163 +71,31 @@ static void brw_clear(struct pipe_context *pipe, struct pipe_surface *ps,
}
-static int
-brw_get_param(struct pipe_context *pipe, int param)
-{
- 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 0;
- case PIPE_CAP_S3TC:
- return 0;
- case PIPE_CAP_ANISOTROPIC_FILTER:
- return 0;
- case PIPE_CAP_POINT_SPRITE:
- return 0;
- case PIPE_CAP_MAX_RENDER_TARGETS:
- return 1;
- case PIPE_CAP_OCCLUSION_QUERY:
- return 0;
- case PIPE_CAP_TEXTURE_SHADOW_MAP:
- return 1;
- case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
- return 11; /* max 1024x1024 */
- case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
- return 8; /* max 128x128x128 */
- case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
- return 11; /* max 1024x1024 */
- default:
- return 0;
- }
-}
-
-
-static float
-brw_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 7.5;
-
- case PIPE_CAP_MAX_POINT_WIDTH:
- /* fall-through */
- case PIPE_CAP_MAX_POINT_WIDTH_AA:
- return 255.0;
-
- case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
- return 4.0;
-
- case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
- return 16.0;
-
- default:
- return 0;
- }
-}
-
-static boolean
-brw_is_format_supported( struct pipe_context *pipe,
- enum pipe_format format, uint type )
-{
-#if 0
- /* XXX: This is broken -- rewrite if still needed. */
- static const unsigned tex_supported[] = {
- PIPE_FORMAT_U_R8_G8_B8_A8,
- PIPE_FORMAT_U_A8_R8_G8_B8,
- PIPE_FORMAT_U_R5_G6_B5,
- PIPE_FORMAT_U_L8,
- PIPE_FORMAT_U_A8,
- PIPE_FORMAT_U_I8,
- PIPE_FORMAT_U_L8_A8,
- PIPE_FORMAT_YCBCR,
- PIPE_FORMAT_YCBCR_REV,
- PIPE_FORMAT_S8_Z24,
- };
-
-
- /* Actually a lot more than this - add later:
- */
- static const unsigned render_supported[] = {
- PIPE_FORMAT_U_A8_R8_G8_B8,
- PIPE_FORMAT_U_R5_G6_B5,
- };
-
- /*
- */
- static const unsigned z_stencil_supported[] = {
- PIPE_FORMAT_U_Z16,
- PIPE_FORMAT_U_Z32,
- PIPE_FORMAT_S8_Z24,
- };
-
- switch (type) {
- case PIPE_RENDER_FORMAT:
- *numFormats = Elements(render_supported);
- return render_supported;
-
- case PIPE_TEX_FORMAT:
- *numFormats = Elements(tex_supported);
- return render_supported;
-
- case PIPE_Z_STENCIL_FORMAT:
- *numFormats = Elements(render_supported);
- return render_supported;
-
- default:
- *numFormats = 0;
- return NULL;
- }
-#else
- switch (format) {
- case PIPE_FORMAT_A8R8G8B8_UNORM:
- case PIPE_FORMAT_R5G6B5_UNORM:
- case PIPE_FORMAT_S8Z24_UNORM:
- return TRUE;
- default:
- return FALSE;
- };
- return FALSE;
-#endif
-}
-
-
-
-
-struct pipe_context *brw_create(struct pipe_winsys *pipe_winsys,
+struct pipe_context *brw_create(struct pipe_screen *screen,
struct brw_winsys *brw_winsys,
unsigned pci_id)
{
struct brw_context *brw;
- pipe_winsys->printf(pipe_winsys,
- "%s: creating brw_context with pci id 0x%x\n",
- __FUNCTION__, pci_id);
+ screen->winsys->printf(screen->winsys,
+ "%s: creating brw_context with pci id 0x%x\n",
+ __FUNCTION__, pci_id);
brw = CALLOC_STRUCT(brw_context);
if (brw == NULL)
return NULL;
brw->winsys = brw_winsys;
- brw->pipe.winsys = pipe_winsys;
+ brw->pipe.winsys = screen->winsys;
+ brw->pipe.screen = screen;
brw->pipe.destroy = brw_destroy;
- brw->pipe.is_format_supported = brw_is_format_supported;
- brw->pipe.get_param = brw_get_param;
- brw->pipe.get_paramf = brw_get_paramf;
brw->pipe.clear = brw_clear;
brw_init_surface_functions(brw);
brw_init_texture_functions(brw);
brw_init_state_functions(brw);
brw_init_flush_functions(brw);
- brw_init_string_functions(brw);
brw_init_draw_functions( brw );
diff --git a/src/gallium/drivers/i965simple/brw_context.h b/src/gallium/drivers/i965simple/brw_context.h
index 65664d853d..4da3a8cffc 100644
--- a/src/gallium/drivers/i965simple/brw_context.h
+++ b/src/gallium/drivers/i965simple/brw_context.h
@@ -38,6 +38,8 @@
#include "pipe/p_defines.h"
#include "pipe/p_state.h"
+#include "tgsi/util/tgsi_scan.h"
+
#include "brw_structs.h"
#include "brw_winsys.h"
@@ -195,33 +197,22 @@ struct brw_state_flags {
};
-struct brw_shader_info {
- int nr_regs[8]; /* TGSI_FILE_* */
-};
-
-
-
struct brw_vertex_program {
struct pipe_shader_state program;
- struct brw_shader_info info;
+ struct tgsi_shader_info info;
int id;
};
-
struct brw_fragment_program {
struct pipe_shader_state program;
- struct brw_shader_info info;
+ struct tgsi_shader_info info;
- boolean UsesDepth;
- boolean UsesKill;
- boolean ComputesDepth;
+ boolean UsesDepth; /* XXX add this to tgsi_shader_info? */
int id;
};
-
-
struct pipe_setup_linkage {
struct {
unsigned vp_output:5;
@@ -502,7 +493,7 @@ struct brw_context
/* Arrays with buffer objects to copy non-bufferobj arrays into
* for upload:
*/
- struct pipe_vertex_buffer *vbo_array[PIPE_ATTRIB_MAX];
+ const struct pipe_vertex_buffer *vbo_array[PIPE_ATTRIB_MAX];
struct brw_vertex_element_state inputs[PIPE_ATTRIB_MAX];
diff --git a/src/gallium/drivers/i965simple/brw_draw_upload.c b/src/gallium/drivers/i965simple/brw_draw_upload.c
index aa85d93866..9c0c78c236 100644
--- a/src/gallium/drivers/i965simple/brw_draw_upload.c
+++ b/src/gallium/drivers/i965simple/brw_draw_upload.c
@@ -256,7 +256,7 @@ boolean brw_upload_vertex_elements( struct brw_context *brw )
struct brw_vertex_element_packet vep;
unsigned i;
- unsigned nr_enabled = brw->attribs.VertexProgram->program.num_inputs;
+ unsigned nr_enabled = brw->attribs.VertexProgram->info.num_inputs;
memset(&vep, 0, sizeof(vep));
diff --git a/src/gallium/drivers/i965simple/brw_screen.c b/src/gallium/drivers/i965simple/brw_screen.c
new file mode 100644
index 0000000000..5be369fe52
--- /dev/null
+++ b/src/gallium/drivers/i965simple/brw_screen.c
@@ -0,0 +1,235 @@
+/**************************************************************************
+ *
+ * Copyright 2008 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 "pipe/p_winsys.h"
+
+#include "brw_context.h"
+#include "brw_screen.h"
+#include "brw_tex_layout.h"
+
+
+static const char *
+brw_get_vendor( struct pipe_screen *screen )
+{
+ return "Tungsten Graphics, Inc.";
+}
+
+
+static const char *
+brw_get_name( struct pipe_screen *screen )
+{
+ static char buffer[128];
+ const char *chipset;
+
+ switch (brw_screen(screen)->pci_id) {
+ case PCI_CHIP_I965_Q:
+ chipset = "Intel(R) 965Q";
+ break;
+ case PCI_CHIP_I965_G:
+ case PCI_CHIP_I965_G_1:
+ chipset = "Intel(R) 965G";
+ break;
+ case PCI_CHIP_I965_GM:
+ chipset = "Intel(R) 965GM";
+ break;
+ case PCI_CHIP_I965_GME:
+ chipset = "Intel(R) 965GME/GLE";
+ break;
+ default:
+ chipset = "unknown";
+ break;
+ }
+
+ sprintf(buffer, "i965 (chipset: %s)", chipset);
+ return buffer;
+}
+
+
+static int
+brw_get_param(struct pipe_screen *screen, int param)
+{
+ 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 0;
+ case PIPE_CAP_S3TC:
+ return 0;
+ case PIPE_CAP_ANISOTROPIC_FILTER:
+ return 0;
+ case PIPE_CAP_POINT_SPRITE:
+ return 0;
+ case PIPE_CAP_MAX_RENDER_TARGETS:
+ return 1;
+ case PIPE_CAP_OCCLUSION_QUERY:
+ return 0;
+ case PIPE_CAP_TEXTURE_SHADOW_MAP:
+ return 1;
+ case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
+ return 11; /* max 1024x1024 */
+ case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
+ return 8; /* max 128x128x128 */
+ case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
+ return 11; /* max 1024x1024 */
+ default:
+ return 0;
+ }
+}
+
+
+static float
+brw_get_paramf(struct pipe_screen *screen, int param)
+{
+ switch (param) {
+ case PIPE_CAP_MAX_LINE_WIDTH:
+ /* fall-through */
+ case PIPE_CAP_MAX_LINE_WIDTH_AA:
+ return 7.5;
+
+ case PIPE_CAP_MAX_POINT_WIDTH:
+ /* fall-through */
+ case PIPE_CAP_MAX_POINT_WIDTH_AA:
+ return 255.0;
+
+ case PIPE_CAP_MAX_TEXTURE_ANISOTROPY:
+ return 4.0;
+
+ case PIPE_CAP_MAX_TEXTURE_LOD_BIAS:
+ return 16.0;
+
+ default:
+ return 0;
+ }
+}
+
+
+static boolean
+brw_is_format_supported( struct pipe_screen *screen,
+ enum pipe_format format, uint type )
+{
+#if 0
+ /* XXX: This is broken -- rewrite if still needed. */
+ static const unsigned tex_supported[] = {
+ PIPE_FORMAT_U_R8_G8_B8_A8,
+ PIPE_FORMAT_U_A8_R8_G8_B8,
+ PIPE_FORMAT_U_R5_G6_B5,
+ PIPE_FORMAT_U_L8,
+ PIPE_FORMAT_U_A8,
+ PIPE_FORMAT_U_I8,
+ PIPE_FORMAT_U_L8_A8,
+ PIPE_FORMAT_YCBCR,
+ PIPE_FORMAT_YCBCR_REV,
+ PIPE_FORMAT_S8_Z24,
+ };
+
+
+ /* Actually a lot more than this - add later:
+ */
+ static const unsigned render_supported[] = {
+ PIPE_FORMAT_U_A8_R8_G8_B8,
+ PIPE_FORMAT_U_R5_G6_B5,
+ };
+
+ /*
+ */
+ static const unsigned z_stencil_supported[] = {
+ PIPE_FORMAT_U_Z16,
+ PIPE_FORMAT_U_Z32,
+ PIPE_FORMAT_S8_Z24,
+ };
+
+ switch (type) {
+ case PIPE_RENDER_FORMAT:
+ *numFormats = Elements(render_supported);
+ return render_supported;
+
+ case PIPE_TEX_FORMAT:
+ *numFormats = Elements(tex_supported);
+ return render_supported;
+
+ case PIPE_Z_STENCIL_FORMAT:
+ *numFormats = Elements(render_supported);
+ return render_supported;
+
+ default:
+ *numFormats = 0;
+ return NULL;
+ }
+#else
+ switch (format) {
+ case PIPE_FORMAT_A8R8G8B8_UNORM:
+ case PIPE_FORMAT_R5G6B5_UNORM:
+ case PIPE_FORMAT_S8Z24_UNORM:
+ return TRUE;
+ default:
+ return FALSE;
+ };
+ return FALSE;
+#endif
+}
+
+
+static void
+brw_destroy_screen( struct pipe_screen *screen )
+{
+ FREE(screen);
+}
+
+
+/**
+ * Create a new brw_screen object
+ */
+struct pipe_screen *
+brw_create_screen(struct pipe_winsys *winsys, uint pci_id)
+{
+ struct brw_screen *brwscreen = CALLOC_STRUCT(brw_screen);
+
+ if (!brwscreen)
+ return NULL;
+
+ brwscreen->pci_id = pci_id;
+
+ brwscreen->screen.winsys = winsys;
+
+ brwscreen->screen.destroy = brw_destroy_screen;
+
+ brwscreen->screen.get_name = brw_get_name;
+ brwscreen->screen.get_vendor = brw_get_vendor;
+ brwscreen->screen.get_param = brw_get_param;
+ brwscreen->screen.get_paramf = brw_get_paramf;
+ brwscreen->screen.is_format_supported = brw_is_format_supported;
+
+ brw_init_screen_texture_funcs(&brwscreen->screen);
+
+ return &brwscreen->screen;
+}
diff --git a/src/gallium/drivers/i915simple/i915_strings.c b/src/gallium/drivers/i965simple/brw_screen.h
index 301fedea19..d3c70387e6 100644
--- a/src/gallium/drivers/i915simple/i915_strings.c
+++ b/src/gallium/drivers/i965simple/brw_screen.h
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,59 +25,44 @@
*
**************************************************************************/
-#include "i915_context.h"
-#include "i915_reg.h"
+#ifndef BRW_SCREEN_H
+#define BRW_SCREEN_H
-static const char *i915_get_vendor( struct pipe_context *pipe )
+
+#include "pipe/p_screen.h"
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * Subclass of pipe_screen
+ */
+struct brw_screen
{
- return "Tungsten Graphics, Inc.";
-}
+ struct pipe_screen screen;
+ uint pci_id;
+};
-static const char *i915_get_name( struct pipe_context *pipe )
+
+/** cast wrapper */
+static INLINE struct brw_screen *
+brw_screen(struct pipe_screen *pscreen)
{
- static char buffer[128];
- const char *chipset;
-
- switch (i915_context(pipe)->pci_id) {
- case PCI_CHIP_I915_G:
- chipset = "915G";
- break;
- case PCI_CHIP_I915_GM:
- chipset = "915GM";
- break;
- case PCI_CHIP_I945_G:
- chipset = "945G";
- break;
- case PCI_CHIP_I945_GM:
- chipset = "945GM";
- break;
- case PCI_CHIP_I945_GME:
- chipset = "945GME";
- break;
- case PCI_CHIP_G33_G:
- chipset = "G33";
- break;
- case PCI_CHIP_Q35_G:
- chipset = "Q35";
- break;
- case PCI_CHIP_Q33_G:
- chipset = "Q33";
- break;
- default:
- chipset = "unknown";
- break;
- }
-
- sprintf(buffer, "i915 (chipset: %s)", chipset);
- return buffer;
+ return (struct brw_screen *) pscreen;
}
-void
-i915_init_string_functions(struct i915_context *i915)
-{
- i915->pipe.get_name = i915_get_name;
- i915->pipe.get_vendor = i915_get_vendor;
+extern struct pipe_screen *
+brw_create_screen(struct pipe_winsys *winsys, uint pci_id);
+
+
+#ifdef __cplusplus
}
+#endif
+
+#endif /* BRW_SCREEN_H */
diff --git a/src/gallium/drivers/i965simple/brw_sf.c b/src/gallium/drivers/i965simple/brw_sf.c
index 7c83b81c85..c3b815a82b 100644
--- a/src/gallium/drivers/i965simple/brw_sf.c
+++ b/src/gallium/drivers/i965simple/brw_sf.c
@@ -133,7 +133,7 @@ static void upload_sf_prog( struct brw_context *brw )
key.vp_output_count = brw->vs.prog_data->outputs_written;
/* BRW_NEW_FS */
- key.fp_input_count = brw->attribs.FragmentProgram->info.nr_regs[TGSI_FILE_INPUT];
+ key.fp_input_count = brw->attribs.FragmentProgram->info.file_max[TGSI_FILE_INPUT] + 1;
/* BRW_NEW_REDUCED_PRIMITIVE */
diff --git a/src/gallium/drivers/i965simple/brw_shader_info.c b/src/gallium/drivers/i965simple/brw_shader_info.c
index a762a870fe..f4694a4433 100644
--- a/src/gallium/drivers/i965simple/brw_shader_info.c
+++ b/src/gallium/drivers/i965simple/brw_shader_info.c
@@ -6,8 +6,9 @@
#include "tgsi/util/tgsi_parse.h"
-
-
+/**
+ * XXX this obsolete new and no longer compiled.
+ */
void brw_shader_info(const struct tgsi_token *tokens,
struct brw_shader_info *info )
{
diff --git a/src/gallium/drivers/i965simple/brw_state.c b/src/gallium/drivers/i965simple/brw_state.c
index 2fc048bde0..6744a8aa4f 100644
--- a/src/gallium/drivers/i965simple/brw_state.c
+++ b/src/gallium/drivers/i965simple/brw_state.c
@@ -175,8 +175,12 @@ static void * brw_create_fs_state(struct pipe_context *pipe,
brw_fp->program = *shader;
brw_fp->id = brw_context(pipe)->program_id++;
+ tgsi_scan_shader(shader->tokens, &brw_fp->info);
+
+#if 0
brw_shader_info(shader->tokens,
- &brw_fp->info);
+ &brw_fp->info2);
+#endif
tgsi_dump(shader->tokens, 0);
@@ -211,9 +215,13 @@ static void *brw_create_vs_state(struct pipe_context *pipe,
*/
brw_vp->program = *shader;
brw_vp->id = brw_context(pipe)->program_id++;
- brw_shader_info(shader->tokens,
- &brw_vp->info);
+ tgsi_scan_shader(shader->tokens, &brw_vp->info);
+
+#if 0
+ brw_shader_info(shader->tokens,
+ &brw_vp->info2);
+#endif
tgsi_dump(shader->tokens, 0);
return (void *)brw_vp;
@@ -328,8 +336,7 @@ static void brw_set_sampler_texture(struct pipe_context *pipe,
{
struct brw_context *brw = brw_context(pipe);
- pipe_texture_reference(pipe,
- (struct pipe_texture **) &brw->attribs.Texture[unit],
+ pipe_texture_reference((struct pipe_texture **) &brw->attribs.Texture[unit],
texture);
brw->state.dirty.brw |= BRW_NEW_TEXTURE;
diff --git a/src/gallium/drivers/i965simple/brw_state.h b/src/gallium/drivers/i965simple/brw_state.h
index 258e9a556e..de0a6371b8 100644
--- a/src/gallium/drivers/i965simple/brw_state.h
+++ b/src/gallium/drivers/i965simple/brw_state.h
@@ -148,11 +148,4 @@ void brw_invalidate_pools( struct brw_context *brw );
void brw_clear_batch_cache_flush( struct brw_context *brw );
-/* brw_shader_info.c
- */
-
-void brw_shader_info(const struct tgsi_token *tokens,
- struct brw_shader_info *info );
-
-
#endif
diff --git a/src/gallium/drivers/i965simple/brw_surface.c b/src/gallium/drivers/i965simple/brw_surface.c
index dc4846d39f..c99a91dcf7 100644
--- a/src/gallium/drivers/i965simple/brw_surface.c
+++ b/src/gallium/drivers/i965simple/brw_surface.c
@@ -164,6 +164,7 @@ brw_surface_fill(struct pipe_context *pipe,
void
brw_init_surface_functions(struct brw_context *brw)
{
+ (void) brw_surface_data; /* silence warning */
brw->pipe.surface_copy = brw_surface_copy;
brw->pipe.surface_fill = brw_surface_fill;
}
diff --git a/src/gallium/drivers/i965simple/brw_tex_layout.c b/src/gallium/drivers/i965simple/brw_tex_layout.c
index 86ce3d0cc3..b24ac87c37 100644
--- a/src/gallium/drivers/i965simple/brw_tex_layout.c
+++ b/src/gallium/drivers/i965simple/brw_tex_layout.c
@@ -71,8 +71,6 @@ static unsigned minify( unsigned d )
}
-static boolean brw_miptree_layout(struct pipe_context *, struct brw_texture *);
-
static void intel_miptree_set_image_offset(struct brw_texture *tex,
unsigned level,
unsigned img,
@@ -199,7 +197,7 @@ static void i945_miptree_layout_2d(struct brw_texture *tex)
}
}
-static boolean brw_miptree_layout(struct pipe_context *pipe, struct brw_texture *tex)
+static boolean brw_miptree_layout(struct brw_texture *tex)
{
struct pipe_texture *pt = &tex->base;
/* XXX: these vary depending on image format:
@@ -301,20 +299,21 @@ static boolean brw_miptree_layout(struct pipe_context *pipe, struct brw_texture
static struct pipe_texture *
-brw_texture_create(struct pipe_context *pipe,
- const struct pipe_texture *templat)
+brw_texture_create_screen(struct pipe_screen *screen,
+ const struct pipe_texture *templat)
{
+ struct pipe_winsys *ws = screen->winsys;
struct brw_texture *tex = CALLOC_STRUCT(brw_texture);
if (tex) {
tex->base = *templat;
tex->base.refcount = 1;
- if (brw_miptree_layout(pipe, tex))
- tex->buffer = pipe->winsys->buffer_create(pipe->winsys, 64,
- PIPE_BUFFER_USAGE_PIXEL,
- tex->pitch * tex->base.cpp *
- tex->total_height);
+ if (brw_miptree_layout(tex))
+ tex->buffer = ws->buffer_create(ws, 64,
+ PIPE_BUFFER_USAGE_PIXEL,
+ tex->pitch * tex->base.cpp *
+ tex->total_height);
if (!tex->buffer) {
FREE(tex);
@@ -327,7 +326,8 @@ brw_texture_create(struct pipe_context *pipe,
static void
-brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
+brw_texture_release_screen(struct pipe_screen *screen,
+ struct pipe_texture **pt)
{
if (!*pt)
return;
@@ -337,6 +337,7 @@ brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
__FUNCTION__, (void *) *pt, (*pt)->refcount - 1);
*/
if (--(*pt)->refcount <= 0) {
+ struct pipe_winsys *ws = screen->winsys;
struct brw_texture *tex = (struct brw_texture *)*pt;
uint i;
@@ -344,7 +345,7 @@ brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
- pipe_buffer_reference(pipe->winsys, &tex->buffer, NULL);
+ pipe_buffer_reference(ws, &tex->buffer, NULL);
for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
if (tex->image_offset[i])
@@ -363,14 +364,12 @@ brw_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
}
-/*
- * XXX note: same as code in sp_surface.c
- */
static struct pipe_surface *
-brw_get_tex_surface(struct pipe_context *pipe,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice)
+brw_get_tex_surface_screen(struct pipe_screen *screen,
+ struct pipe_texture *pt,
+ unsigned face, unsigned level, unsigned zslice)
{
+ struct pipe_winsys *ws = screen->winsys;
struct brw_texture *tex = (struct brw_texture *)pt;
struct pipe_surface *ps;
unsigned offset; /* in bytes */
@@ -388,11 +387,11 @@ brw_get_tex_surface(struct pipe_context *pipe,
assert(zslice == 0);
}
- ps = pipe->winsys->surface_alloc(pipe->winsys);
+ ps = ws->surface_alloc(ws);
if (ps) {
assert(ps->format);
assert(ps->refcount);
- pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
+ pipe_buffer_reference(ws, &ps->buffer, tex->buffer);
ps->format = pt->format;
ps->cpp = pt->cpp;
ps->width = pt->width[level];
@@ -407,8 +406,15 @@ brw_get_tex_surface(struct pipe_context *pipe,
void
brw_init_texture_functions(struct brw_context *brw)
{
- brw->pipe.texture_create = brw_texture_create;
- brw->pipe.texture_release = brw_texture_release;
brw->pipe.texture_update = brw_texture_update;
- brw->pipe.get_tex_surface = brw_get_tex_surface;
}
+
+
+void
+brw_init_screen_texture_funcs(struct pipe_screen *screen)
+{
+ screen->texture_create = brw_texture_create_screen;
+ screen->texture_release = brw_texture_release_screen;
+ screen->get_tex_surface = brw_get_tex_surface_screen;
+}
+
diff --git a/src/gallium/drivers/i965simple/brw_tex_layout.h b/src/gallium/drivers/i965simple/brw_tex_layout.h
index ed49baeef8..a6b6ba8146 100644
--- a/src/gallium/drivers/i965simple/brw_tex_layout.h
+++ b/src/gallium/drivers/i965simple/brw_tex_layout.h
@@ -1,12 +1,44 @@
+/*
+ Copyright (C) Intel Corp. 2006. All Rights Reserved.
+ Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
+ develop this 3D driver.
+
+ 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, sublicense, 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 NONINFRINGEMENT.
+ IN NO EVENT SHALL THE COPYRIGHT OWNER(S) 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 BRW_TEX_LAYOUT_H
#define BRW_TEX_LAYOUT_H
struct brw_context;
+struct pipe_screen;
extern void
brw_init_texture_functions(struct brw_context *brw);
+extern void
+brw_init_screen_texture_funcs(struct pipe_screen *screen);
+
#endif
diff --git a/src/gallium/drivers/i965simple/brw_vs.c b/src/gallium/drivers/i965simple/brw_vs.c
index 738c6346d5..92327e896d 100644
--- a/src/gallium/drivers/i965simple/brw_vs.c
+++ b/src/gallium/drivers/i965simple/brw_vs.c
@@ -50,8 +50,8 @@ static void do_vs_prog( struct brw_context *brw,
brw_init_compile(&c.func);
c.vp = vp;
- c.prog_data.outputs_written = vp->program.num_outputs;
- c.prog_data.inputs_read = vp->program.num_inputs;
+ c.prog_data.outputs_written = vp->info.num_outputs;
+ c.prog_data.inputs_read = vp->info.num_inputs;
#if 0
if (c.key.copy_edgeflag) {
diff --git a/src/gallium/drivers/i965simple/brw_vs.h b/src/gallium/drivers/i965simple/brw_vs.h
index 0e58f043b0..070f9dfcae 100644
--- a/src/gallium/drivers/i965simple/brw_vs.h
+++ b/src/gallium/drivers/i965simple/brw_vs.h
@@ -52,7 +52,7 @@ struct brw_vs_compile {
struct brw_vs_prog_key key;
struct brw_vs_prog_data prog_data;
- struct brw_vertex_program *vp;
+ const struct brw_vertex_program *vp;
unsigned nr_inputs;
diff --git a/src/gallium/drivers/i965simple/brw_vs_emit.c b/src/gallium/drivers/i965simple/brw_vs_emit.c
index 05df4860ed..9020fcc001 100644
--- a/src/gallium/drivers/i965simple/brw_vs_emit.c
+++ b/src/gallium/drivers/i965simple/brw_vs_emit.c
@@ -86,7 +86,7 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c,
/* Allocate input regs:
*/
- c->nr_inputs = c->vp->program.num_inputs;
+ c->nr_inputs = c->vp->info.num_inputs;
for (i = 0; i < c->nr_inputs; i++) {
c->regs[TGSI_FILE_INPUT][i] = brw_vec8_grf(reg, 0);
reg++;
@@ -99,7 +99,7 @@ static void brw_vs_alloc_regs( struct brw_vs_compile *c,
c->nr_outputs = 0;
c->first_output = reg;
mrf = 4;
- for (i = 0; i < c->vp->program.num_outputs; i++) {
+ for (i = 0; i < c->vp->info.num_outputs; i++) {
c->nr_outputs++;
#if 0
if (i == VERT_RESULT_HPOS) {
@@ -1051,7 +1051,7 @@ static void process_instruction(struct brw_vs_compile *c,
{
struct brw_reg args[3], dst;
struct brw_compile *p = &c->func;
- struct brw_indirect stack_index = brw_indirect(0, 0);
+ /*struct brw_indirect stack_index = brw_indirect(0, 0);*/
unsigned i;
unsigned index;
unsigned file;
diff --git a/src/gallium/drivers/i965simple/brw_winsys.h b/src/gallium/drivers/i965simple/brw_winsys.h
index 3523a58614..b67bd73750 100644
--- a/src/gallium/drivers/i965simple/brw_winsys.h
+++ b/src/gallium/drivers/i965simple/brw_winsys.h
@@ -53,6 +53,8 @@
struct pipe_buffer;
struct pipe_fence_handle;
struct pipe_winsys;
+struct pipe_screen;
+
/* The pipe driver currently understands the following chipsets:
*/
@@ -181,7 +183,7 @@ struct brw_winsys {
#define BRW_BUFFER_USAGE_LIT_VERTEX (PIPE_BUFFER_USAGE_CUSTOM << 0)
-struct pipe_context *brw_create(struct pipe_winsys *,
+struct pipe_context *brw_create(struct pipe_screen *,
struct brw_winsys *,
unsigned pci_id);
diff --git a/src/gallium/drivers/i965simple/brw_wm.c b/src/gallium/drivers/i965simple/brw_wm.c
index 539b170744..1c4b5b5ede 100644
--- a/src/gallium/drivers/i965simple/brw_wm.c
+++ b/src/gallium/drivers/i965simple/brw_wm.c
@@ -94,11 +94,11 @@ static void brw_wm_populate_key( struct brw_context *brw,
/* Build the index for table lookup
*/
/* BRW_NEW_DEPTH_STENCIL */
- if (fp->UsesKill ||
+ if (fp->info.uses_kill ||
brw->attribs.DepthStencil->alpha.enabled)
lookup |= IZ_PS_KILL_ALPHATEST_BIT;
- if (fp->ComputesDepth)
+ if (fp->info.writes_z)
lookup |= IZ_PS_COMPUTES_DEPTH_BIT;
if (brw->attribs.DepthStencil->depth.enabled)
diff --git a/src/gallium/drivers/i965simple/brw_wm_decl.c b/src/gallium/drivers/i965simple/brw_wm_decl.c
index 97418a52e7..74ccfd494a 100644
--- a/src/gallium/drivers/i965simple/brw_wm_decl.c
+++ b/src/gallium/drivers/i965simple/brw_wm_decl.c
@@ -259,9 +259,12 @@ static void prealloc_reg(struct brw_wm_compile *c)
/* Then a copy of our part of the CURBE entry:
*/
{
- int nr_constants = c->fp->info.nr_regs[TGSI_FILE_CONSTANT];
+ int nr_constants = c->fp->info.file_max[TGSI_FILE_CONSTANT] + 1;
int index = 0;
+ /* XXX number of constants, or highest numbered constant? */
+ assert(nr_constants == c->fp->info.file_count[TGSI_FILE_CONSTANT]);
+
c->prog_data.max_const = 4*nr_constants;
for (i = 0; i < nr_constants; i++) {
for (j = 0; j < 4; j++, index++)
@@ -282,13 +285,14 @@ static void prealloc_reg(struct brw_wm_compile *c)
/* Next we receive the plane coefficients for parameter
* interpolation:
*/
- for (i = 0; i < c->fp->info.nr_regs[TGSI_FILE_INPUT]; i++) {
+ assert(c->fp->info.file_max[TGSI_FILE_INPUT] == c->fp->info.num_inputs);
+ for (i = 0; i < c->fp->info.file_max[TGSI_FILE_INPUT] + 1; i++) {
c->payload_coef[i] = brw_vec8_grf(c->reg_index, 0);
c->reg_index += 2;
}
c->prog_data.first_curbe_grf = c->key.nr_depth_regs * 2;
- c->prog_data.urb_read_length = (c->fp->program.num_inputs + 1) * 2;
+ c->prog_data.urb_read_length = (c->fp->info.num_inputs + 1) * 2;
c->prog_data.curb_read_length = nr_curbe_regs;
/* That's the end of the payload, now we can start allocating registers.
@@ -302,11 +306,17 @@ static void prealloc_reg(struct brw_wm_compile *c)
/* Now allocate room for the interpolated inputs and staging
* registers for the outputs:
*/
- for (i = 0; i < c->fp->info.nr_regs[TGSI_FILE_INPUT]; i++)
+ /* XXX do we want to loop over the _number_ of inputs/outputs or loop
+ * to the highest input/output index that's used?
+ * Probably the same, actually.
+ */
+ assert(c->fp->info.file_max[TGSI_FILE_INPUT] + 1 == c->fp->info.num_inputs);
+ assert(c->fp->info.file_max[TGSI_FILE_OUTPUT] + 1 == c->fp->info.num_outputs);
+ for (i = 0; i < c->fp->info.file_max[TGSI_FILE_INPUT] + 1; i++)
for (j = 0; j < 4; j++)
c->wm_regs[TGSI_FILE_INPUT][i][j] = brw_vec8_grf( c->reg_index++, 0 );
- for (i = 0; i < c->fp->info.nr_regs[TGSI_FILE_OUTPUT]; i++)
+ for (i = 0; i < c->fp->info.file_max[TGSI_FILE_OUTPUT] + 1; i++)
for (j = 0; j < 4; j++)
c->wm_regs[TGSI_FILE_OUTPUT][i][j] = brw_vec8_grf( c->reg_index++, 0 );
diff --git a/src/gallium/drivers/i965simple/brw_wm_state.c b/src/gallium/drivers/i965simple/brw_wm_state.c
index 5ccd488842..f3aa36b07f 100644
--- a/src/gallium/drivers/i965simple/brw_wm_state.c
+++ b/src/gallium/drivers/i965simple/brw_wm_state.c
@@ -117,11 +117,11 @@ static void upload_wm_unit(struct brw_context *brw )
if (fp->UsesDepth)
wm.wm5.program_uses_depth = 1; /* as far as we can tell */
- if (fp->ComputesDepth)
+ if (fp->info.writes_z)
wm.wm5.program_computes_depth = 1;
/* BRW_NEW_ALPHA_TEST */
- if (fp->UsesKill ||
+ if (fp->info.uses_kill ||
brw->attribs.DepthStencil->alpha.enabled)
wm.wm5.program_uses_killpixel = 1;
diff --git a/src/gallium/drivers/softpipe/Makefile b/src/gallium/drivers/softpipe/Makefile
index 539ffb77f5..f32db35d58 100644
--- a/src/gallium/drivers/softpipe/Makefile
+++ b/src/gallium/drivers/softpipe/Makefile
@@ -27,6 +27,7 @@ C_SOURCES = \
sp_quad_output.c \
sp_quad_stencil.c \
sp_quad_stipple.c \
+ sp_screen.c \
sp_state_blend.c \
sp_state_clip.c \
sp_state_derived.c \
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index 2cdf3c75bf..fa16ed94e8 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -48,29 +48,6 @@
/**
- * Query format support for creating a texture, drawing surface, etc.
- * \param format the format to test
- * \param type one of PIPE_TEXTURE, PIPE_SURFACE
- */
-static boolean
-softpipe_is_format_supported( struct pipe_context *pipe,
- enum pipe_format format, uint type )
-{
- switch (type) {
- case PIPE_TEXTURE:
- /* softpipe supports all texture formats */
- return TRUE;
- case PIPE_SURFACE:
- /* softpipe supports all (off-screen) surface formats */
- return TRUE;
- default:
- assert(0);
- return FALSE;
- }
-}
-
-
-/**
* Map any drawing surfaces which aren't already mapped
*/
void
@@ -143,76 +120,10 @@ static void softpipe_destroy( struct pipe_context *pipe )
}
-static const char *softpipe_get_name( struct pipe_context *pipe )
-{
- return "softpipe";
-}
-
-static const char *softpipe_get_vendor( struct pipe_context *pipe )
-{
- return "Tungsten Graphics, Inc.";
-}
-
-static int softpipe_get_param(struct pipe_context *pipe, int param)
-{
- 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 softpipe_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;
- }
-}
-
-struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
- struct softpipe_winsys *softpipe_winsys )
+struct pipe_context *
+softpipe_create( struct pipe_screen *screen,
+ struct pipe_winsys *pipe_winsys,
+ struct softpipe_winsys *softpipe_winsys )
{
struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
uint i;
@@ -226,15 +137,9 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
softpipe->dump_fs = GETENV( "GALLIUM_DUMP_FS" ) != NULL;
softpipe->pipe.winsys = pipe_winsys;
+ softpipe->pipe.screen = screen;
softpipe->pipe.destroy = softpipe_destroy;
- /* queries */
- softpipe->pipe.is_format_supported = softpipe_is_format_supported;
- softpipe->pipe.get_name = softpipe_get_name;
- softpipe->pipe.get_vendor = softpipe_get_vendor;
- softpipe->pipe.get_param = softpipe_get_param;
- softpipe->pipe.get_paramf = softpipe_get_paramf;
-
/* state setters */
softpipe->pipe.create_blend_state = softpipe_create_blend_state;
softpipe->pipe.bind_blend_state = softpipe_bind_blend_state;
@@ -279,12 +184,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
softpipe->pipe.flush = softpipe_flush;
softpipe_init_query_funcs( softpipe );
-
- /* textures */
- softpipe->pipe.texture_create = softpipe_texture_create;
- softpipe->pipe.texture_release = softpipe_texture_release;
- softpipe->pipe.texture_update = softpipe_texture_update;
- softpipe->pipe.get_tex_surface = softpipe_get_tex_surface;
+ softpipe_init_texture_funcs( softpipe );
/*
* Alloc caches for accessing drawing surfaces and textures.
@@ -337,9 +237,6 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
draw_install_pstipple_stage(softpipe->draw, &softpipe->pipe);
#endif
- /* sp_prim_setup can do wide points (don't convert to quads) */
- draw_convert_wide_points(softpipe->draw, FALSE);
-
sp_init_surface_functions(softpipe);
return &softpipe->pipe;
diff --git a/src/gallium/drivers/softpipe/sp_fs_llvm.c b/src/gallium/drivers/softpipe/sp_fs_llvm.c
index 34b2b7d4e2..07d058155f 100644
--- a/src/gallium/drivers/softpipe/sp_fs_llvm.c
+++ b/src/gallium/drivers/softpipe/sp_fs_llvm.c
@@ -96,7 +96,7 @@ shade_quad_llvm(struct quad_stage *qs,
if (qss->colorOutSlot >= 0) {
unsigned i;
/* XXX need to handle multiple color outputs someday */
- allvmrt(qss->stage.softpipe->fs->shader.output_semantic_name[qss->colorOutSlot]
+ allvmrt(qss->stage.softpipe->fs->info.output_semantic_name[qss->colorOutSlot]
== TGSI_SEMANTIC_COLOR);
for (i = 0; i < QUAD_SIZE; ++i) {
quad->outputs.color[0][i] = dests[i][qss->colorOutSlot][0];
diff --git a/src/gallium/drivers/softpipe/sp_prim_setup.c b/src/gallium/drivers/softpipe/sp_prim_setup.c
index b6a3fddb29..2feee5c485 100644
--- a/src/gallium/drivers/softpipe/sp_prim_setup.c
+++ b/src/gallium/drivers/softpipe/sp_prim_setup.c
@@ -514,7 +514,7 @@ setup_fragcoord_coeff(struct setup_stage *setup, uint slot)
static void setup_tri_coefficients( struct setup_stage *setup )
{
struct softpipe_context *softpipe = setup->softpipe;
- const struct pipe_shader_state *fs = &softpipe->fs->shader;
+ const struct sp_fragment_shader *spfs = softpipe->fs;
const struct vertex_info *vinfo = softpipe_get_vertex_info(softpipe);
uint fragSlot;
@@ -525,7 +525,7 @@ static void setup_tri_coefficients( struct setup_stage *setup )
/* setup interpolation for all the remaining attributes:
*/
- for (fragSlot = 0; fragSlot < fs->num_inputs; fragSlot++) {
+ for (fragSlot = 0; fragSlot < spfs->info.num_inputs; fragSlot++) {
const uint vertSlot = vinfo->src_index[fragSlot];
uint j;
@@ -549,7 +549,7 @@ static void setup_tri_coefficients( struct setup_stage *setup )
assert(0);
}
- if (fs->input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
+ if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
/* FOG.y = front/back facing XXX fix this */
setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.facing;
setup->coef[fragSlot].dadx[1] = 0.0;
@@ -757,7 +757,7 @@ static INLINE void
setup_line_coefficients(struct setup_stage *setup, struct prim_header *prim)
{
struct softpipe_context *softpipe = setup->softpipe;
- const struct pipe_shader_state *fs = &setup->softpipe->fs->shader;
+ const struct sp_fragment_shader *spfs = softpipe->fs;
const struct vertex_info *vinfo = softpipe_get_vertex_info(softpipe);
uint fragSlot;
@@ -779,7 +779,7 @@ setup_line_coefficients(struct setup_stage *setup, struct prim_header *prim)
/* setup interpolation for all the remaining attributes:
*/
- for (fragSlot = 0; fragSlot < fs->num_inputs; fragSlot++) {
+ for (fragSlot = 0; fragSlot < spfs->info.num_inputs; fragSlot++) {
const uint vertSlot = vinfo->src_index[fragSlot];
uint j;
@@ -803,7 +803,7 @@ setup_line_coefficients(struct setup_stage *setup, struct prim_header *prim)
assert(0);
}
- if (fs->input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
+ if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
/* FOG.y = front/back facing XXX fix this */
setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.facing;
setup->coef[fragSlot].dadx[1] = 0.0;
@@ -967,7 +967,7 @@ setup_point(struct draw_stage *stage, struct prim_header *prim)
{
struct setup_stage *setup = setup_stage( stage );
struct softpipe_context *softpipe = setup->softpipe;
- const struct pipe_shader_state *fs = &softpipe->fs->shader;
+ const struct sp_fragment_shader *spfs = softpipe->fs;
const struct vertex_header *v0 = prim->v[0];
const int sizeAttr = setup->softpipe->psize_slot;
const float size
@@ -1002,7 +1002,7 @@ setup_point(struct draw_stage *stage, struct prim_header *prim)
const_coeff(setup, &setup->posCoef, 0, 2);
const_coeff(setup, &setup->posCoef, 0, 3);
- for (fragSlot = 0; fragSlot < fs->num_inputs; fragSlot++) {
+ for (fragSlot = 0; fragSlot < spfs->info.num_inputs; fragSlot++) {
const uint vertSlot = vinfo->src_index[fragSlot];
uint j;
@@ -1025,7 +1025,7 @@ setup_point(struct draw_stage *stage, struct prim_header *prim)
assert(0);
}
- if (fs->input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
+ if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
/* FOG.y = front/back facing XXX fix this */
setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.facing;
setup->coef[fragSlot].dadx[1] = 0.0;
@@ -1163,13 +1163,13 @@ static void setup_begin( struct draw_stage *stage )
{
struct setup_stage *setup = setup_stage(stage);
struct softpipe_context *sp = setup->softpipe;
- const struct pipe_shader_state *fs = &setup->softpipe->fs->shader;
+ const struct sp_fragment_shader *fs = setup->softpipe->fs;
if (sp->dirty) {
softpipe_update_derived(sp);
}
- setup->quad.nr_attrs = fs->num_inputs;
+ setup->quad.nr_attrs = fs->info.num_inputs;
sp->quad.first->begin(sp->quad.first);
diff --git a/src/gallium/drivers/softpipe/sp_quad.c b/src/gallium/drivers/softpipe/sp_quad.c
index 142dbcc771..8603c1a367 100644
--- a/src/gallium/drivers/softpipe/sp_quad.c
+++ b/src/gallium/drivers/softpipe/sp_quad.c
@@ -60,8 +60,8 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
sp->depth_stencil->depth.enabled &&
sp->framebuffer.zsbuf &&
!sp->depth_stencil->alpha.enabled &&
- !sp->fs->uses_kill &&
- !sp->fs->writes_z;
+ !sp->fs->info.uses_kill &&
+ !sp->fs->info.writes_z;
/* build up the pipeline in reverse order... */
diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c
index 2f40e09d5c..1fbb2e38c4 100644
--- a/src/gallium/drivers/softpipe/sp_quad_fs.c
+++ b/src/gallium/drivers/softpipe/sp_quad_fs.c
@@ -91,7 +91,7 @@ shade_quad(
/* store result color */
if (qss->colorOutSlot >= 0) {
/* XXX need to handle multiple color outputs someday */
- assert(qss->stage.softpipe->fs->shader.output_semantic_name[qss->colorOutSlot]
+ assert(qss->stage.softpipe->fs->info.output_semantic_name[qss->colorOutSlot]
== TGSI_SEMANTIC_COLOR);
memcpy(
quad->outputs.color,
@@ -148,8 +148,8 @@ static void shade_begin(struct quad_stage *qs)
/* find output slots for depth, color */
qss->colorOutSlot = -1;
qss->depthOutSlot = -1;
- for (i = 0; i < qss->stage.softpipe->fs->shader.num_outputs; i++) {
- switch (qss->stage.softpipe->fs->shader.output_semantic_name[i]) {
+ for (i = 0; i < qss->stage.softpipe->fs->info.num_outputs; i++) {
+ switch (qss->stage.softpipe->fs->info.output_semantic_name[i]) {
case TGSI_SEMANTIC_POSITION:
qss->depthOutSlot = i;
break;
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
new file mode 100644
index 0000000000..1850a1ced3
--- /dev/null
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -0,0 +1,165 @@
+/**************************************************************************
+ *
+ * Copyright 2008 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 "pipe/p_winsys.h"
+#include "pipe/p_defines.h"
+#include "pipe/p_screen.h"
+
+#include "sp_texture.h"
+#include "sp_winsys.h"
+
+
+static const char *
+softpipe_get_vendor(struct pipe_screen *screen)
+{
+ return "Tungsten Graphics, Inc.";
+}
+
+
+static const char *
+softpipe_get_name(struct pipe_screen *screen)
+{
+ return "softpipe";
+}
+
+
+static int
+softpipe_get_param(struct pipe_screen *screen, int param)
+{
+ 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
+softpipe_get_paramf(struct pipe_screen *screen, 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;
+ }
+}
+
+
+/**
+ * Query format support for creating a texture, drawing surface, etc.
+ * \param format the format to test
+ * \param type one of PIPE_TEXTURE, PIPE_SURFACE
+ */
+static boolean
+softpipe_is_format_supported( struct pipe_screen *screen,
+ enum pipe_format format, uint type )
+{
+ switch (type) {
+ case PIPE_TEXTURE:
+ /* softpipe supports all texture formats */
+ return TRUE;
+ case PIPE_SURFACE:
+ /* softpipe supports all (off-screen) surface formats */
+ return TRUE;
+ default:
+ assert(0);
+ return FALSE;
+ }
+}
+
+
+static void
+softpipe_destroy_screen( struct pipe_screen *screen )
+{
+ FREE(screen);
+}
+
+
+/**
+ * Create a new pipe_screen object
+ * Note: we're not presently subclassing pipe_screen (no softpipe_screen).
+ */
+struct pipe_screen *
+softpipe_create_screen(struct pipe_winsys *winsys)
+{
+ struct pipe_screen *screen = CALLOC_STRUCT(pipe_screen);
+
+ if (!screen)
+ return NULL;
+
+ screen->winsys = winsys;
+
+ screen->destroy = softpipe_destroy_screen;
+
+ screen->get_name = softpipe_get_name;
+ screen->get_vendor = softpipe_get_vendor;
+ screen->get_param = softpipe_get_param;
+ screen->get_paramf = softpipe_get_paramf;
+ screen->is_format_supported = softpipe_is_format_supported;
+
+ softpipe_init_screen_texture_funcs(screen);
+
+ return screen;
+}
diff --git a/src/gallium/drivers/softpipe/sp_state.h b/src/gallium/drivers/softpipe/sp_state.h
index 5aaa9e346b..3943d4ed2b 100644
--- a/src/gallium/drivers/softpipe/sp_state.h
+++ b/src/gallium/drivers/softpipe/sp_state.h
@@ -32,6 +32,7 @@
#define SP_STATE_H
#include "pipe/p_state.h"
+#include "tgsi/util/tgsi_scan.h"
#define SP_NEW_VIEWPORT 0x1
@@ -52,7 +53,6 @@
struct tgsi_sampler;
-struct tgsi_interp_coef;
struct tgsi_exec_machine;
@@ -61,10 +61,9 @@ struct tgsi_exec_machine;
* This is starting to look an awful lot like a quad pipeline stage...
*/
struct sp_fragment_shader {
- struct pipe_shader_state shader;
+ struct pipe_shader_state shader;
- boolean uses_kill;
- boolean writes_z;
+ struct tgsi_shader_info info;
void (*prepare)( const struct sp_fragment_shader *shader,
struct tgsi_exec_machine *machine,
diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c
index 4c6313001f..eafbaed4b9 100644
--- a/src/gallium/drivers/softpipe/sp_state_derived.c
+++ b/src/gallium/drivers/softpipe/sp_state_derived.c
@@ -61,8 +61,7 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
if (vinfo->num_attribs == 0) {
/* compute vertex layout now */
- const struct pipe_shader_state *vs = &softpipe->vs->shader;
- const struct pipe_shader_state *fs = &softpipe->fs->shader;
+ const struct sp_fragment_shader *spfs = softpipe->fs;
const enum interp_mode colorInterp
= softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
uint i;
@@ -74,7 +73,8 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
struct vertex_info *vinfo_vbuf = &softpipe->vertex_info_vbuf;
vinfo_vbuf->num_attribs = 0;
draw_emit_vertex_attr(vinfo_vbuf, EMIT_ALL, INTERP_NONE, 0);
- vinfo_vbuf->size = 4 * vs->num_outputs
+ /* size in dwords or floats */
+ vinfo_vbuf->size = 4 * draw_num_vs_outputs(softpipe->draw)
+ sizeof(struct vertex_header) / 4;
}
@@ -83,9 +83,9 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
* from the vertex shader.
*/
vinfo->num_attribs = 0;
- for (i = 0; i < fs->num_inputs; i++) {
+ for (i = 0; i < spfs->info.num_inputs; i++) {
int src;
- switch (fs->input_semantic_name[i]) {
+ switch (spfs->info.input_semantic_name[i]) {
case TGSI_SEMANTIC_POSITION:
src = draw_find_vs_output(softpipe->draw,
TGSI_SEMANTIC_POSITION, 0);
@@ -94,7 +94,7 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
case TGSI_SEMANTIC_COLOR:
src = draw_find_vs_output(softpipe->draw, TGSI_SEMANTIC_COLOR,
- fs->input_semantic_index[i]);
+ spfs->info.input_semantic_index[i]);
draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
break;
@@ -106,7 +106,7 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
case TGSI_SEMANTIC_GENERIC:
/* this includes texcoords and varying vars */
src = draw_find_vs_output(softpipe->draw, TGSI_SEMANTIC_GENERIC,
- fs->input_semantic_index[i]);
+ spfs->info.input_semantic_index[i]);
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
break;
diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c
index b184ac61bb..eb641ed321 100644
--- a/src/gallium/drivers/softpipe/sp_state_fs.c
+++ b/src/gallium/drivers/softpipe/sp_state_fs.c
@@ -45,13 +45,12 @@ softpipe_create_fs_state(struct pipe_context *pipe,
{
struct softpipe_context *softpipe = softpipe_context(pipe);
struct sp_fragment_shader *state;
- struct tgsi_shader_info info;
-
- tgsi_scan_shader(templ->tokens, &info);
+ /* debug */
if (softpipe->dump_fs)
tgsi_dump(templ->tokens, 0);
+ /* codegen */
state = softpipe_create_fs_llvm( softpipe, templ );
if (!state) {
state = softpipe_create_fs_sse( softpipe, templ );
@@ -59,10 +58,12 @@ softpipe_create_fs_state(struct pipe_context *pipe,
state = softpipe_create_fs_exec( softpipe, templ );
}
}
+
assert(state);
- state->uses_kill = (info.opcode_count[TGSI_OPCODE_KIL] ||
- info.opcode_count[TGSI_OPCODE_KILP]);
- state->writes_z = info.writes_z;
+
+ /* get/save the summary info for this shader */
+ tgsi_scan_shader(templ->tokens, &state->info);
+
return state;
}
diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c
index 18669a1c6e..1d6dd17d1d 100644
--- a/src/gallium/drivers/softpipe/sp_state_sampler.c
+++ b/src/gallium/drivers/softpipe/sp_state_sampler.c
@@ -83,7 +83,7 @@ softpipe_set_sampler_texture(struct pipe_context *pipe,
draw_flush(softpipe->draw);
assert(unit < PIPE_MAX_SAMPLERS);
- pipe_texture_reference(pipe, &softpipe->texture[unit], texture);
+ pipe_texture_reference(&softpipe->texture[unit], texture);
sp_tile_cache_set_texture(pipe, softpipe->tex_cache[unit], texture);
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index 6ba0f09e0a..c605ed925b 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -80,22 +80,24 @@ softpipe_texture_layout(struct softpipe_texture * spt)
}
-struct pipe_texture *
-softpipe_texture_create(struct pipe_context *pipe,
- const struct pipe_texture *templat)
+static struct pipe_texture *
+softpipe_texture_create_screen(struct pipe_screen *screen,
+ const struct pipe_texture *templat)
{
+ struct pipe_winsys *ws = screen->winsys;
struct softpipe_texture *spt = CALLOC_STRUCT(softpipe_texture);
if (!spt)
return NULL;
spt->base = *templat;
spt->base.refcount = 1;
+ spt->base.screen = screen;
softpipe_texture_layout(spt);
- spt->buffer = pipe->winsys->buffer_create(pipe->winsys, 32,
- PIPE_BUFFER_USAGE_PIXEL,
- spt->buffer_size);
+ spt->buffer = ws->buffer_create(ws, 32,
+ PIPE_BUFFER_USAGE_PIXEL,
+ spt->buffer_size);
if (!spt->buffer) {
FREE(spt);
return NULL;
@@ -107,8 +109,9 @@ softpipe_texture_create(struct pipe_context *pipe,
}
-void
-softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
+static void
+softpipe_texture_release_screen(struct pipe_screen *screen,
+ struct pipe_texture **pt)
{
if (!*pt)
return;
@@ -124,7 +127,7 @@ softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
DBG("%s deleting %p\n", __FUNCTION__, (void *) spt);
*/
- pipe_buffer_reference(pipe->winsys, &spt->buffer, NULL);
+ pipe_buffer_reference(screen->winsys, &spt->buffer, NULL);
FREE(spt);
}
@@ -132,38 +135,22 @@ softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
}
-void
-softpipe_texture_update(struct pipe_context *pipe,
- struct pipe_texture *texture)
-{
- struct softpipe_context *softpipe = softpipe_context(pipe);
- uint unit;
- for (unit = 0; unit < PIPE_MAX_SAMPLERS; unit++) {
- if (softpipe->texture[unit] == texture) {
- sp_flush_tile_cache(softpipe, softpipe->tex_cache[unit]);
- }
- }
-}
-
-
-/**
- * Called via pipe->get_tex_surface()
- */
-struct pipe_surface *
-softpipe_get_tex_surface(struct pipe_context *pipe,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice)
+static struct pipe_surface *
+softpipe_get_tex_surface_screen(struct pipe_screen *screen,
+ struct pipe_texture *pt,
+ unsigned face, unsigned level, unsigned zslice)
{
+ struct pipe_winsys *ws = screen->winsys;
struct softpipe_texture *spt = softpipe_texture(pt);
struct pipe_surface *ps;
assert(level <= pt->last_level);
- ps = pipe->winsys->surface_alloc(pipe->winsys);
+ ps = ws->surface_alloc(ws);
if (ps) {
assert(ps->refcount);
assert(ps->winsys);
- pipe_buffer_reference(pipe->winsys, &ps->buffer, spt->buffer);
+ pipe_buffer_reference(ws, &ps->buffer, spt->buffer);
ps->format = pt->format;
ps->cpp = pt->cpp;
ps->width = pt->width[level];
@@ -175,10 +162,41 @@ softpipe_get_tex_surface(struct pipe_context *pipe,
ps->offset += ((pt->target == PIPE_TEXTURE_CUBE) ? face : zslice) *
(pt->compressed ? ps->height/4 : ps->height) *
ps->width * ps->cpp;
- } else {
+ }
+ else {
assert(face == 0);
assert(zslice == 0);
}
}
return ps;
}
+
+
+static void
+softpipe_texture_update(struct pipe_context *pipe,
+ struct pipe_texture *texture)
+{
+ struct softpipe_context *softpipe = softpipe_context(pipe);
+ uint unit;
+ for (unit = 0; unit < PIPE_MAX_SAMPLERS; unit++) {
+ if (softpipe->texture[unit] == texture) {
+ sp_flush_tile_cache(softpipe, softpipe->tex_cache[unit]);
+ }
+ }
+}
+
+
+void
+softpipe_init_texture_funcs( struct softpipe_context *softpipe )
+{
+ softpipe->pipe.texture_update = softpipe_texture_update;
+}
+
+
+void
+softpipe_init_screen_texture_funcs(struct pipe_screen *screen)
+{
+ screen->texture_create = softpipe_texture_create_screen;
+ screen->texture_release = softpipe_texture_release_screen;
+ screen->get_tex_surface = softpipe_get_tex_surface_screen;
+}
diff --git a/src/gallium/drivers/softpipe/sp_texture.h b/src/gallium/drivers/softpipe/sp_texture.h
index 50fc100427..a7322144e6 100644
--- a/src/gallium/drivers/softpipe/sp_texture.h
+++ b/src/gallium/drivers/softpipe/sp_texture.h
@@ -29,8 +29,12 @@
#define SP_TEXTURE_H
+#include "pipe/p_state.h"
+
+
struct pipe_context;
-struct pipe_texture;
+struct pipe_screen;
+struct softpipe_context;
struct softpipe_texture
@@ -54,22 +58,12 @@ softpipe_texture(struct pipe_texture *pt)
}
-
-extern struct pipe_texture *
-softpipe_texture_create(struct pipe_context *pipe,
- const struct pipe_texture *templat);
-
extern void
-softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
+softpipe_init_texture_funcs( struct softpipe_context *softpipe );
-extern void
-softpipe_texture_update(struct pipe_context *pipe,
- struct pipe_texture *texture);
-extern struct pipe_surface *
-softpipe_get_tex_surface(struct pipe_context *pipe,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice);
+extern void
+softpipe_init_screen_texture_funcs(struct pipe_screen *screen);
#endif /* SP_TEXTURE */
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c
index da30dd6c48..4caf2dd3fc 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
@@ -220,7 +220,7 @@ sp_tile_cache_set_texture(struct pipe_context *pipe,
assert(!tc->surface);
- pipe_texture_reference(pipe, &tc->texture, texture);
+ pipe_texture_reference(&tc->texture, texture);
if (tc->tex_surf_map) {
pipe_surface_unmap(tc->tex_surf);
@@ -489,6 +489,7 @@ sp_get_cached_tile_tex(struct pipe_context *pipe,
struct softpipe_tile_cache *tc, int x, int y, int z,
int face, int level)
{
+ struct pipe_screen *screen = pipe->screen;
/* tile pos in framebuffer: */
const int tile_x = x & ~(TILE_SIZE - 1);
const int tile_y = y & ~(TILE_SIZE - 1);
@@ -514,7 +515,7 @@ sp_get_cached_tile_tex(struct pipe_context *pipe,
if (tc->tex_surf_map)
pipe_surface_unmap(tc->tex_surf);
- tc->tex_surf = pipe->get_tex_surface(pipe, tc->texture, face, level, z);
+ tc->tex_surf = screen->get_tex_surface(screen, tc->texture, face, level, z);
tc->tex_surf_map = pipe_surface_map(tc->tex_surf);
tc->tex_face = face;
diff --git a/src/gallium/drivers/softpipe/sp_winsys.h b/src/gallium/drivers/softpipe/sp_winsys.h
index d6b379f58c..fc372dba27 100644
--- a/src/gallium/drivers/softpipe/sp_winsys.h
+++ b/src/gallium/drivers/softpipe/sp_winsys.h
@@ -46,12 +46,18 @@ struct softpipe_winsys {
};
+struct pipe_screen;
struct pipe_winsys;
struct pipe_context;
-struct pipe_context *softpipe_create( struct pipe_winsys *,
+struct pipe_context *softpipe_create( struct pipe_screen *,
+ struct pipe_winsys *,
struct softpipe_winsys * );
+struct pipe_screen *
+softpipe_create_screen(struct pipe_winsys *);
+
+
#endif /* SP_WINSYS_H */
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index f69b52f5e3..d0f25d7d46 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -36,6 +36,8 @@ extern "C" {
#endif
+struct pipe_screen;
+
struct pipe_state_cache;
/* Opaque driver handles:
@@ -51,27 +53,13 @@ struct pipe_query;
*/
struct pipe_context {
struct pipe_winsys *winsys;
+ struct pipe_screen *screen;
void *priv; /** context private data (for DRI for example) */
void (*destroy)( struct pipe_context * );
/*
- * Queries
- */
- /** type is one of PIPE_SURFACE, PIPE_TEXTURE, etc. */
- boolean (*is_format_supported)( struct pipe_context *pipe,
- enum pipe_format format, uint type );
-
- const char *(*get_name)( struct pipe_context *pipe );
-
- const char *(*get_vendor)( struct pipe_context *pipe );
-
- int (*get_param)( struct pipe_context *pipe, int param );
- float (*get_paramf)( struct pipe_context *pipe, int param );
-
-
- /*
* Drawing.
* Return false on fallbacks (temporary??)
*/
@@ -201,29 +189,16 @@ struct pipe_context {
struct pipe_surface *ps,
unsigned clearValue);
-
- /*
- * Texture functions
- */
- struct pipe_texture * (*texture_create)(struct pipe_context *pipe,
- const struct pipe_texture *templat);
-
- void (*texture_release)(struct pipe_context *pipe,
- struct pipe_texture **pt);
-
/**
* Called when texture data is changed.
* Note: we could pass some hints about which mip levels or cube faces
* have changed...
+ * XXX this may go away - could pass a 'write' flag to get_tex_surface()
*/
void (*texture_update)(struct pipe_context *pipe,
struct pipe_texture *texture);
- /** Get a surface which is a "view" into a texture */
- struct pipe_surface *(*get_tex_surface)(struct pipe_context *pipe,
- struct pipe_texture *texture,
- unsigned face, unsigned level,
- unsigned zslice);
+
/* Flush rendering:
*/
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index d84ddbc27a..0c662d6517 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -152,7 +152,7 @@ enum pipe_texture_target {
*/
#define PIPE_TEX_FILTER_NEAREST 0
#define PIPE_TEX_FILTER_LINEAR 1
-//#define PIPE_TEX_FILTER_ANISO 2
+/* #define PIPE_TEX_FILTER_ANISO 2 */
#define PIPE_TEX_COMPARE_NONE 0
diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h
index 561d2e5921..f90087b3c9 100644
--- a/src/gallium/include/pipe/p_format.h
+++ b/src/gallium/include/pipe/p_format.h
@@ -28,7 +28,7 @@
#ifndef PIPE_FORMAT_H
#define PIPE_FORMAT_H
-#include <stdio.h> // for sprintf
+#include <stdio.h> /* for sprintf */
#include "p_compiler.h"
#include "p_debug.h"
diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/include/pipe/p_inlines.h
index de3fa555c5..274f76a383 100644
--- a/src/gallium/include/pipe/p_inlines.h
+++ b/src/gallium/include/pipe/p_inlines.h
@@ -30,6 +30,7 @@
#include "p_context.h"
#include "p_defines.h"
+#include "p_screen.h"
#include "p_winsys.h"
@@ -97,7 +98,7 @@ pipe_buffer_reference(struct pipe_winsys *winsys,
* \sa pipe_surface_reference
*/
static INLINE void
-pipe_texture_reference(struct pipe_context *pipe, struct pipe_texture **ptr,
+pipe_texture_reference(struct pipe_texture **ptr,
struct pipe_texture *pt)
{
assert(ptr);
@@ -106,7 +107,10 @@ pipe_texture_reference(struct pipe_context *pipe, struct pipe_texture **ptr,
pt->refcount++;
if (*ptr) {
- pipe->texture_release(pipe, ptr);
+ struct pipe_screen *screen = (*ptr)->screen;
+ assert(screen);
+ screen->texture_release(screen, ptr);
+
assert(!*ptr);
}
@@ -114,6 +118,17 @@ pipe_texture_reference(struct pipe_context *pipe, struct pipe_texture **ptr,
}
+static INLINE void
+pipe_texture_release(struct pipe_texture **ptr)
+{
+ struct pipe_screen *screen;
+ assert(ptr);
+ screen = (*ptr)->screen;
+ screen->texture_release(screen, ptr);
+ *ptr = NULL;
+}
+
+
#ifdef __cplusplus
}
#endif
diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
new file mode 100644
index 0000000000..6be9a82b68
--- /dev/null
+++ b/src/gallium/include/pipe/p_screen.h
@@ -0,0 +1,98 @@
+/**************************************************************************
+ *
+ * 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.
+ *
+ **************************************************************************/
+
+/**
+ * Screen, Adapter or GPU
+ *
+ * These are driver functions/facilities that are context independent.
+ */
+
+
+#ifndef P_SCREEN_H
+#define P_SCREEN_H
+
+
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+/**
+ * Gallium screen/adapter context. Basically everything
+ * hardware-specific that doesn't actually require a rendering
+ * context.
+ */
+struct pipe_screen {
+ struct pipe_winsys *winsys;
+
+ void (*destroy)( struct pipe_screen * );
+
+
+ /*
+ * Capability queries
+ */
+ const char *(*get_name)( struct pipe_screen * );
+
+ const char *(*get_vendor)( struct pipe_screen * );
+
+ int (*get_param)( struct pipe_screen *, int param );
+
+ float (*get_paramf)( struct pipe_screen *, int param );
+
+ boolean (*is_format_supported)( struct pipe_screen *,
+ enum pipe_format format,
+ uint type );
+
+
+ /*
+ * Texture functions
+ */
+ struct pipe_texture * (*texture_create)(struct pipe_screen *,
+ const struct pipe_texture *templat);
+
+ void (*texture_release)(struct pipe_screen *,
+ struct pipe_texture **pt);
+
+ /** Get a surface which is a "view" into a texture */
+ struct pipe_surface *(*get_tex_surface)(struct pipe_screen *,
+ struct pipe_texture *texture,
+ unsigned face, unsigned level,
+ unsigned zslice);
+};
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* P_SCREEN_H */
diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h
index 1806877f6c..0a6145a6bf 100644
--- a/src/gallium/include/pipe/p_shader_tokens.h
+++ b/src/gallium/include/pipe/p_shader_tokens.h
@@ -1,9 +1,9 @@
#if !defined TGSI_TOKEN_H
#define TGSI_TOKEN_H
-#if defined __cplusplus
+#ifdef __cplusplus
extern "C" {
-#endif // defined __cplusplus
+#endif
#include "p_compiler.h"
@@ -802,9 +802,9 @@ struct tgsi_dst_register_ext_predicate
};
-#if defined __cplusplus
-} // extern "C"
-#endif // defined __cplusplus
+#ifdef __cplusplus
+}
+#endif
-#endif // !defined TGSI_TOKEN_H
+#endif /* TGSI_TOKEN_H */
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 15c88881eb..5fab41acbd 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -63,6 +63,7 @@ extern "C" {
/* fwd decls */
+struct pipe_screen;
struct pipe_surface;
struct pipe_winsys;
@@ -160,9 +161,9 @@ struct pipe_constant_buffer
struct pipe_shader_state
{
const struct tgsi_token *tokens;
+ /* XXX these are going away */
ubyte num_inputs;
ubyte num_outputs;
- ubyte input_map[PIPE_MAX_SHADER_INPUTS]; /* XXX this may be temporary */
ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; /**< TGSI_SEMANTIC_x */
ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS];
ubyte output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; /**< TGSI_SEMANTIC_x */
@@ -276,8 +277,7 @@ struct pipe_surface
/**
- * Texture. Represents one or several texture images on one or several mipmap
- * levels.
+ * Texture object.
*/
struct pipe_texture
{
@@ -297,6 +297,8 @@ struct pipe_texture
/* These are also refcounted:
*/
unsigned refcount;
+
+ struct pipe_screen *screen; /**< screen that this texture belongs to */
};
diff --git a/src/gallium/winsys/dri/intel/intel_context.h b/src/gallium/winsys/dri/intel/intel_context.h
index b01370c049..45430984d8 100644
--- a/src/gallium/winsys/dri/intel/intel_context.h
+++ b/src/gallium/winsys/dri/intel/intel_context.h
@@ -30,6 +30,9 @@
#include "drm.h"
+
+#include "pipe/p_debug.h"
+
#include "intel_screen.h"
#include "i915_drm.h"
diff --git a/src/gallium/winsys/dri/intel/intel_winsys_i915.c b/src/gallium/winsys/dri/intel/intel_winsys_i915.c
index 0ed3890e93..2def1afc31 100644
--- a/src/gallium/winsys/dri/intel/intel_winsys_i915.c
+++ b/src/gallium/winsys/dri/intel/intel_winsys_i915.c
@@ -40,6 +40,7 @@
#include "pipe/p_util.h"
#include "i915simple/i915_winsys.h"
+#include "i915simple/i915_screen.h"
struct intel_i915_winsys {
@@ -135,6 +136,7 @@ intel_create_i915simple( struct intel_context *intel,
struct pipe_winsys *winsys )
{
struct intel_i915_winsys *iws = CALLOC_STRUCT( intel_i915_winsys );
+ struct pipe_screen *screen;
/* Fill in this struct with callbacks that i915simple will need to
* communicate with the window system, buffer manager, etc.
@@ -146,9 +148,11 @@ intel_create_i915simple( struct intel_context *intel,
iws->winsys.batch_finish = intel_i915_batch_finish;
iws->intel = intel;
+ screen = i915_create_screen(winsys, intel->intelScreen->deviceID);
+
/* Create the i915simple context:
*/
- return i915_create( winsys,
- &iws->winsys,
- intel->intelScreen->deviceID );
+ return i915_create_context( screen,
+ winsys,
+ &iws->winsys );
}
diff --git a/src/gallium/winsys/dri/intel/intel_winsys_softpipe.c b/src/gallium/winsys/dri/intel/intel_winsys_softpipe.c
index 9e483bdc9f..0bc2dc4002 100644
--- a/src/gallium/winsys/dri/intel/intel_winsys_softpipe.c
+++ b/src/gallium/winsys/dri/intel/intel_winsys_softpipe.c
@@ -68,6 +68,7 @@ intel_create_softpipe( struct intel_context *intel,
struct pipe_winsys *winsys )
{
struct intel_softpipe_winsys *isws = CALLOC_STRUCT( intel_softpipe_winsys );
+ struct pipe_screen *screen = softpipe_create_screen(winsys);
/* Fill in this struct with callbacks that softpipe will need to
* communicate with the window system, buffer manager, etc.
@@ -77,5 +78,5 @@ intel_create_softpipe( struct intel_context *intel,
/* Create the softpipe context:
*/
- return softpipe_create( winsys, &isws->sws );
+ return softpipe_create( screen, winsys, &isws->sws );
}
diff --git a/src/gallium/winsys/xlib/xm_winsys.c b/src/gallium/winsys/xlib/xm_winsys.c
index 8da596d419..018cf01cd6 100644
--- a/src/gallium/winsys/xlib/xm_winsys.c
+++ b/src/gallium/winsys/xlib/xm_winsys.c
@@ -36,6 +36,8 @@
#include "glxheader.h"
#include "xmesaP.h"
+#undef ASSERT
+
#include "pipe/p_winsys.h"
#include "pipe/p_format.h"
#include "pipe/p_context.h"
@@ -45,6 +47,7 @@
#ifdef GALLIUM_CELL
#include "cell/ppu/cell_context.h"
+#include "cell/ppu/cell_screen.h"
#include "cell/ppu/cell_winsys.h"
#else
#define TILE_SIZE 32 /* avoid compilation errors */
@@ -448,7 +451,8 @@ xmesa_create_pipe_context(XMesaContext xmesa, uint pixelformat)
#ifdef GALLIUM_CELL
if (!getenv("GALLIUM_NOCELL")) {
struct cell_winsys *cws = cell_get_winsys(pixelformat);
- pipe = cell_create_context(pws, cws);
+ struct pipe_screen *screen = cell_create_screen(pws);
+ pipe = cell_create_context(screen, cws);
if (pipe)
pipe->priv = xmesa;
return pipe;
@@ -457,7 +461,8 @@ xmesa_create_pipe_context(XMesaContext xmesa, uint pixelformat)
#endif
{
struct softpipe_winsys *spws = xmesa_get_softpipe_winsys(pixelformat);
- pipe = softpipe_create( pws, spws );
+ struct pipe_screen *screen = softpipe_create_screen(pws);
+ pipe = softpipe_create( screen, pws, spws );
if (pipe)
pipe->priv = xmesa;
diff --git a/src/gallium/winsys/xlib/xm_winsys_aub.c b/src/gallium/winsys/xlib/xm_winsys_aub.c
index dbfd37bda2..d55d8c39eb 100644
--- a/src/gallium/winsys/xlib/xm_winsys_aub.c
+++ b/src/gallium/winsys/xlib/xm_winsys_aub.c
@@ -40,6 +40,7 @@
#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "i965simple/brw_winsys.h"
+#include "i965simple/brw_screen.h"
#include "brw_aub.h"
#include "xm_winsys_aub.h"
@@ -565,6 +566,7 @@ struct pipe_context *
xmesa_create_i965simple( struct pipe_winsys *winsys )
{
struct aub_brw_winsys *iws = CALLOC_STRUCT( aub_brw_winsys );
+ struct pipe_screen *screen = brw_create_screen(winsys, 0/* XXX pci_id */);
/* Fill in this struct with callbacks that i965simple will need to
* communicate with the window system, buffer manager, etc.
@@ -583,7 +585,7 @@ xmesa_create_i965simple( struct pipe_winsys *winsys )
/* Create the i965simple context:
*/
- return brw_create( winsys,
+ return brw_create( screen,
&iws->winsys,
0 );
}