summaryrefslogtreecommitdiff
path: root/src/gallium/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/Makefile7
-rw-r--r--src/gallium/drivers/cell/common.h36
-rw-r--r--src/gallium/drivers/cell/ppu/Makefile20
-rw-r--r--src/gallium/drivers/cell/ppu/cell_clear.c1
-rw-r--r--src/gallium/drivers/cell/ppu/cell_context.c45
-rw-r--r--src/gallium/drivers/cell/ppu/cell_context.h2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_draw_arrays.c6
-rw-r--r--src/gallium/drivers/cell/ppu/cell_flush.c14
-rw-r--r--src/gallium/drivers/cell/ppu/cell_pipe_state.c326
-rw-r--r--src/gallium/drivers/cell/ppu/cell_pipe_state.h (renamed from src/gallium/drivers/cell/ppu/cell_state_surface.c)48
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state.h111
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_blend.c109
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_clip.c84
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_emit.c18
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_rasterizer.c106
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_sampler.c84
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_shader.c (renamed from src/gallium/drivers/cell/ppu/cell_state_fs.c)31
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.c28
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.h17
-rw-r--r--src/gallium/drivers/cell/ppu/cell_vertex_fetch.c2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_vertex_shader.c18
-rw-r--r--src/gallium/drivers/cell/spu/Makefile1
-rw-r--r--src/gallium/drivers/cell/spu/spu_dcache.c111
-rw-r--r--src/gallium/drivers/cell/spu/spu_dcache.h34
-rw-r--r--src/gallium/drivers/cell/spu/spu_exec.c56
-rw-r--r--src/gallium/drivers/cell/spu/spu_main.c17
-rw-r--r--src/gallium/drivers/cell/spu/spu_vertex_fetch.c74
-rw-r--r--src/gallium/drivers/cell/spu/spu_vertex_shader.c68
-rw-r--r--src/gallium/drivers/cell/spu/spu_vertex_shader.h5
-rw-r--r--src/gallium/drivers/failover/Makefile9
-rw-r--r--src/gallium/drivers/failover/SConscript13
-rw-r--r--src/gallium/drivers/failover/fo_context.c9
-rw-r--r--src/gallium/drivers/i915simple/Makefile9
-rw-r--r--src/gallium/drivers/i915simple/i915_context.c3
-rw-r--r--src/gallium/drivers/i915simple/i915_debug.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_state.c5
-rw-r--r--src/gallium/drivers/i915simple/i915_state_immediate.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_state_inlines.h4
-rw-r--r--src/gallium/drivers/i915simple/i915_surface.c45
-rw-r--r--src/gallium/drivers/i915simple/i915_texture.c64
-rw-r--r--src/gallium/drivers/i915simple/i915_texture.h33
-rw-r--r--src/gallium/drivers/i965simple/Makefile25
-rw-r--r--src/gallium/drivers/i965simple/brw_context.c3
-rw-r--r--src/gallium/drivers/i965simple/brw_state.c5
-rw-r--r--src/gallium/drivers/i965simple/brw_surface.c43
-rw-r--r--src/gallium/drivers/i965simple/brw_tex_layout.c67
-rw-r--r--src/gallium/drivers/i965simple/brw_tex_layout.h9
-rw-r--r--src/gallium/drivers/softpipe/Makefile9
-rw-r--r--src/gallium/drivers/softpipe/sp_context.c13
-rw-r--r--src/gallium/drivers/softpipe/sp_context.h9
-rw-r--r--src/gallium/drivers/softpipe/sp_fs_exec.c35
-rw-r--r--src/gallium/drivers/softpipe/sp_fs_sse.c40
-rw-r--r--src/gallium/drivers/softpipe/sp_prim_setup.c41
-rw-r--r--src/gallium/drivers/softpipe/sp_quad.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_fs.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_state_clip.c20
-rw-r--r--src/gallium/drivers/softpipe/sp_state_derived.c17
-rw-r--r--src/gallium/drivers/softpipe/sp_state_sampler.c5
-rw-r--r--src/gallium/drivers/softpipe/sp_state_surface.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.c168
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c18
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.h4
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.c50
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.h3
64 files changed, 1226 insertions, 1041 deletions
diff --git a/src/gallium/drivers/Makefile b/src/gallium/drivers/Makefile
index 58df6c5009..6161cb6ff8 100644
--- a/src/gallium/drivers/Makefile
+++ b/src/gallium/drivers/Makefile
@@ -2,12 +2,7 @@ TOP = ../../..
include $(TOP)/configs/current
-ifeq ($(CONFIG_NAME), linux-cell)
-CELL_DIR = cell
-endif
-
-SUBDIRS = softpipe i915simple i965simple nv30 nv40 nv50 \
- failover pipebuffer $(CELL_DIR)
+SUBDIRS = $(GALLIUM_DRIVER_DIRS)
default: subdirs
diff --git a/src/gallium/drivers/cell/common.h b/src/gallium/drivers/cell/common.h
index 74b131fbef..9a4004535e 100644
--- a/src/gallium/drivers/cell/common.h
+++ b/src/gallium/drivers/cell/common.h
@@ -87,10 +87,13 @@
#define CELL_CMD_STATE_TEXTURE 13
#define CELL_CMD_STATE_VERTEX_INFO 14
#define CELL_CMD_STATE_VIEWPORT 15
-#define CELL_CMD_STATE_VS_ARRAY_INFO 16
-#define CELL_CMD_STATE_BLEND 17
-#define CELL_CMD_VS_EXECUTE 18
-#define CELL_CMD_STATE_ATTRIB_FETCH 19
+#define CELL_CMD_STATE_UNIFORMS 16
+#define CELL_CMD_STATE_VS_ARRAY_INFO 17
+#define CELL_CMD_STATE_BIND_VS 18
+#define CELL_CMD_STATE_BLEND 19
+#define CELL_CMD_STATE_ATTRIB_FETCH 20
+#define CELL_CMD_VS_EXECUTE 21
+#define CELL_CMD_FLUSH_BUFFER_RANGE 22
#define CELL_NUM_BUFFERS 4
@@ -134,7 +137,7 @@ struct cell_array_info
uint pitch; /**< Byte pitch from one entry to the next. */
uint size;
uint function_offset;
-} ALIGN16_ATTRIB;
+};
struct cell_attribute_fetch_code {
@@ -142,32 +145,37 @@ struct cell_attribute_fetch_code {
uint size;
};
+
+struct cell_buffer_range {
+ uint64_t base;
+ unsigned size;
+};
+
+
struct cell_shader_info
{
- unsigned num_outputs;
-
uint64_t declarations;
- unsigned num_declarations;
uint64_t instructions;
- unsigned num_instructions;
- uint64_t uniforms;
uint64_t immediates;
+
+ unsigned num_outputs;
+ unsigned num_declarations;
+ unsigned num_instructions;
unsigned num_immediates;
-} ALIGN16_ATTRIB;
+};
#define SPU_VERTS_PER_BATCH 64
struct cell_command_vs
{
uint64_t opcode; /**< CELL_CMD_VS_EXECUTE */
- struct cell_shader_info shader;
+ uint64_t vOut[SPU_VERTS_PER_BATCH];
unsigned num_elts;
unsigned elts[SPU_VERTS_PER_BATCH];
- uint64_t vOut[SPU_VERTS_PER_BATCH];
float plane[12][4];
unsigned nr_planes;
unsigned nr_attrs;
-} ALIGN16_ATTRIB;
+};
struct cell_command_render
diff --git a/src/gallium/drivers/cell/ppu/Makefile b/src/gallium/drivers/cell/ppu/Makefile
index 196ab777f5..164dde762c 100644
--- a/src/gallium/drivers/cell/ppu/Makefile
+++ b/src/gallium/drivers/cell/ppu/Makefile
@@ -1,6 +1,6 @@
# Gallium3D Cell driver: PPU code
-# This makefile builds the g3dcell.a library which gets pulled into
+# This makefile builds the libcell.a library which gets pulled into
# the main libGL.so library
@@ -8,10 +8,14 @@ TOP = ../../../../..
include $(TOP)/configs/linux-cell
-#PROG = gl4
+# This is the "top-level" cell PPU driver code, will get pulled into libGL.so
+# by the winsys Makefile.
+CELL_LIB = ../libcell.a
-CELL_LIB = libcell.a
+# This is the SPU code. We'd like to be able to put this into the libcell.a
+# archive with the PPU code, but nesting .a libs doesn't seem to work.
+# So, it's pulled into libGL.so in gallium/winsys/xlib/Makefile
SPU_CODE_MODULE = ../spu/g3d_spu.a
@@ -21,14 +25,10 @@ SOURCES = \
cell_context.c \
cell_draw_arrays.c \
cell_flush.c \
- cell_state_blend.c \
- cell_state_clip.c \
cell_state_derived.c \
cell_state_emit.c \
- cell_state_fs.c \
- cell_state_rasterizer.c \
- cell_state_sampler.c \
- cell_state_surface.c \
+ cell_state_shader.c \
+ cell_pipe_state.c \
cell_state_vertex.c \
cell_spu.c \
cell_surface.c \
@@ -56,7 +56,7 @@ default: $(CELL_LIB)
$(CELL_LIB): $(OBJECTS) $(SPU_CODE_MODULE)
-# ar -ru $(CELL_LIB) $(OBJECTS) $(SPU_CODE_MODULE)
+# ar -ru $(CELL_LIB) $(OBJECTS) $(SPU_CODE_MODULE) # doesn't work
ar -ru $(CELL_LIB) $(OBJECTS)
#$(PROG): $(PPU_OBJECTS)
diff --git a/src/gallium/drivers/cell/ppu/cell_clear.c b/src/gallium/drivers/cell/ppu/cell_clear.c
index e588a30d5b..3ffe09add6 100644
--- a/src/gallium/drivers/cell/ppu/cell_clear.c
+++ b/src/gallium/drivers/cell/ppu/cell_clear.c
@@ -41,6 +41,7 @@
#include "cell_batch.h"
#include "cell_flush.h"
#include "cell_spu.h"
+#include "cell_state.h"
void
diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c
index e1eb22f468..98c314f45c 100644
--- a/src/gallium/drivers/cell/ppu/cell_context.c
+++ b/src/gallium/drivers/cell/ppu/cell_context.c
@@ -48,6 +48,7 @@
#include "cell_state.h"
#include "cell_surface.h"
#include "cell_spu.h"
+#include "cell_pipe_state.h"
#include "cell_texture.h"
#include "cell_vbuf.h"
@@ -198,40 +199,6 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws)
/* state setters */
- cell->pipe.create_blend_state = cell_create_blend_state;
- cell->pipe.bind_blend_state = cell_bind_blend_state;
- cell->pipe.delete_blend_state = cell_delete_blend_state;
-
- cell->pipe.create_sampler_state = cell_create_sampler_state;
- cell->pipe.bind_sampler_state = cell_bind_sampler_state;
- cell->pipe.delete_sampler_state = cell_delete_sampler_state;
-
- cell->pipe.create_depth_stencil_alpha_state = cell_create_depth_stencil_alpha_state;
- cell->pipe.bind_depth_stencil_alpha_state = cell_bind_depth_stencil_alpha_state;
- cell->pipe.delete_depth_stencil_alpha_state = cell_delete_depth_stencil_alpha_state;
-
- cell->pipe.create_rasterizer_state = cell_create_rasterizer_state;
- cell->pipe.bind_rasterizer_state = cell_bind_rasterizer_state;
- cell->pipe.delete_rasterizer_state = cell_delete_rasterizer_state;
-
- cell->pipe.create_fs_state = cell_create_fs_state;
- cell->pipe.bind_fs_state = cell_bind_fs_state;
- cell->pipe.delete_fs_state = cell_delete_fs_state;
-
- cell->pipe.create_vs_state = cell_create_vs_state;
- cell->pipe.bind_vs_state = cell_bind_vs_state;
- cell->pipe.delete_vs_state = cell_delete_vs_state;
-
- cell->pipe.set_blend_color = cell_set_blend_color;
- cell->pipe.set_clip_state = cell_set_clip_state;
- cell->pipe.set_constant_buffer = cell_set_constant_buffer;
-
- cell->pipe.set_framebuffer_state = cell_set_framebuffer_state;
-
- cell->pipe.set_polygon_stipple = cell_set_polygon_stipple;
- cell->pipe.set_scissor_state = cell_set_scissor_state;
- cell->pipe.set_viewport_state = cell_set_viewport_state;
-
cell->pipe.set_vertex_buffer = cell_set_vertex_buffer;
cell->pipe.set_vertex_element = cell_set_vertex_element;
@@ -241,20 +208,16 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws)
cell->pipe.clear = cell_clear_surface;
cell->pipe.flush = cell_flush;
- /* textures */
- cell->pipe.texture_create = cell_texture_create;
- cell->pipe.texture_release = cell_texture_release;
- cell->pipe.get_tex_surface = cell_get_tex_surface;
-
- cell->pipe.set_sampler_texture = cell_set_sampler_texture;
-
#if 0
cell->pipe.begin_query = cell_begin_query;
cell->pipe.end_query = cell_end_query;
cell->pipe.wait_query = cell_wait_query;
#endif
+ cell_init_state_functions(cell);
+ cell_init_shader_functions(cell);
cell_init_surface_functions(cell);
+ cell_init_texture_functions(cell);
cell->draw = cell_draw_create(cell);
diff --git a/src/gallium/drivers/cell/ppu/cell_context.h b/src/gallium/drivers/cell/ppu/cell_context.h
index 91f8e542a2..3b687bb868 100644
--- a/src/gallium/drivers/cell/ppu/cell_context.h
+++ b/src/gallium/drivers/cell/ppu/cell_context.h
@@ -36,7 +36,7 @@
#include "draw/draw_vbuf.h"
#include "cell_winsys.h"
#include "cell/common.h"
-#include "ppc/rtasm/spe_asm.h"
+#include "rtasm/rtasm_ppc_spe.h"
struct cell_vbuf_render;
diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
index f12613649b..cbd387f014 100644
--- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
+++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
@@ -49,9 +49,12 @@ cell_map_constant_buffers(struct cell_context *sp)
struct pipe_winsys *ws = sp->pipe.winsys;
uint i;
for (i = 0; i < 2; i++) {
- if (sp->constants[i].size)
+ if (sp->constants[i].size) {
sp->mapped_constants[i] = ws->buffer_map(ws, sp->constants[i].buffer,
PIPE_BUFFER_USAGE_CPU_READ);
+ cell_flush_buffer_range(sp, sp->mapped_constants[i],
+ sp->constants[i].buffer->size);
+ }
}
draw_set_mapped_constant_buffer(sp->draw,
@@ -124,6 +127,7 @@ cell_draw_elements(struct pipe_context *pipe,
void *buf = pipe->winsys->buffer_map(pipe->winsys,
sp->vertex_buffer[i].buffer,
PIPE_BUFFER_USAGE_CPU_READ);
+ cell_flush_buffer_range(sp, buf, sp->vertex_buffer[i].buffer->size);
draw_set_mapped_vertex_buffer(draw, i, buf);
}
}
diff --git a/src/gallium/drivers/cell/ppu/cell_flush.c b/src/gallium/drivers/cell/ppu/cell_flush.c
index 20f27531fc..66a5627d84 100644
--- a/src/gallium/drivers/cell/ppu/cell_flush.c
+++ b/src/gallium/drivers/cell/ppu/cell_flush.c
@@ -82,3 +82,17 @@ cell_flush_int(struct pipe_context *pipe, unsigned flags)
flushing = FALSE;
}
+
+
+void
+cell_flush_buffer_range(struct cell_context *cell, void *ptr,
+ unsigned size)
+{
+ uint64_t batch[1 + (ROUNDUP8(sizeof(struct cell_buffer_range)) / 8)];
+ struct cell_buffer_range *br = (struct cell_buffer_range *) & batch[1];
+
+ batch[0] = CELL_CMD_FLUSH_BUFFER_RANGE;
+ br->base = (uintptr_t) ptr;
+ br->size = size;
+ cell_batch_append(cell, batch, sizeof(batch));
+}
diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
new file mode 100644
index 0000000000..95bfc29fbe
--- /dev/null
+++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
@@ -0,0 +1,326 @@
+/**************************************************************************
+ *
+ * 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>
+ * Brian Paul
+ */
+
+#include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
+#include "draw/draw_context.h"
+#include "cell_context.h"
+#include "cell_state.h"
+#include "cell_texture.h"
+
+
+
+static void *
+cell_create_blend_state(struct pipe_context *pipe,
+ const struct pipe_blend_state *blend)
+{
+ return mem_dup(blend, sizeof(*blend));
+}
+
+
+static void
+cell_bind_blend_state(struct pipe_context *pipe, void *blend)
+{
+ struct cell_context *cell = cell_context(pipe);
+
+ draw_flush(cell->draw);
+
+ cell->blend = (const struct pipe_blend_state *)blend;
+
+ cell->dirty |= CELL_NEW_BLEND;
+}
+
+
+static void
+cell_delete_blend_state(struct pipe_context *pipe, void *blend)
+{
+ FREE(blend);
+}
+
+
+static void
+cell_set_blend_color(struct pipe_context *pipe,
+ const struct pipe_blend_color *blend_color)
+{
+ struct cell_context *cell = cell_context(pipe);
+
+ draw_flush(cell->draw);
+
+ cell->blend_color = *blend_color;
+
+ cell->dirty |= CELL_NEW_BLEND;
+}
+
+
+
+
+static void *
+cell_create_depth_stencil_alpha_state(struct pipe_context *pipe,
+ const struct pipe_depth_stencil_alpha_state *depth_stencil)
+{
+ return mem_dup(depth_stencil, sizeof(*depth_stencil));
+}
+
+
+static void
+cell_bind_depth_stencil_alpha_state(struct pipe_context *pipe,
+ void *depth_stencil)
+{
+ struct cell_context *cell = cell_context(pipe);
+
+ draw_flush(cell->draw);
+
+ cell->depth_stencil
+ = (const struct pipe_depth_stencil_alpha_state *) depth_stencil;
+
+ cell->dirty |= CELL_NEW_DEPTH_STENCIL;
+}
+
+
+static void
+cell_delete_depth_stencil_alpha_state(struct pipe_context *pipe, void *depth)
+{
+ FREE(depth);
+}
+
+
+static void cell_set_clip_state( struct pipe_context *pipe,
+ const struct pipe_clip_state *clip )
+{
+ struct cell_context *cell = cell_context(pipe);
+
+ /* pass the clip state to the draw module */
+ draw_set_clip_state(cell->draw, clip);
+}
+
+
+
+/* Called when driver state tracker notices changes to the viewport
+ * matrix:
+ */
+static void
+cell_set_viewport_state( struct pipe_context *pipe,
+ const struct pipe_viewport_state *viewport )
+{
+ struct cell_context *cell = cell_context(pipe);
+
+ cell->viewport = *viewport; /* struct copy */
+ cell->dirty |= CELL_NEW_VIEWPORT;
+
+ /* pass the viewport info to the draw module */
+ draw_set_viewport_state(cell->draw, viewport);
+
+ /* Using tnl/ and vf/ modules is temporary while getting started.
+ * Full pipe will have vertex shader, vertex fetch of its own.
+ */
+}
+
+
+static void
+cell_set_scissor_state( struct pipe_context *pipe,
+ const struct pipe_scissor_state *scissor )
+{
+ struct cell_context *cell = cell_context(pipe);
+
+ memcpy( &cell->scissor, scissor, sizeof(*scissor) );
+ cell->dirty |= CELL_NEW_SCISSOR;
+}
+
+
+static void
+cell_set_polygon_stipple( struct pipe_context *pipe,
+ const struct pipe_poly_stipple *stipple )
+{
+ struct cell_context *cell = cell_context(pipe);
+
+ memcpy( &cell->poly_stipple, stipple, sizeof(*stipple) );
+ cell->dirty |= CELL_NEW_STIPPLE;
+}
+
+
+
+static void *
+cell_create_rasterizer_state(struct pipe_context *pipe,
+ const struct pipe_rasterizer_state *setup)
+{
+ struct pipe_rasterizer_state *state
+ = MALLOC(sizeof(struct pipe_rasterizer_state));
+ memcpy(state, setup, sizeof(struct pipe_rasterizer_state));
+ return state;
+}
+
+
+static void
+cell_bind_rasterizer_state(struct pipe_context *pipe, void *setup)
+{
+ struct cell_context *cell = cell_context(pipe);
+
+ /* pass-through to draw module */
+ draw_set_rasterizer_state(cell->draw, setup);
+
+ cell->rasterizer = (struct pipe_rasterizer_state *)setup;
+
+ cell->dirty |= CELL_NEW_RASTERIZER;
+}
+
+
+static void
+cell_delete_rasterizer_state(struct pipe_context *pipe, void *rasterizer)
+{
+ FREE(rasterizer);
+}
+
+
+
+static void *
+cell_create_sampler_state(struct pipe_context *pipe,
+ const struct pipe_sampler_state *sampler)
+{
+ return mem_dup(sampler, sizeof(*sampler));
+}
+
+
+static void
+cell_bind_sampler_state(struct pipe_context *pipe,
+ unsigned unit, void *sampler)
+{
+ struct cell_context *cell = cell_context(pipe);
+
+ draw_flush(cell->draw);
+
+ assert(unit < PIPE_MAX_SAMPLERS);
+ cell->sampler[unit] = (struct pipe_sampler_state *)sampler;
+
+ cell->dirty |= CELL_NEW_SAMPLER;
+}
+
+
+static void
+cell_delete_sampler_state(struct pipe_context *pipe,
+ void *sampler)
+{
+ FREE( sampler );
+}
+
+
+
+static void
+cell_set_sampler_texture(struct pipe_context *pipe,
+ unsigned sampler,
+ struct pipe_texture *texture)
+{
+ struct cell_context *cell = cell_context(pipe);
+
+ draw_flush(cell->draw);
+
+ pipe_texture_reference(pipe,
+ (struct pipe_texture **) &cell->texture[sampler],
+ texture);
+
+ cell_update_texture_mapping(cell);
+
+ cell->dirty |= CELL_NEW_TEXTURE;
+}
+
+
+
+static void
+cell_set_framebuffer_state(struct pipe_context *pipe,
+ const struct pipe_framebuffer_state *fb)
+{
+ struct cell_context *cell = cell_context(pipe);
+
+ if (1 /*memcmp(&cell->framebuffer, fb, sizeof(*fb))*/) {
+ struct pipe_surface *csurf = fb->cbufs[0];
+ struct pipe_surface *zsurf = fb->zsbuf;
+ uint i;
+
+ /* unmap old surfaces */
+ for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
+ if (cell->framebuffer.cbufs[i] && cell->cbuf_map[i]) {
+ pipe_surface_unmap(cell->framebuffer.cbufs[i]);
+ cell->cbuf_map[i] = NULL;
+ }
+ }
+
+ if (cell->framebuffer.zsbuf && cell->zsbuf_map) {
+ pipe_surface_unmap(cell->framebuffer.zsbuf);
+ cell->zsbuf_map = NULL;
+ }
+
+ /* update my state */
+ cell->framebuffer = *fb;
+
+ /* map new surfaces */
+ if (csurf)
+ cell->cbuf_map[0] = pipe_surface_map(csurf);
+
+ if (zsurf)
+ cell->zsbuf_map = pipe_surface_map(zsurf);
+
+ cell->dirty |= CELL_NEW_FRAMEBUFFER;
+ }
+}
+
+
+
+void
+cell_init_state_functions(struct cell_context *cell)
+{
+ cell->pipe.create_blend_state = cell_create_blend_state;
+ cell->pipe.bind_blend_state = cell_bind_blend_state;
+ cell->pipe.delete_blend_state = cell_delete_blend_state;
+
+ cell->pipe.create_sampler_state = cell_create_sampler_state;
+ cell->pipe.bind_sampler_state = cell_bind_sampler_state;
+ cell->pipe.delete_sampler_state = cell_delete_sampler_state;
+
+ cell->pipe.set_sampler_texture = cell_set_sampler_texture;
+
+ cell->pipe.create_depth_stencil_alpha_state = cell_create_depth_stencil_alpha_state;
+ cell->pipe.bind_depth_stencil_alpha_state = cell_bind_depth_stencil_alpha_state;
+ cell->pipe.delete_depth_stencil_alpha_state = cell_delete_depth_stencil_alpha_state;
+
+ cell->pipe.create_rasterizer_state = cell_create_rasterizer_state;
+ cell->pipe.bind_rasterizer_state = cell_bind_rasterizer_state;
+ cell->pipe.delete_rasterizer_state = cell_delete_rasterizer_state;
+
+ cell->pipe.set_blend_color = cell_set_blend_color;
+ cell->pipe.set_clip_state = cell_set_clip_state;
+
+ cell->pipe.set_framebuffer_state = cell_set_framebuffer_state;
+
+ cell->pipe.set_polygon_stipple = cell_set_polygon_stipple;
+ cell->pipe.set_scissor_state = cell_set_scissor_state;
+ cell->pipe.set_viewport_state = cell_set_viewport_state;
+}
+
diff --git a/src/gallium/drivers/cell/ppu/cell_state_surface.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.h
index 287610b76b..1889bd52ff 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_surface.c
+++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.h
@@ -1,8 +1,8 @@
/**************************************************************************
*
- * Copyright 2007 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
* copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
@@ -26,46 +26,14 @@
**************************************************************************/
-#include "pipe/p_inlines.h"
-#include "cell_context.h"
-#include "cell_state.h"
-
-
-void
-cell_set_framebuffer_state(struct pipe_context *pipe,
- const struct pipe_framebuffer_state *fb)
-{
- struct cell_context *cell = cell_context(pipe);
-
- if (1 /*memcmp(&cell->framebuffer, fb, sizeof(*fb))*/) {
- struct pipe_surface *csurf = fb->cbufs[0];
- struct pipe_surface *zsurf = fb->zsbuf;
- uint i;
-
- /* unmap old surfaces */
- for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
- if (cell->framebuffer.cbufs[i] && cell->cbuf_map[i]) {
- pipe_surface_unmap(cell->framebuffer.cbufs[i]);
- cell->cbuf_map[i] = NULL;
- }
- }
-
- if (cell->framebuffer.zsbuf && cell->zsbuf_map) {
- pipe_surface_unmap(cell->framebuffer.zsbuf);
- cell->zsbuf_map = NULL;
- }
+#ifndef CELL_PIPE_STATE_H
+#define CELL_PIPE_STATE_H
- /* update my state */
- cell->framebuffer = *fb;
- /* map new surfaces */
- if (csurf)
- cell->cbuf_map[0] = pipe_surface_map(csurf);
+struct cell_context;
- if (zsurf)
- cell->zsbuf_map = pipe_surface_map(zsurf);
+extern void
+cell_init_state_functions(struct cell_context *cell);
- cell->dirty |= CELL_NEW_FRAMEBUFFER;
- }
-}
+#endif /* CELL_PIPE_STATE_H */
diff --git a/src/gallium/drivers/cell/ppu/cell_state.h b/src/gallium/drivers/cell/ppu/cell_state.h
index 3a71ba14fa..31ce505e21 100644
--- a/src/gallium/drivers/cell/ppu/cell_state.h
+++ b/src/gallium/drivers/cell/ppu/cell_state.h
@@ -1,3 +1,29 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
#ifndef CELL_STATE_H
@@ -22,82 +48,6 @@
#define CELL_NEW_VERTEX_INFO 0x8000
-
-extern void
-cell_set_framebuffer_state( struct pipe_context *,
- const struct pipe_framebuffer_state * );
-
-
-
-extern void *
-cell_create_blend_state(struct pipe_context *, const struct pipe_blend_state *);
-extern void cell_bind_blend_state(struct pipe_context *, void *);
-extern void cell_delete_blend_state(struct pipe_context *, void *);
-
-extern void cell_set_blend_color( struct pipe_context *pipe,
- const struct pipe_blend_color *blend_color );
-
-
-void *
-cell_create_sampler_state(struct pipe_context *,
- const struct pipe_sampler_state *);
-
-extern void
-cell_bind_sampler_state(struct pipe_context *, unsigned, void *);
-
-extern void
-cell_delete_sampler_state(struct pipe_context *, void *);
-
-
-extern void *
-cell_create_depth_stencil_alpha_state(struct pipe_context *,
- const struct pipe_depth_stencil_alpha_state *);
-
-extern void
-cell_bind_depth_stencil_alpha_state(struct pipe_context *, void *);
-
-extern void
-cell_delete_depth_stencil_alpha_state(struct pipe_context *, void *);
-
-
-void *cell_create_fs_state(struct pipe_context *,
- const struct pipe_shader_state *);
-void cell_bind_fs_state(struct pipe_context *, void *);
-void cell_delete_fs_state(struct pipe_context *, void *);
-void *cell_create_vs_state(struct pipe_context *,
- const struct pipe_shader_state *);
-void cell_bind_vs_state(struct pipe_context *, void *);
-void cell_delete_vs_state(struct pipe_context *, void *);
-
-
-void *
-cell_create_rasterizer_state(struct pipe_context *,
- const struct pipe_rasterizer_state *);
-void cell_bind_rasterizer_state(struct pipe_context *, void *);
-void cell_delete_rasterizer_state(struct pipe_context *, void *);
-
-
-void cell_set_clip_state( struct pipe_context *,
- const struct pipe_clip_state * );
-
-void cell_set_constant_buffer(struct pipe_context *pipe,
- uint shader, uint index,
- const struct pipe_constant_buffer *buf);
-
-void cell_set_polygon_stipple( struct pipe_context *,
- const struct pipe_poly_stipple * );
-
-void
-cell_set_sampler_texture(struct pipe_context *pipe,
- unsigned sampler,
- struct pipe_texture *texture);
-
-void cell_set_scissor_state( struct pipe_context *,
- const struct pipe_scissor_state * );
-
-void cell_set_texture_state( struct pipe_context *,
- unsigned unit, struct pipe_texture * );
-
void cell_set_vertex_element(struct pipe_context *,
unsigned index,
const struct pipe_vertex_element *);
@@ -106,10 +56,11 @@ void cell_set_vertex_buffer(struct pipe_context *,
unsigned index,
const struct pipe_vertex_buffer *);
-void cell_set_viewport_state( struct pipe_context *,
- const struct pipe_viewport_state * );
+void cell_update_derived( struct cell_context *softpipe );
-void cell_update_derived( struct cell_context *softpipe );
+void
+cell_init_shader_functions(struct cell_context *cell);
+
+#endif /* CELL_STATE_H */
-#endif
diff --git a/src/gallium/drivers/cell/ppu/cell_state_blend.c b/src/gallium/drivers/cell/ppu/cell_state_blend.c
deleted file mode 100644
index b6d6d71f0c..0000000000
--- a/src/gallium/drivers/cell/ppu/cell_state_blend.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/**************************************************************************
- *
- * 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 "draw/draw_context.h"
-#include "cell_context.h"
-#include "cell_state.h"
-
-
-
-void *
-cell_create_blend_state(struct pipe_context *pipe,
- const struct pipe_blend_state *blend)
-{
- return mem_dup(blend, sizeof(*blend));
-}
-
-
-void
-cell_bind_blend_state(struct pipe_context *pipe, void *blend)
-{
- struct cell_context *cell = cell_context(pipe);
-
- draw_flush(cell->draw);
-
- cell->blend = (const struct pipe_blend_state *)blend;
-
- cell->dirty |= CELL_NEW_BLEND;
-}
-
-
-void
-cell_delete_blend_state(struct pipe_context *pipe, void *blend)
-{
- FREE(blend);
-}
-
-
-void
-cell_set_blend_color(struct pipe_context *pipe,
- const struct pipe_blend_color *blend_color)
-{
- struct cell_context *cell = cell_context(pipe);
-
- draw_flush(cell->draw);
-
- cell->blend_color = *blend_color;
-
- cell->dirty |= CELL_NEW_BLEND;
-}
-
-
-
-
-void *
-cell_create_depth_stencil_alpha_state(struct pipe_context *pipe,
- const struct pipe_depth_stencil_alpha_state *depth_stencil)
-{
- return mem_dup(depth_stencil, sizeof(*depth_stencil));
-}
-
-
-void
-cell_bind_depth_stencil_alpha_state(struct pipe_context *pipe,
- void *depth_stencil)
-{
- struct cell_context *cell = cell_context(pipe);
-
- draw_flush(cell->draw);
-
- cell->depth_stencil
- = (const struct pipe_depth_stencil_alpha_state *) depth_stencil;
-
- cell->dirty |= CELL_NEW_DEPTH_STENCIL;
-}
-
-
-void
-cell_delete_depth_stencil_alpha_state(struct pipe_context *pipe, void *depth)
-{
- FREE(depth);
-}
diff --git a/src/gallium/drivers/cell/ppu/cell_state_clip.c b/src/gallium/drivers/cell/ppu/cell_state_clip.c
deleted file mode 100644
index 0482f87e88..0000000000
--- a/src/gallium/drivers/cell/ppu/cell_state_clip.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors: Keith Whitwell <keith@tungstengraphics.com>
- */
-
-#include "cell_context.h"
-#include "cell_state.h"
-#include "draw/draw_context.h"
-
-
-void cell_set_clip_state( struct pipe_context *pipe,
- const struct pipe_clip_state *clip )
-{
- struct cell_context *cell = cell_context(pipe);
-
- /* pass the clip state to the draw module */
- draw_set_clip_state(cell->draw, clip);
-}
-
-
-
-/* Called when driver state tracker notices changes to the viewport
- * matrix:
- */
-void cell_set_viewport_state( struct pipe_context *pipe,
- const struct pipe_viewport_state *viewport )
-{
- struct cell_context *cell = cell_context(pipe);
-
- cell->viewport = *viewport; /* struct copy */
- cell->dirty |= CELL_NEW_VIEWPORT;
-
- /* pass the viewport info to the draw module */
- draw_set_viewport_state(cell->draw, viewport);
-
- /* Using tnl/ and vf/ modules is temporary while getting started.
- * Full pipe will have vertex shader, vertex fetch of its own.
- */
-}
-
-
-void cell_set_scissor_state( struct pipe_context *pipe,
- const struct pipe_scissor_state *scissor )
-{
- struct cell_context *cell = cell_context(pipe);
-
- memcpy( &cell->scissor, scissor, sizeof(*scissor) );
- cell->dirty |= CELL_NEW_SCISSOR;
-}
-
-
-void cell_set_polygon_stipple( struct pipe_context *pipe,
- const struct pipe_poly_stipple *stipple )
-{
- struct cell_context *cell = cell_context(pipe);
-
- memcpy( &cell->poly_stipple, stipple, sizeof(*stipple) );
- cell->dirty |= CELL_NEW_STIPPLE;
-}
diff --git a/src/gallium/drivers/cell/ppu/cell_state_emit.c b/src/gallium/drivers/cell/ppu/cell_state_emit.c
index 5d2a786449..49c0d130c5 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_emit.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_emit.c
@@ -31,6 +31,8 @@
#include "cell_state_emit.h"
#include "cell_batch.h"
#include "cell_texture.h"
+#include "draw/draw_context.h"
+#include "draw/draw_private.h"
static void
@@ -100,4 +102,20 @@ cell_emit_state(struct cell_context *cell)
emit_state_cmd(cell, CELL_CMD_STATE_VERTEX_INFO,
&cell->vertex_info, sizeof(struct vertex_info));
}
+
+ if (cell->dirty & CELL_NEW_VS) {
+ const struct draw_context *const draw = cell->draw;
+ struct cell_shader_info info;
+
+ info.num_outputs = draw->num_vs_outputs;
+ info.declarations = (uintptr_t) draw->machine.Declarations;
+ info.num_declarations = draw->machine.NumDeclarations;
+ info.instructions = (uintptr_t) draw->machine.Instructions;
+ info.num_instructions = draw->machine.NumInstructions;
+ info.immediates = (uintptr_t) draw->machine.Imms;
+ info.num_immediates = draw->machine.ImmLimit / 4;
+
+ emit_state_cmd(cell, CELL_CMD_STATE_BIND_VS,
+ & info, sizeof(info));
+ }
}
diff --git a/src/gallium/drivers/cell/ppu/cell_state_rasterizer.c b/src/gallium/drivers/cell/ppu/cell_state_rasterizer.c
deleted file mode 100644
index 7eca5b5765..0000000000
--- a/src/gallium/drivers/cell/ppu/cell_state_rasterizer.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "draw/draw_context.h"
-#include "cell_context.h"
-#include "cell_state.h"
-
-
-
-struct spu_rasterizer_state
-{
- unsigned flatshade:1;
-#if 0
- unsigned light_twoside:1;
- unsigned front_winding:2; /**< PIPE_WINDING_x */
- unsigned cull_mode:2; /**< PIPE_WINDING_x */
- unsigned fill_cw:2; /**< PIPE_POLYGON_MODE_x */
- unsigned fill_ccw:2; /**< PIPE_POLYGON_MODE_x */
- unsigned offset_cw:1;
- unsigned offset_ccw:1;
-#endif
- unsigned scissor:1;
- unsigned poly_smooth:1;
- unsigned poly_stipple_enable:1;
- unsigned point_smooth:1;
-#if 0
- unsigned point_sprite:1;
- unsigned point_size_per_vertex:1; /**< size computed in vertex shader */
-#endif
- unsigned multisample:1; /* XXX maybe more ms state in future */
- unsigned line_smooth:1;
- unsigned line_stipple_enable:1;
- unsigned line_stipple_factor:8; /**< [1..256] actually */
- unsigned line_stipple_pattern:16;
-#if 0
- unsigned bypass_clipping:1;
-#endif
- unsigned origin_lower_left:1; /**< Is (0,0) the lower-left corner? */
-
- float line_width;
- float point_size; /**< used when no per-vertex size */
-#if 0
- float offset_units;
- float offset_scale;
- ubyte sprite_coord_mode[PIPE_MAX_SHADER_OUTPUTS]; /**< PIPE_SPRITE_COORD_ */
-#endif
-};
-
-
-
-void *
-cell_create_rasterizer_state(struct pipe_context *pipe,
- const struct pipe_rasterizer_state *setup)
-{
- struct pipe_rasterizer_state *state
- = MALLOC(sizeof(struct pipe_rasterizer_state));
- memcpy(state, setup, sizeof(struct pipe_rasterizer_state));
- return state;
-}
-
-
-void
-cell_bind_rasterizer_state(struct pipe_context *pipe, void *setup)
-{
- struct cell_context *cell = cell_context(pipe);
-
- /* pass-through to draw module */
- draw_set_rasterizer_state(cell->draw, setup);
-
- cell->rasterizer = (struct pipe_rasterizer_state *)setup;
-
- cell->dirty |= CELL_NEW_RASTERIZER;
-}
-
-
-void
-cell_delete_rasterizer_state(struct pipe_context *pipe, void *rasterizer)
-{
- FREE(rasterizer);
-}
diff --git a/src/gallium/drivers/cell/ppu/cell_state_sampler.c b/src/gallium/drivers/cell/ppu/cell_state_sampler.c
deleted file mode 100644
index a33421a4ad..0000000000
--- a/src/gallium/drivers/cell/ppu/cell_state_sampler.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/* Authors:
- * Brian Paul
- */
-
-#include "pipe/p_util.h"
-#include "draw/draw_context.h"
-#include "cell_context.h"
-#include "cell_state.h"
-#include "cell_texture.h"
-
-
-void *
-cell_create_sampler_state(struct pipe_context *pipe,
- const struct pipe_sampler_state *sampler)
-{
- return mem_dup(sampler, sizeof(*sampler));
-}
-
-void
-cell_bind_sampler_state(struct pipe_context *pipe,
- unsigned unit, void *sampler)
-{
- struct cell_context *cell = cell_context(pipe);
-
- draw_flush(cell->draw);
-
- assert(unit < PIPE_MAX_SAMPLERS);
- cell->sampler[unit] = (struct pipe_sampler_state *)sampler;
-
- cell->dirty |= CELL_NEW_SAMPLER;
-}
-
-
-void
-cell_delete_sampler_state(struct pipe_context *pipe,
- void *sampler)
-{
- FREE( sampler );
-}
-
-
-
-void
-cell_set_sampler_texture(struct pipe_context *pipe,
- unsigned sampler,
- struct pipe_texture *texture)
-{
- struct cell_context *cell = cell_context(pipe);
-
- draw_flush(cell->draw);
-
- cell->texture[sampler] = texture;
-
- cell_update_texture_mapping(cell);
-
- cell->dirty |= CELL_NEW_TEXTURE;
-}
diff --git a/src/gallium/drivers/cell/ppu/cell_state_fs.c b/src/gallium/drivers/cell/ppu/cell_state_shader.c
index b2ed699a5b..935501441b 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_fs.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_shader.c
@@ -32,7 +32,7 @@
#include "draw/draw_context.h"
#if 0
#include "pipe/p_shader_tokens.h"
-#include "llvm/gallivm.h"
+#include "gallivm/gallivm.h"
#include "tgsi/util/tgsi_dump.h"
#include "tgsi/exec/tgsi_sse2.h"
#endif
@@ -41,7 +41,7 @@
#include "cell_state.h"
-void *
+static void *
cell_create_fs_state(struct pipe_context *pipe,
const struct pipe_shader_state *templ)
{
@@ -80,7 +80,7 @@ cell_create_fs_state(struct pipe_context *pipe,
}
-void
+static void
cell_bind_fs_state(struct pipe_context *pipe, void *fs)
{
struct cell_context *cell = cell_context(pipe);
@@ -91,7 +91,7 @@ cell_bind_fs_state(struct pipe_context *pipe, void *fs)
}
-void
+static void
cell_delete_fs_state(struct pipe_context *pipe, void *fs)
{
struct cell_fragment_shader_state *state =
@@ -101,7 +101,7 @@ cell_delete_fs_state(struct pipe_context *pipe, void *fs)
}
-void *
+static void *
cell_create_vs_state(struct pipe_context *pipe,
const struct pipe_shader_state *templ)
{
@@ -124,7 +124,7 @@ cell_create_vs_state(struct pipe_context *pipe,
}
-void
+static void
cell_bind_vs_state(struct pipe_context *pipe, void *vs)
{
struct cell_context *cell = cell_context(pipe);
@@ -137,7 +137,7 @@ cell_bind_vs_state(struct pipe_context *pipe, void *vs)
}
-void
+static void
cell_delete_vs_state(struct pipe_context *pipe, void *vs)
{
struct cell_context *cell = cell_context(pipe);
@@ -150,7 +150,7 @@ cell_delete_vs_state(struct pipe_context *pipe, void *vs)
}
-void
+static void
cell_set_constant_buffer(struct pipe_context *pipe,
uint shader, uint index,
const struct pipe_constant_buffer *buf)
@@ -169,3 +169,18 @@ cell_set_constant_buffer(struct pipe_context *pipe,
cell->dirty |= CELL_NEW_CONSTANTS;
}
+
+
+void
+cell_init_shader_functions(struct cell_context *cell)
+{
+ cell->pipe.create_fs_state = cell_create_fs_state;
+ cell->pipe.bind_fs_state = cell_bind_fs_state;
+ cell->pipe.delete_fs_state = cell_delete_fs_state;
+
+ cell->pipe.create_vs_state = cell_create_vs_state;
+ cell->pipe.bind_vs_state = cell_bind_vs_state;
+ cell->pipe.delete_vs_state = cell_delete_vs_state;
+
+ cell->pipe.set_constant_buffer = cell_set_constant_buffer;
+}
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c
index c8ef36002f..0edefa5f05 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.c
+++ b/src/gallium/drivers/cell/ppu/cell_texture.c
@@ -79,14 +79,16 @@ cell_texture_layout(struct cell_texture * spt)
}
-struct pipe_texture *
-cell_texture_create(struct pipe_context *pipe, const struct pipe_texture *templat)
+static struct pipe_texture *
+cell_texture_create(struct pipe_context *pipe,
+ const struct pipe_texture *templat)
{
struct cell_texture *spt = CALLOC_STRUCT(cell_texture);
if (!spt)
return NULL;
spt->base = *templat;
+ spt->base.refcount = 1;
cell_texture_layout(spt);
@@ -103,7 +105,7 @@ cell_texture_create(struct pipe_context *pipe, const struct pipe_texture *templa
}
-void
+static void
cell_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
{
if (!*pt)
@@ -128,10 +130,18 @@ cell_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
}
+static void
+cell_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
+{
+ /* XXX TO DO: re-tile the texture data ... */
+
+}
+
+
/**
* Called via pipe->get_tex_surface()
*/
-struct pipe_surface *
+static struct pipe_surface *
cell_get_tex_surface(struct pipe_context *pipe,
struct pipe_texture *pt,
unsigned face, unsigned level, unsigned zslice)
@@ -250,3 +260,13 @@ cell_update_texture_mapping(struct cell_context *cell)
cell->tex_map = pipe_surface_map(cell->tex_surf);
#endif
}
+
+
+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;
+}
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.h b/src/gallium/drivers/cell/ppu/cell_texture.h
index 0264fed88e..824fb3e20f 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.h
+++ b/src/gallium/drivers/cell/ppu/cell_texture.h
@@ -29,7 +29,7 @@
#define CELL_TEXTURE_H
-struct pipe_context;
+struct cell_context;
struct pipe_texture;
@@ -60,21 +60,12 @@ cell_texture(struct pipe_texture *pt)
-extern struct pipe_texture *
-cell_texture_create(struct pipe_context *pipe,
- const struct pipe_texture *templat);
-
extern void
-cell_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
-
-extern struct pipe_surface *
-cell_get_tex_surface(struct pipe_context *pipe,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice);
+cell_update_texture_mapping(struct cell_context *cell);
extern void
-cell_update_texture_mapping(struct cell_context *cell);
+cell_init_texture_functions(struct cell_context *cell);
-#endif /* CELL_TEXTURE */
+#endif /* CELL_TEXTURE_H */
diff --git a/src/gallium/drivers/cell/ppu/cell_vertex_fetch.c b/src/gallium/drivers/cell/ppu/cell_vertex_fetch.c
index f10689a959..9cf74bab47 100644
--- a/src/gallium/drivers/cell/ppu/cell_vertex_fetch.c
+++ b/src/gallium/drivers/cell/ppu/cell_vertex_fetch.c
@@ -31,7 +31,7 @@
#include "../auxiliary/draw/draw_private.h"
#include "cell_context.h"
-#include "ppc/rtasm/spe_asm.h"
+#include "rtasm/rtasm_ppc_spe.h"
typedef uint64_t register_mask;
diff --git a/src/gallium/drivers/cell/ppu/cell_vertex_shader.c b/src/gallium/drivers/cell/ppu/cell_vertex_shader.c
index 6a1d3bc20a..f7ef72e5a2 100644
--- a/src/gallium/drivers/cell/ppu/cell_vertex_shader.c
+++ b/src/gallium/drivers/cell/ppu/cell_vertex_shader.c
@@ -35,6 +35,7 @@
#include "cell_context.h"
#include "cell_draw_arrays.h"
+#include "cell_flush.h"
#include "cell_spu.h"
#include "cell_batch.h"
@@ -54,6 +55,7 @@ cell_vertex_shader_queue_flush(struct draw_context *draw)
struct cell_command_vs *const vs = &cell_global.command[0].vs;
uint64_t *batch;
struct cell_array_info *array_info;
+ struct cell_shader_info *shader_info;
unsigned i, j;
struct cell_attribute_fetch_code *cf;
@@ -100,17 +102,17 @@ cell_vertex_shader_queue_flush(struct draw_context *draw)
(void) memcpy(&batch[1], &draw->viewport,
sizeof(struct pipe_viewport_state));
+ {
+ uint64_t uniforms = (uintptr_t) draw->user.constants;
+
+ batch = cell_batch_alloc(cell, 2 *sizeof(batch[0]));
+ batch[0] = CELL_CMD_STATE_UNIFORMS;
+ batch[1] = uniforms;
+ }
+
cell_batch_flush(cell);
vs->opcode = CELL_CMD_VS_EXECUTE;
- vs->shader.num_outputs = draw->num_vs_outputs;
- vs->shader.declarations = (uintptr_t) draw->machine.Declarations;
- vs->shader.num_declarations = draw->machine.NumDeclarations;
- vs->shader.instructions = (uintptr_t) draw->machine.Instructions;
- vs->shader.num_instructions = draw->machine.NumInstructions;
- vs->shader.uniforms = (uintptr_t) draw->user.constants;
- vs->shader.immediates = (uintptr_t) draw->machine.Imms;
- vs->shader.num_immediates = draw->machine.ImmLimit / 4;
vs->nr_attrs = draw->vertex_fetch.nr_attrs;
(void) memcpy(vs->plane, draw->plane, sizeof(draw->plane));
diff --git a/src/gallium/drivers/cell/spu/Makefile b/src/gallium/drivers/cell/spu/Makefile
index 30ef2450ec..c071de1900 100644
--- a/src/gallium/drivers/cell/spu/Makefile
+++ b/src/gallium/drivers/cell/spu/Makefile
@@ -18,6 +18,7 @@ PROG_SPU_EMBED_O = $(PROG)_spu-embed.o
SOURCES = \
spu_main.c \
spu_blend.c \
+ spu_dcache.c \
spu_render.c \
spu_texture.c \
spu_tile.c \
diff --git a/src/gallium/drivers/cell/spu/spu_dcache.c b/src/gallium/drivers/cell/spu/spu_dcache.c
new file mode 100644
index 0000000000..698a5790bb
--- /dev/null
+++ b/src/gallium/drivers/cell/spu/spu_dcache.c
@@ -0,0 +1,111 @@
+/*
+ * (C) Copyright IBM Corporation 2008
+ * 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
+ * on 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
+ * AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR 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 "cell/common.h"
+#include "spu_main.h"
+#include "spu_dcache.h"
+
+#define CACHELINE_LOG2SIZE 7
+#define LINE_SIZE (1U << 7)
+#define ALIGN_MASK (~(LINE_SIZE - 1))
+
+#define CACHE_NAME data
+#define CACHED_TYPE qword
+#define CACHE_TYPE CACHE_TYPE_RO
+#define CACHE_SET_TAGID(set) TAG_VERTEX_BUFFER
+#define CACHE_LOG2NNWAY 2
+#define CACHE_LOG2NSETS 6
+#include <cache-api.h>
+
+/* Yes folks, this is ugly.
+ */
+#undef CACHE_NWAY
+#undef CACHE_NSETS
+#define CACHE_NAME data
+#define CACHE_NWAY 4
+#define CACHE_NSETS (1U << 6)
+
+
+/**
+ * Fetch between arbitrary number of bytes from an unaligned address
+ */
+void
+spu_dcache_fetch_unaligned(qword *dst, unsigned ea, unsigned size)
+{
+ const int shift = ea & 0x0f;
+ const unsigned aligned_start_ea = ea & ~0x0f;
+ const unsigned aligned_end_ea = ROUNDUP16(ea + size);
+ const unsigned num_entries = (aligned_end_ea - aligned_start_ea) / 16;
+ unsigned i;
+
+
+ if (shift == 0) {
+ /* Data is already aligned. Fetch directly into the destination buffer.
+ */
+ for (i = 0; i < num_entries; i++) {
+ dst[i] = cache_rd(data, ea + (i * 16));
+ }
+ } else {
+ qword tmp[2] ALIGN16_ATTRIB;
+
+
+ tmp[0] = cache_rd(data, (ea & ~0x0f));
+ for (i = 0; i < (num_entries & ~1); i++) {
+ const unsigned curr = i & 1;
+ const unsigned next = curr ^ 1;
+
+ tmp[next] = cache_rd(data, (ea & ~0x0f) + (next * 16));
+
+ dst[i] = si_or((qword) spu_slqwbyte(tmp[curr], shift),
+ (qword) spu_rlmaskqwbyte(tmp[next], shift - 16));
+ }
+
+ if (i < num_entries) {
+ dst[i] = si_or((qword) spu_slqwbyte(tmp[(i & 1)], shift),
+ si_il(0));
+ }
+ }
+}
+
+
+/**
+ * Notify the cache that a range of main memory may have been modified
+ */
+void
+spu_dcache_mark_dirty(unsigned ea, unsigned size)
+{
+ unsigned i;
+ const unsigned aligned_start = (ea & ALIGN_MASK);
+ const unsigned aligned_end = (ea + size + (LINE_SIZE - 1))
+ & ALIGN_MASK;
+
+
+ for (i = 0; i < (CACHE_NWAY * CACHE_NSETS); i++) {
+ const unsigned entry = __cache_dir[i];
+ const unsigned addr = entry & ~0x0f;
+
+ __cache_dir[i] = ((addr >= aligned_start) && (addr < aligned_end))
+ ? (entry & ~CACHELINE_VALID) : entry;
+ }
+}
diff --git a/src/gallium/drivers/cell/spu/spu_dcache.h b/src/gallium/drivers/cell/spu/spu_dcache.h
new file mode 100644
index 0000000000..7a06b8c25a
--- /dev/null
+++ b/src/gallium/drivers/cell/spu/spu_dcache.h
@@ -0,0 +1,34 @@
+/*
+ * (C) Copyright IBM Corporation 2008
+ * 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
+ * on 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
+ * AUTHORS, COPYRIGHT HOLDERS, AND/OR THEIR 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 SPU_DCACHE_H
+#define SPU_DCACHE_H
+
+extern void
+spu_dcache_fetch_unaligned(qword *dst, unsigned ea, unsigned size);
+
+extern void
+spu_dcache_mark_dirty(unsigned ea, unsigned size);
+
+#endif /* SPU_DCACHE_H */
diff --git a/src/gallium/drivers/cell/spu/spu_exec.c b/src/gallium/drivers/cell/spu/spu_exec.c
index 109540b1f7..cf81bee8fd 100644
--- a/src/gallium/drivers/cell/spu/spu_exec.c
+++ b/src/gallium/drivers/cell/spu/spu_exec.c
@@ -72,6 +72,8 @@
#include "spu_exec.h"
#include "spu_main.h"
#include "spu_vertex_shader.h"
+#include "spu_dcache.h"
+#include "cell/common.h"
#define TILE_TOP_LEFT 0
#define TILE_TOP_RIGHT 1
@@ -146,17 +148,13 @@ spu_exec_machine_init(struct spu_exec_machine *mach,
struct spu_sampler *samplers,
unsigned processor)
{
- qword zero;
- qword not_zero;
- uint i;
+ const qword zero = si_il(0);
+ const qword not_zero = si_il(~0);
mach->Samplers = samplers;
mach->Processor = processor;
mach->Addrs = &mach->Temps[TGSI_EXEC_NUM_TEMPS];
- zero = si_xor(zero, zero);
- not_zero = si_xori(zero, 0xff);
-
/* Setup constants. */
mach->Temps[TEMP_0_I].xyzw[TEMP_0_C].q = zero;
mach->Temps[TEMP_FF_I].xyzw[TEMP_FF_C].q = not_zero;
@@ -356,19 +354,17 @@ fetch_src_file_channel(
case TGSI_EXTSWIZZLE_W:
switch( file ) {
case TGSI_FILE_CONSTANT: {
- unsigned char buffer[32] ALIGN16_ATTRIB;
unsigned i;
for (i = 0; i < 4; i++) {
const float *ptr = mach->Consts[index->i[i]];
- const uint64_t addr = (uint64_t)(uintptr_t) ptr;
- const unsigned size = ((addr & 0x0f) == 0) ? 16 : 32;
+ float tmp[4];
- mfc_get(buffer, addr & ~0x0f, size, TAG_VERTEX_BUFFER, 0, 0);
- wait_on_mask(1 << TAG_VERTEX_BUFFER);
+ spu_dcache_fetch_unaligned((qword *) tmp,
+ (uintptr_t)(ptr + swizzle),
+ sizeof(float));
- (void) memcpy(& chan->f[i], &buffer[(addr & 0x0f)
- + (sizeof(float) * swizzle)], sizeof(float));
+ chan->f[i] = tmp[0];
}
break;
}
@@ -1903,32 +1899,28 @@ spu_exec_machine_run( struct spu_exec_machine *mach )
/* execute declarations (interpolants) */
if( mach->Processor == TGSI_PROCESSOR_FRAGMENT ) {
for (i = 0; i < mach->NumDeclarations; i++) {
- uint8_t buffer[sizeof(struct tgsi_full_declaration) + 32] ALIGN16_ATTRIB;
- struct tgsi_full_declaration decl;
- unsigned long decl_addr = (unsigned long) (mach->Declarations+i);
- unsigned size = ((sizeof(decl) + (decl_addr & 0x0f) + 0x0f) & ~0x0f);
+ union {
+ struct tgsi_full_declaration decl;
+ qword buffer[ROUNDUP16(sizeof(struct tgsi_full_declaration)) / 16];
+ } d ALIGN16_ATTRIB;
+ unsigned ea = (unsigned) (mach->Declarations + pc);
- mfc_get(buffer, decl_addr & ~0x0f, size, TAG_INSTRUCTION_FETCH, 0, 0);
- wait_on_mask(1 << TAG_INSTRUCTION_FETCH);
+ spu_dcache_fetch_unaligned(d.buffer, ea, sizeof(d.decl));
- memcpy(& decl, buffer + (decl_addr & 0x0f), sizeof(decl));
- exec_declaration( mach, &decl );
+ exec_declaration( mach, &d.decl );
}
}
/* execute instructions, until pc is set to -1 */
while (pc != -1) {
- uint8_t buffer[sizeof(struct tgsi_full_instruction) + 32] ALIGN16_ATTRIB;
- struct tgsi_full_instruction inst;
- unsigned long inst_addr = (unsigned long) (mach->Instructions + pc);
- unsigned size = ((sizeof(inst) + (inst_addr & 0x0f) + 0x0f) & ~0x0f);
-
- assert(pc < mach->NumInstructions);
- mfc_get(buffer, inst_addr & ~0x0f, size, TAG_INSTRUCTION_FETCH, 0, 0);
- wait_on_mask(1 << TAG_INSTRUCTION_FETCH);
-
- memcpy(& inst, buffer + (inst_addr & 0x0f), sizeof(inst));
- exec_instruction( mach, & inst, &pc );
+ union {
+ struct tgsi_full_instruction inst;
+ qword buffer[ROUNDUP16(sizeof(struct tgsi_full_instruction)) / 16];
+ } i ALIGN16_ATTRIB;
+ unsigned ea = (unsigned) (mach->Instructions + pc);
+
+ spu_dcache_fetch_unaligned(i.buffer, ea, sizeof(i.inst));
+ exec_instruction( mach, & i.inst, &pc );
}
#if 0
diff --git a/src/gallium/drivers/cell/spu/spu_main.c b/src/gallium/drivers/cell/spu/spu_main.c
index fcbf0f841e..1136dba62d 100644
--- a/src/gallium/drivers/cell/spu/spu_main.c
+++ b/src/gallium/drivers/cell/spu/spu_main.c
@@ -433,10 +433,19 @@ cmd_batch(uint opcode)
sizeof(struct pipe_viewport_state));
pos += (1 + ROUNDUP8(sizeof(struct pipe_viewport_state)) / 8);
break;
+ case CELL_CMD_STATE_UNIFORMS:
+ draw.constants = (float (*)[4]) (uintptr_t) buffer[pos + 1];
+ pos += 2;
+ break;
case CELL_CMD_STATE_VS_ARRAY_INFO:
cmd_state_vs_array_info((struct cell_array_info *) &buffer[pos+1]);
pos += (1 + ROUNDUP8(sizeof(struct cell_array_info)) / 8);
break;
+ case CELL_CMD_STATE_BIND_VS:
+ spu_bind_vertex_shader(&draw,
+ (struct cell_shader_info *) &buffer[pos+1]);
+ pos += (1 + ROUNDUP8(sizeof(struct cell_shader_info)) / 8);
+ break;
case CELL_CMD_STATE_ATTRIB_FETCH: {
struct cell_attribute_fetch_code *code =
(struct cell_attribute_fetch_code *) &buffer[pos+1];
@@ -453,6 +462,14 @@ cmd_batch(uint opcode)
pos += (1 + ROUNDUP8(sizeof(struct cell_attribute_fetch_code)) / 8);
break;
}
+ case CELL_CMD_FLUSH_BUFFER_RANGE: {
+ struct cell_buffer_range *br = (struct cell_buffer_range *)
+ &buffer[pos+1];
+
+ spu_dcache_mark_dirty((unsigned) br->base, br->size);
+ pos += (1 + ROUNDUP8(sizeof(struct cell_buffer_range)) / 8);
+ break;
+ }
default:
printf("SPU %u: bad opcode: 0x%llx\n", spu.init.id, buffer[pos]);
ASSERT(0);
diff --git a/src/gallium/drivers/cell/spu/spu_vertex_fetch.c b/src/gallium/drivers/cell/spu/spu_vertex_fetch.c
index 55c6c28717..f7e4e653e3 100644
--- a/src/gallium/drivers/cell/spu/spu_vertex_fetch.c
+++ b/src/gallium/drivers/cell/spu/spu_vertex_fetch.c
@@ -40,31 +40,13 @@
#include "spu_exec.h"
#include "spu_vertex_shader.h"
#include "spu_main.h"
-
-#define CACHE_NAME attribute
-#define CACHED_TYPE qword
-#define CACHE_TYPE CACHE_TYPE_RO
-#define CACHE_SET_TAGID(set) TAG_VERTEX_BUFFER
-#define CACHE_LOG2NNWAY 2
-#define CACHE_LOG2NSETS 6
-#include <cache-api.h>
-
-/* Yes folks, this is ugly.
- */
-#undef CACHE_NWAY
-#undef CACHE_NSETS
-#define CACHE_NAME attribute
-#define CACHE_NWAY 4
-#define CACHE_NSETS (1U << 6)
-
-
-#define DRAW_DBG 0
+#include "spu_dcache.h"
typedef void (*spu_fetch_func)(qword *out, const qword *in,
const qword *shuffle_data);
-static const qword fetch_shuffle_data[] = {
+static const qword fetch_shuffle_data[5] ALIGN16_ATTRIB = {
/* Shuffle used by CVT_64_FLOAT
*/
{
@@ -103,44 +85,6 @@ static const qword fetch_shuffle_data[] = {
/**
- * Fetch between 1 and 32 bytes from an unaligned address
- */
-static INLINE void
-fetch_unaligned(qword *dst, unsigned ea, unsigned size)
-{
- qword tmp[4];
- const int shift = ea & 0x0f;
- const unsigned aligned_start_ea = ea & ~0x0f;
- const unsigned aligned_end_ea = (ea + size) & ~0x0f;
- const unsigned num_entries = ((aligned_end_ea - aligned_start_ea) / 16) + 1;
- unsigned i;
-
-
- if (shift == 0) {
- /* Data is already aligned. Fetch directly into the destination buffer.
- */
- for (i = 0; i < num_entries; i++) {
- dst[i] = cache_rd(attribute, (ea & ~0x0f) + (i * 16));
- }
- } else {
- /* Fetch data from the cache to the local buffer.
- */
- for (i = 0; i < num_entries; i++) {
- tmp[i] = cache_rd(attribute, (ea & ~0x0f) + (i * 16));
- }
-
-
- /* Fix the alignment of the data and write to the destination buffer.
- */
- for (i = 0; i < ((size + 15) / 16); i++) {
- dst[i] = si_or((qword) spu_slqwbyte(tmp[i], shift),
- (qword) spu_rlmaskqwbyte(tmp[i + 1], shift - 16));
- }
- }
-}
-
-
-/**
* Fetch vertex attributes for 'count' vertices.
*/
static void generic_vertex_fetch(struct spu_vs_context *draw,
@@ -169,7 +113,7 @@ static void generic_vertex_fetch(struct spu_vs_context *draw,
unsigned idx;
const unsigned bytes_per_entry = draw->vertex_fetch.size[attr];
const unsigned quads_per_entry = (bytes_per_entry + 15) / 16;
- qword in[2 * 4];
+ qword in[2 * 4] ALIGN16_ATTRIB;
/* Fetch four attributes for four vertices.
@@ -182,7 +126,7 @@ static void generic_vertex_fetch(struct spu_vs_context *draw,
printf("SPU: fetching = 0x%llx\n", addr);
#endif
- fetch_unaligned(& in[idx], addr, bytes_per_entry);
+ spu_dcache_fetch_unaligned(& in[idx], addr, bytes_per_entry);
idx += quads_per_entry;
}
@@ -200,15 +144,5 @@ static void generic_vertex_fetch(struct spu_vs_context *draw,
void spu_update_vertex_fetch( struct spu_vs_context *draw )
{
- unsigned i;
-
-
- /* Invalidate the vertex cache.
- */
- for (i = 0; i < (CACHE_NWAY * CACHE_NSETS); i++) {
- CACHELINE_CLEARVALID(i);
- }
-
-
draw->vertex_fetch.fetch_func = generic_vertex_fetch;
}
diff --git a/src/gallium/drivers/cell/spu/spu_vertex_shader.c b/src/gallium/drivers/cell/spu/spu_vertex_shader.c
index 3f5bf41aa2..8363efeeb6 100644
--- a/src/gallium/drivers/cell/spu/spu_vertex_shader.c
+++ b/src/gallium/drivers/cell/spu/spu_vertex_shader.c
@@ -165,63 +165,55 @@ run_vertex_program(struct spu_vs_context *draw,
}
-static void
-spu_bind_vertex_shader(struct spu_vs_context *draw,
- void *uniforms,
- void *planes,
- unsigned nr_planes,
- unsigned num_outputs
- )
-{
- draw->constants = (float (*)[4]) uniforms;
-
- (void) memcpy(draw->plane, planes, sizeof(float) * 4 * nr_planes);
- draw->nr_planes = nr_planes;
- draw->num_vs_outputs = num_outputs;
-
- /* specify the shader to interpret/execute */
- spu_exec_machine_init(&draw->machine,
- PIPE_MAX_SAMPLERS,
- NULL /*samplers*/,
- PIPE_SHADER_VERTEX);
-}
-
-
unsigned char immediates[(sizeof(float) * 4 * TGSI_EXEC_NUM_IMMEDIATES) + 32]
ALIGN16_ATTRIB;
+
void
-spu_execute_vertex_shader(struct spu_vs_context *draw,
- const struct cell_command_vs *vs)
+spu_bind_vertex_shader(struct spu_vs_context *draw,
+ struct cell_shader_info *vs)
{
- unsigned i;
-
- const uint64_t immediate_addr = vs->shader.immediates;
+ const unsigned immediate_addr = vs->immediates;
const unsigned immediate_size =
- ROUNDUP16((sizeof(float) * 4 * vs->shader.num_immediates)
- + (immediate_addr & 0x0f));
+ ROUNDUP16((sizeof(float) * 4 * vs->num_immediates)
+ + (immediate_addr & 0x0f));
+
mfc_get(immediates, immediate_addr & ~0x0f, immediate_size,
TAG_VERTEX_BUFFER, 0, 0);
draw->machine.Instructions = (struct tgsi_full_instruction *)
- vs->shader.instructions;
- draw->machine.NumInstructions = vs->shader.num_instructions;
+ vs->instructions;
+ draw->machine.NumInstructions = vs->num_instructions;
draw->machine.Declarations = (struct tgsi_full_declaration *)
- vs->shader.declarations;
- draw->machine.NumDeclarations = vs->shader.num_declarations;
+ vs->declarations;
+ draw->machine.NumDeclarations = vs->num_declarations;
- draw->vertex_fetch.nr_attrs = vs->nr_attrs;
+ draw->num_vs_outputs = vs->num_outputs;
+
+ /* specify the shader to interpret/execute */
+ spu_exec_machine_init(&draw->machine,
+ PIPE_MAX_SAMPLERS,
+ NULL /*samplers*/,
+ PIPE_SHADER_VERTEX);
wait_on_mask(1 << TAG_VERTEX_BUFFER);
(void) memcpy(& draw->machine.Imms, &immediates[immediate_addr & 0x0f],
- sizeof(float) * 4 * vs->shader.num_immediates);
+ sizeof(float) * 4 * vs->num_immediates);
+}
- spu_bind_vertex_shader(draw, vs->shader.uniforms,
- vs->plane, vs->nr_planes,
- vs->shader.num_outputs);
+
+void
+spu_execute_vertex_shader(struct spu_vs_context *draw,
+ const struct cell_command_vs *vs)
+{
+ unsigned i;
+
+ (void) memcpy(draw->plane, vs->plane, sizeof(float) * 4 * vs->nr_planes);
+ draw->nr_planes = vs->nr_planes;
+ draw->vertex_fetch.nr_attrs = vs->nr_attrs;
for (i = 0; i < vs->num_elts; i += 4) {
const unsigned batch_size = MIN2(vs->num_elts - i, 4);
diff --git a/src/gallium/drivers/cell/spu/spu_vertex_shader.h b/src/gallium/drivers/cell/spu/spu_vertex_shader.h
index 0fb0bc28d0..54a4b8d9b9 100644
--- a/src/gallium/drivers/cell/spu/spu_vertex_shader.h
+++ b/src/gallium/drivers/cell/spu/spu_vertex_shader.h
@@ -1,6 +1,7 @@
#ifndef SPU_VERTEX_SHADER_H
#define SPU_VERTEX_SHADER_H
+#include "cell/common.h"
#include "pipe/p_format.h"
#include "spu_exec.h"
@@ -55,6 +56,10 @@ static INLINE void spu_vertex_fetch(struct spu_vs_context *draw,
struct cell_command_vs;
extern void
+spu_bind_vertex_shader(struct spu_vs_context *draw,
+ struct cell_shader_info *vs);
+
+extern void
spu_execute_vertex_shader(struct spu_vs_context *draw,
const struct cell_command_vs *vs);
diff --git a/src/gallium/drivers/failover/Makefile b/src/gallium/drivers/failover/Makefile
index 14389bd055..f08b8df07a 100644
--- a/src/gallium/drivers/failover/Makefile
+++ b/src/gallium/drivers/failover/Makefile
@@ -1,20 +1,13 @@
-
TOP = ../../../..
include $(TOP)/configs/current
LIBNAME = failover
-DRIVER_SOURCES = \
+C_SOURCES = \
fo_state.c \
fo_state_emit.c \
fo_context.c
-C_SOURCES = \
- $(COMMON_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
include ../../Makefile.template
symlinks:
diff --git a/src/gallium/drivers/failover/SConscript b/src/gallium/drivers/failover/SConscript
new file mode 100644
index 0000000000..f8e9b1b491
--- /dev/null
+++ b/src/gallium/drivers/failover/SConscript
@@ -0,0 +1,13 @@
+Import('*')
+
+env = env.Clone()
+
+failover = env.ConvenienceLibrary(
+ target = 'failover',
+ source = [
+ 'fo_state.c',
+ 'fo_state_emit.c',
+ 'fo_context.c',
+ ])
+
+Export('failover')
diff --git a/src/gallium/drivers/failover/fo_context.c b/src/gallium/drivers/failover/fo_context.c
index 7ce4a7df17..156f7399b0 100644
--- a/src/gallium/drivers/failover/fo_context.c
+++ b/src/gallium/drivers/failover/fo_context.c
@@ -137,15 +137,14 @@ struct pipe_context *failover_create( struct pipe_context *hw,
failover_init_state_functions( failover );
-#if 0
- failover->pipe.surface_alloc = hw->surface_alloc;
-#endif
- failover->pipe.get_tex_surface = hw->get_tex_surface;
-
failover->pipe.surface_copy = hw->surface_copy;
failover->pipe.surface_fill = hw->surface_fill;
+
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;
+
failover->pipe.flush = hw->flush;
failover->dirty = 0;
diff --git a/src/gallium/drivers/i915simple/Makefile b/src/gallium/drivers/i915simple/Makefile
index ee22ba86f9..2a75f5d57c 100644
--- a/src/gallium/drivers/i915simple/Makefile
+++ b/src/gallium/drivers/i915simple/Makefile
@@ -1,10 +1,9 @@
-
TOP = ../../../..
include $(TOP)/configs/current
LIBNAME = i915simple
-DRIVER_SOURCES = \
+C_SOURCES = \
i915_blit.c \
i915_clear.c \
i915_flush.c \
@@ -26,12 +25,6 @@ DRIVER_SOURCES = \
i915_fpc_translate.c \
i915_surface.c
-C_SOURCES = \
- $(COMMON_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
include ../../Makefile.template
symlinks:
diff --git a/src/gallium/drivers/i915simple/i915_context.c b/src/gallium/drivers/i915simple/i915_context.c
index 7f71f8fd4f..acfa349439 100644
--- a/src/gallium/drivers/i915simple/i915_context.c
+++ b/src/gallium/drivers/i915simple/i915_context.c
@@ -296,12 +296,11 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
i915_init_state_functions(i915);
i915_init_flush_functions(i915);
i915_init_string_functions(i915);
+ i915_init_texture_functions(i915);
i915->pci_id = pci_id;
i915->flags.is_i945 = is_i945;
- i915->pipe.texture_create = i915_texture_create;
- i915->pipe.texture_release = i915_texture_release;
i915->dirty = ~0;
i915->hardware_dirty = ~0;
diff --git a/src/gallium/drivers/i915simple/i915_debug.c b/src/gallium/drivers/i915simple/i915_debug.c
index 94db44e1aa..78102dbac2 100644
--- a/src/gallium/drivers/i915simple/i915_debug.c
+++ b/src/gallium/drivers/i915simple/i915_debug.c
@@ -25,8 +25,6 @@
*
**************************************************************************/
-//#include "imports.h"
-
#include "i915_reg.h"
#include "i915_context.h"
#include "i915_winsys.h"
diff --git a/src/gallium/drivers/i915simple/i915_state.c b/src/gallium/drivers/i915simple/i915_state.c
index 294e6fad03..e055eed7e0 100644
--- a/src/gallium/drivers/i915simple/i915_state.c
+++ b/src/gallium/drivers/i915simple/i915_state.c
@@ -32,6 +32,7 @@
#include "draw/draw_context.h"
#include "pipe/p_winsys.h"
#include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
#include "i915_context.h"
#include "i915_reg.h"
@@ -505,7 +506,9 @@ static void i915_set_sampler_texture(struct pipe_context *pipe,
{
struct i915_context *i915 = i915_context(pipe);
- i915->texture[sampler] = (struct i915_texture*)texture; /* ptr, not struct */
+ pipe_texture_reference(pipe,
+ (struct pipe_texture **) &i915->texture[sampler],
+ texture);
i915->dirty |= I915_NEW_TEXTURE;
}
diff --git a/src/gallium/drivers/i915simple/i915_state_immediate.c b/src/gallium/drivers/i915simple/i915_state_immediate.c
index 07031fc6c5..dfbbcab624 100644
--- a/src/gallium/drivers/i915simple/i915_state_immediate.c
+++ b/src/gallium/drivers/i915simple/i915_state_immediate.c
@@ -33,7 +33,7 @@
#include "i915_context.h"
#include "i915_state.h"
#include "i915_reg.h"
-#include "p_util.h"
+#include "pipe/p_util.h"
/* All state expressable with the LOAD_STATE_IMMEDIATE_1 packet.
diff --git a/src/gallium/drivers/i915simple/i915_state_inlines.h b/src/gallium/drivers/i915simple/i915_state_inlines.h
index 0934ac79a4..378de8f9c4 100644
--- a/src/gallium/drivers/i915simple/i915_state_inlines.h
+++ b/src/gallium/drivers/i915simple/i915_state_inlines.h
@@ -28,8 +28,8 @@
#ifndef I915_STATE_INLINES_H
#define I915_STATE_INLINES_H
-#include "p_compiler.h"
-#include "p_defines.h"
+#include "pipe/p_compiler.h"
+#include "pipe/p_defines.h"
#include "i915_reg.h"
diff --git a/src/gallium/drivers/i915simple/i915_surface.c b/src/gallium/drivers/i915simple/i915_surface.c
index 17fd27895a..f4fbedbe9b 100644
--- a/src/gallium/drivers/i915simple/i915_surface.c
+++ b/src/gallium/drivers/i915simple/i915_surface.c
@@ -36,48 +36,6 @@
#include "util/p_tile.h"
-/*
- * 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)
-{
- struct i915_texture *tex = (struct i915_texture *)pt;
- struct pipe_surface *ps;
- unsigned offset; /* in bytes */
-
- offset = tex->level_offset[level];
-
- if (pt->target == PIPE_TEXTURE_CUBE) {
- offset += tex->image_offset[level][face] * pt->cpp;
- }
- else if (pt->target == PIPE_TEXTURE_3D) {
- offset += tex->image_offset[level][zslice] * pt->cpp;
- }
- else {
- assert(face == 0);
- assert(zslice == 0);
- }
-
- ps = pipe->winsys->surface_alloc(pipe->winsys);
- if (ps) {
- assert(ps->refcount);
- assert(ps->winsys);
- pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
- ps->format = pt->format;
- ps->cpp = pt->cpp;
- ps->width = pt->width[level];
- ps->height = pt->height[level];
- ps->pitch = tex->pitch;
- ps->offset = offset;
- }
- return ps;
-}
-
-
-
/* Assumes all values are within bounds -- no checking at this level -
* do it higher up if required.
*/
@@ -115,6 +73,7 @@ i915_surface_copy(struct pipe_context *pipe,
}
}
+
/* Fill a rectangular sub-region. Need better logic about when to
* push buffers into AGP - will currently do so whenever possible.
*/
@@ -184,8 +143,6 @@ i915_surface_fill(struct pipe_context *pipe,
void
i915_init_surface_functions(struct i915_context *i915)
{
- i915->pipe.get_tex_surface = i915_get_tex_surface;
-
i915->pipe.surface_copy = i915_surface_copy;
i915->pipe.surface_fill = i915_surface_fill;
}
diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c
index 6d37ae3d74..1b415a94d4 100644
--- a/src/gallium/drivers/i915simple/i915_texture.c
+++ b/src/gallium/drivers/i915simple/i915_texture.c
@@ -478,7 +478,7 @@ i945_miptree_layout(struct pipe_context *pipe, struct i915_texture * tex)
}
-struct pipe_texture *
+static struct pipe_texture *
i915_texture_create(struct pipe_context *pipe,
const struct pipe_texture *templat)
{
@@ -488,6 +488,7 @@ i915_texture_create(struct pipe_context *pipe,
struct i915_context *i915 = i915_context(pipe);
tex->base = *templat;
+ tex->base.refcount = 1;
if (i915->flags.is_i945 ? i945_miptree_layout(pipe, tex) :
i915_miptree_layout(pipe, tex))
@@ -506,7 +507,7 @@ i915_texture_create(struct pipe_context *pipe,
}
-void
+static void
i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
{
if (!*pt)
@@ -534,3 +535,62 @@ i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
}
*pt = NULL;
}
+
+
+static void
+i915_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
+{
+ /* no-op? */
+}
+
+
+/*
+ * 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)
+{
+ struct i915_texture *tex = (struct i915_texture *)pt;
+ struct pipe_surface *ps;
+ unsigned offset; /* in bytes */
+
+ offset = tex->level_offset[level];
+
+ if (pt->target == PIPE_TEXTURE_CUBE) {
+ offset += tex->image_offset[level][face] * pt->cpp;
+ }
+ else if (pt->target == PIPE_TEXTURE_3D) {
+ offset += tex->image_offset[level][zslice] * pt->cpp;
+ }
+ else {
+ assert(face == 0);
+ assert(zslice == 0);
+ }
+
+ ps = pipe->winsys->surface_alloc(pipe->winsys);
+ if (ps) {
+ assert(ps->refcount);
+ assert(ps->winsys);
+ pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
+ ps->format = pt->format;
+ ps->cpp = pt->cpp;
+ ps->width = pt->width[level];
+ ps->height = pt->height[level];
+ ps->pitch = tex->pitch;
+ ps->offset = offset;
+ }
+ return ps;
+}
+
+
+
+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;
+}
diff --git a/src/gallium/drivers/i915simple/i915_texture.h b/src/gallium/drivers/i915simple/i915_texture.h
index 330d111dc7..6d8d41178f 100644
--- a/src/gallium/drivers/i915simple/i915_texture.h
+++ b/src/gallium/drivers/i915simple/i915_texture.h
@@ -1,17 +1,38 @@
+/**************************************************************************
+ *
+ * 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 I915_TEXTURE_H
#define I915_TEXTURE_H
struct pipe_context;
-struct pipe_texture;
-struct pipe_texture *
-i915_texture_create(struct pipe_context *pipe,
- const struct pipe_texture *templat);
-
extern void
-i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
+i915_init_texture_functions(struct i915_context *i915);
#endif /* I915_TEXTURE_H */
diff --git a/src/gallium/drivers/i965simple/Makefile b/src/gallium/drivers/i965simple/Makefile
index 1dec1f9749..cc8580836c 100644
--- a/src/gallium/drivers/i965simple/Makefile
+++ b/src/gallium/drivers/i965simple/Makefile
@@ -1,14 +1,13 @@
-
TOP = ../../../..
include $(TOP)/configs/current
LIBNAME = i965simple
-DRIVER_SOURCES = \
- brw_blit.c \
- brw_flush.c \
- brw_strings.c \
- brw_surface.c \
+C_SOURCES = \
+ brw_blit.c \
+ brw_flush.c \
+ brw_strings.c \
+ brw_surface.c \
brw_cc.c \
brw_clip.c \
brw_clip_line.c \
@@ -31,8 +30,8 @@ DRIVER_SOURCES = \
brw_sf.c \
brw_sf_emit.c \
brw_sf_state.c \
- brw_shader_info.c \
- brw_state.c \
+ brw_shader_info.c \
+ brw_state.c \
brw_state_batch.c \
brw_state_cache.c \
brw_state_pool.c \
@@ -51,16 +50,6 @@ DRIVER_SOURCES = \
brw_wm_state.c \
brw_wm_surface_state.c
-C_SOURCES = \
- $(COMMON_SOURCES) \
- $(COMMON_BM_SOURCES) \
- $(MINIGLX_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
-DRIVER_DEFINES = -I.
-
include ../../Makefile.template
symlinks:
diff --git a/src/gallium/drivers/i965simple/brw_context.c b/src/gallium/drivers/i965simple/brw_context.c
index 5e58701e91..6fb840708e 100644
--- a/src/gallium/drivers/i965simple/brw_context.c
+++ b/src/gallium/drivers/i965simple/brw_context.c
@@ -222,10 +222,9 @@ struct pipe_context *brw_create(struct pipe_winsys *pipe_winsys,
brw->pipe.get_param = brw_get_param;
brw->pipe.get_paramf = brw_get_paramf;
brw->pipe.clear = brw_clear;
- brw->pipe.texture_create = brw_texture_create;
- brw->pipe.texture_release = brw_texture_release;
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);
diff --git a/src/gallium/drivers/i965simple/brw_state.c b/src/gallium/drivers/i965simple/brw_state.c
index f746d1cc57..2fc048bde0 100644
--- a/src/gallium/drivers/i965simple/brw_state.c
+++ b/src/gallium/drivers/i965simple/brw_state.c
@@ -32,6 +32,7 @@
#include "pipe/p_winsys.h"
#include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/util/tgsi_dump.h"
@@ -327,7 +328,9 @@ static void brw_set_sampler_texture(struct pipe_context *pipe,
{
struct brw_context *brw = brw_context(pipe);
- brw->attribs.Texture[unit] = (struct brw_texture*)texture; /* ptr, not struct */
+ pipe_texture_reference(pipe,
+ (struct pipe_texture **) &brw->attribs.Texture[unit],
+ texture);
brw->state.dirty.brw |= BRW_NEW_TEXTURE;
}
diff --git a/src/gallium/drivers/i965simple/brw_surface.c b/src/gallium/drivers/i965simple/brw_surface.c
index 376a42b1a6..dc4846d39f 100644
--- a/src/gallium/drivers/i965simple/brw_surface.c
+++ b/src/gallium/drivers/i965simple/brw_surface.c
@@ -35,47 +35,6 @@
#include "util/p_tile.h"
-/*
- * 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)
-{
- struct brw_texture *tex = (struct brw_texture *)pt;
- struct pipe_surface *ps;
- unsigned offset; /* in bytes */
-
- offset = tex->level_offset[level];
-
- if (pt->target == PIPE_TEXTURE_CUBE) {
- offset += tex->image_offset[level][face] * pt->cpp;
- }
- else if (pt->target == PIPE_TEXTURE_3D) {
- offset += tex->image_offset[level][zslice] * pt->cpp;
- }
- else {
- assert(face == 0);
- assert(zslice == 0);
- }
-
- ps = pipe->winsys->surface_alloc(pipe->winsys);
- if (ps) {
- assert(ps->format);
- assert(ps->refcount);
- pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
- ps->format = pt->format;
- ps->cpp = pt->cpp;
- ps->width = pt->width[level];
- ps->height = pt->height[level];
- ps->pitch = tex->pitch;
- ps->offset = offset;
- }
- return ps;
-}
-
-
/* Upload data to a rectangular sub-region. Lots of choices how to do this:
*
* - memcpy by span to current destination
@@ -201,10 +160,10 @@ brw_surface_fill(struct pipe_context *pipe,
}
}
+
void
brw_init_surface_functions(struct brw_context *brw)
{
- brw->pipe.get_tex_surface = brw_get_tex_surface;
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 90561f1307..86ce3d0cc3 100644
--- a/src/gallium/drivers/i965simple/brw_tex_layout.c
+++ b/src/gallium/drivers/i965simple/brw_tex_layout.c
@@ -300,13 +300,15 @@ static boolean brw_miptree_layout(struct pipe_context *pipe, struct brw_texture
}
-struct pipe_texture *
-brw_texture_create(struct pipe_context *pipe, const struct pipe_texture *templat)
+static struct pipe_texture *
+brw_texture_create(struct pipe_context *pipe,
+ const struct pipe_texture *templat)
{
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,
@@ -323,7 +325,8 @@ brw_texture_create(struct pipe_context *pipe, const struct pipe_texture *templat
return &tex->base;
}
-void
+
+static void
brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
{
if (!*pt)
@@ -351,3 +354,61 @@ brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
}
*pt = NULL;
}
+
+
+static void
+brw_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
+{
+ /* no-op? */
+}
+
+
+/*
+ * 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)
+{
+ struct brw_texture *tex = (struct brw_texture *)pt;
+ struct pipe_surface *ps;
+ unsigned offset; /* in bytes */
+
+ offset = tex->level_offset[level];
+
+ if (pt->target == PIPE_TEXTURE_CUBE) {
+ offset += tex->image_offset[level][face] * pt->cpp;
+ }
+ else if (pt->target == PIPE_TEXTURE_3D) {
+ offset += tex->image_offset[level][zslice] * pt->cpp;
+ }
+ else {
+ assert(face == 0);
+ assert(zslice == 0);
+ }
+
+ ps = pipe->winsys->surface_alloc(pipe->winsys);
+ if (ps) {
+ assert(ps->format);
+ assert(ps->refcount);
+ pipe_buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
+ ps->format = pt->format;
+ ps->cpp = pt->cpp;
+ ps->width = pt->width[level];
+ ps->height = pt->height[level];
+ ps->pitch = tex->pitch;
+ ps->offset = offset;
+ }
+ return ps;
+}
+
+
+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;
+}
diff --git a/src/gallium/drivers/i965simple/brw_tex_layout.h b/src/gallium/drivers/i965simple/brw_tex_layout.h
index cfd6b1ef3a..ed49baeef8 100644
--- a/src/gallium/drivers/i965simple/brw_tex_layout.h
+++ b/src/gallium/drivers/i965simple/brw_tex_layout.h
@@ -1,15 +1,12 @@
#ifndef BRW_TEX_LAYOUT_H
#define BRW_TEX_LAYOUT_H
-#include "pipe/p_compiler.h"
-struct pipe_context;
-struct pipe_texture;
+struct brw_context;
-extern struct pipe_texture *
-brw_texture_create(struct pipe_context *pipe, const struct pipe_texture *templat);
extern void
-brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
+brw_init_texture_functions(struct brw_context *brw);
+
#endif
diff --git a/src/gallium/drivers/softpipe/Makefile b/src/gallium/drivers/softpipe/Makefile
index 5479daf8ea..539ffb77f5 100644
--- a/src/gallium/drivers/softpipe/Makefile
+++ b/src/gallium/drivers/softpipe/Makefile
@@ -1,10 +1,9 @@
-
TOP = ../../../..
include $(TOP)/configs/current
LIBNAME = softpipe
-DRIVER_SOURCES = \
+C_SOURCES = \
sp_fs_exec.c \
sp_fs_sse.c \
sp_fs_llvm.c \
@@ -41,12 +40,6 @@ DRIVER_SOURCES = \
sp_tile_cache.c \
sp_surface.c
-C_SOURCES = \
- $(COMMON_SOURCES) \
- $(DRIVER_SOURCES)
-
-ASM_SOURCES =
-
include ../../Makefile.template
symlinks:
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index 5e98f190bb..2cdf3c75bf 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -283,6 +283,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
/* 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;
/*
@@ -327,6 +328,18 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
draw_set_rasterize_stage(softpipe->draw, softpipe->setup);
}
+ /* plug in AA line/point stages */
+ draw_install_aaline_stage(softpipe->draw, &softpipe->pipe);
+ draw_install_aapoint_stage(softpipe->draw, &softpipe->pipe);
+
+#if USE_DRAW_STAGE_PSTIPPLE
+ /* Do polygon stipple w/ texture map + frag prog? */
+ 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_context.h b/src/gallium/drivers/softpipe/sp_context.h
index b70d4fea85..feeafc7084 100644
--- a/src/gallium/drivers/softpipe/sp_context.h
+++ b/src/gallium/drivers/softpipe/sp_context.h
@@ -39,6 +39,13 @@
#include "sp_quad.h"
+/**
+ * This is a temporary variable for testing draw-stage polygon stipple.
+ * If zero, do stipple in sp_quad_stipple.c
+ */
+#define USE_DRAW_STAGE_PSTIPPLE 1
+
+
struct softpipe_winsys;
struct softpipe_vbuf_render;
struct draw_context;
@@ -68,7 +75,7 @@ struct softpipe_context {
struct pipe_framebuffer_state framebuffer;
struct pipe_poly_stipple poly_stipple;
struct pipe_scissor_state scissor;
- struct softpipe_texture *texture[PIPE_MAX_SAMPLERS];
+ struct pipe_texture *texture[PIPE_MAX_SAMPLERS];
struct pipe_viewport_state viewport;
struct pipe_vertex_buffer vertex_buffer[PIPE_ATTRIB_MAX];
struct pipe_vertex_element vertex_element[PIPE_ATTRIB_MAX];
diff --git a/src/gallium/drivers/softpipe/sp_fs_exec.c b/src/gallium/drivers/softpipe/sp_fs_exec.c
index 9ad30a7681..8cb0534342 100644
--- a/src/gallium/drivers/softpipe/sp_fs_exec.c
+++ b/src/gallium/drivers/softpipe/sp_fs_exec.c
@@ -44,6 +44,41 @@ struct sp_exec_fragment_shader {
+/**
+ * Compute quad X,Y,Z,W for the four fragments in a quad.
+ *
+ * This should really be part of the compiled shader.
+ */
+void
+sp_setup_pos_vector(const struct tgsi_interp_coef *coef,
+ float x, float y,
+ struct tgsi_exec_vector *quadpos)
+{
+ uint chan;
+ /* do X */
+ quadpos->xyzw[0].f[0] = x;
+ quadpos->xyzw[0].f[1] = x + 1;
+ quadpos->xyzw[0].f[2] = x;
+ quadpos->xyzw[0].f[3] = x + 1;
+
+ /* do Y */
+ quadpos->xyzw[1].f[0] = y;
+ quadpos->xyzw[1].f[1] = y;
+ quadpos->xyzw[1].f[2] = y + 1;
+ quadpos->xyzw[1].f[3] = y + 1;
+
+ /* do Z and W for all fragments in the quad */
+ for (chan = 2; chan < 4; chan++) {
+ const float dadx = coef->dadx[chan];
+ const float dady = coef->dady[chan];
+ const float a0 = coef->a0[chan] + dadx * x + dady * y;
+ quadpos->xyzw[chan].f[0] = a0;
+ quadpos->xyzw[chan].f[1] = a0 + dadx;
+ quadpos->xyzw[chan].f[2] = a0 + dady;
+ quadpos->xyzw[chan].f[3] = a0 + dadx + dady;
+ }
+}
+
static void
exec_prepare( struct sp_fragment_shader *base,
diff --git a/src/gallium/drivers/softpipe/sp_fs_sse.c b/src/gallium/drivers/softpipe/sp_fs_sse.c
index d90066e025..8095d662ee 100644
--- a/src/gallium/drivers/softpipe/sp_fs_sse.c
+++ b/src/gallium/drivers/softpipe/sp_fs_sse.c
@@ -42,7 +42,7 @@
#if defined(__i386__) || defined(__386__)
-#include "x86/rtasm/x86sse.h"
+#include "rtasm/rtasm_x86sse.h"
/* Surely this should be defined somewhere in a tgsi header:
*/
@@ -63,41 +63,6 @@ struct sp_sse_fragment_shader {
};
-/**
- * Compute quad X,Y,Z,W for the four fragments in a quad.
- *
- * This should really be part of the compiled shader.
- */
-void
-sp_setup_pos_vector(const struct tgsi_interp_coef *coef,
- float x, float y,
- struct tgsi_exec_vector *quadpos)
-{
- uint chan;
- /* do X */
- quadpos->xyzw[0].f[0] = x;
- quadpos->xyzw[0].f[1] = x + 1;
- quadpos->xyzw[0].f[2] = x;
- quadpos->xyzw[0].f[3] = x + 1;
-
- /* do Y */
- quadpos->xyzw[1].f[0] = y;
- quadpos->xyzw[1].f[1] = y;
- quadpos->xyzw[1].f[2] = y + 1;
- quadpos->xyzw[1].f[3] = y + 1;
-
- /* do Z and W for all fragments in the quad */
- for (chan = 2; chan < 4; chan++) {
- const float dadx = coef->dadx[chan];
- const float dady = coef->dady[chan];
- const float a0 = coef->a0[chan] + dadx * x + dady * y;
- quadpos->xyzw[chan].f[0] = a0;
- quadpos->xyzw[chan].f[1] = a0 + dadx;
- quadpos->xyzw[chan].f[2] = a0 + dady;
- quadpos->xyzw[chan].f[3] = a0 + dadx + dady;
- }
-}
-
static void
fs_sse_prepare( struct sp_fragment_shader *base,
@@ -124,6 +89,9 @@ fs_sse_run( struct sp_fragment_shader *base,
(float)quad->x0, (float)quad->y0,
machine->Temps);
+ /* init kill mask */
+ machine->Temps[TGSI_EXEC_TEMP_KILMASK_I].xyzw[TGSI_EXEC_TEMP_KILMASK_C].u[0] = 0x0;
+
shader->func( machine->Inputs,
machine->Outputs,
machine->Consts,
diff --git a/src/gallium/drivers/softpipe/sp_prim_setup.c b/src/gallium/drivers/softpipe/sp_prim_setup.c
index d73521ccbe..7b1e131ee1 100644
--- a/src/gallium/drivers/softpipe/sp_prim_setup.c
+++ b/src/gallium/drivers/softpipe/sp_prim_setup.c
@@ -476,33 +476,33 @@ static void tri_persp_coeff( struct setup_stage *setup,
* We could do a bit less work if we'd examine gl_FragCoord's swizzle mask.
*/
static void
-setup_fragcoord_coeff(struct setup_stage *setup)
+setup_fragcoord_coeff(struct setup_stage *setup, uint slot)
{
/*X*/
- setup->coef[0].a0[0] = 0;
- setup->coef[0].dadx[0] = 1.0;
- setup->coef[0].dady[0] = 0.0;
+ setup->coef[slot].a0[0] = 0;
+ setup->coef[slot].dadx[0] = 1.0;
+ setup->coef[slot].dady[0] = 0.0;
/*Y*/
if (setup->softpipe->rasterizer->origin_lower_left) {
/* y=0=bottom */
const int winHeight = setup->softpipe->framebuffer.cbufs[0]->height;
- setup->coef[0].a0[1] = (float) (winHeight - 1);
- setup->coef[0].dady[1] = -1.0;
+ setup->coef[slot].a0[1] = (float) (winHeight - 1);
+ setup->coef[slot].dady[1] = -1.0;
}
else {
/* y=0=top */
- setup->coef[0].a0[1] = 0.0;
- setup->coef[0].dady[1] = 1.0;
+ setup->coef[slot].a0[1] = 0.0;
+ setup->coef[slot].dady[1] = 1.0;
}
- setup->coef[0].dadx[1] = 0.0;
+ setup->coef[slot].dadx[1] = 0.0;
/*Z*/
- setup->coef[0].a0[2] = setup->posCoef.a0[2];
- setup->coef[0].dadx[2] = setup->posCoef.dadx[2];
- setup->coef[0].dady[2] = setup->posCoef.dady[2];
+ setup->coef[slot].a0[2] = setup->posCoef.a0[2];
+ setup->coef[slot].dadx[2] = setup->posCoef.dadx[2];
+ setup->coef[slot].dady[2] = setup->posCoef.dady[2];
/*W*/
- setup->coef[0].a0[3] = setup->posCoef.a0[3];
- setup->coef[0].dadx[3] = setup->posCoef.dadx[3];
- setup->coef[0].dady[3] = setup->posCoef.dady[3];
+ setup->coef[slot].a0[3] = setup->posCoef.a0[3];
+ setup->coef[slot].dadx[3] = setup->posCoef.dadx[3];
+ setup->coef[slot].dady[3] = setup->posCoef.dady[3];
}
@@ -543,8 +543,7 @@ static void setup_tri_coefficients( struct setup_stage *setup )
tri_persp_coeff(setup, &setup->coef[fragSlot], vertSlot, j);
break;
case INTERP_POS:
- assert(fragSlot == 0);
- setup_fragcoord_coeff(setup);
+ setup_fragcoord_coeff(setup, fragSlot);
break;
default:
assert(0);
@@ -798,9 +797,7 @@ setup_line_coefficients(struct setup_stage *setup, struct prim_header *prim)
line_persp_coeff(setup, &setup->coef[fragSlot], vertSlot, j);
break;
case INTERP_POS:
- assert(fragSlot == 0);
- assert(0); /* XXX fix this: */
- setup_fragcoord_coeff(setup);
+ setup_fragcoord_coeff(setup, fragSlot);
break;
default:
assert(0);
@@ -1022,9 +1019,7 @@ setup_point(struct draw_stage *stage, struct prim_header *prim)
&setup->coef[fragSlot], vertSlot, j);
break;
case INTERP_POS:
- assert(fragSlot == 0);
- assert(0); /* XXX fix this: */
- setup_fragcoord_coeff(setup);
+ setup_fragcoord_coeff(setup, fragSlot);
break;
default:
assert(0);
diff --git a/src/gallium/drivers/softpipe/sp_quad.c b/src/gallium/drivers/softpipe/sp_quad.c
index 6bd468a51c..15b5594547 100644
--- a/src/gallium/drivers/softpipe/sp_quad.c
+++ b/src/gallium/drivers/softpipe/sp_quad.c
@@ -112,7 +112,9 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
sp_push_quad_first( sp, sp->quad.earlyz );
}
+#if !USE_DRAW_STAGE_PSTIPPLE
if (sp->rasterizer->poly_stipple_enable) {
sp_push_quad_first( sp, sp->quad.polygon_stipple );
}
+#endif
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c
index cf1b1eff75..2f40e09d5c 100644
--- a/src/gallium/drivers/softpipe/sp_quad_fs.c
+++ b/src/gallium/drivers/softpipe/sp_quad_fs.c
@@ -142,7 +142,7 @@ static void shade_begin(struct quad_stage *qs)
/* set TGSI sampler state that varies */
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
qss->samplers[i].state = softpipe->sampler[i];
- qss->samplers[i].texture = &softpipe->texture[i]->base;
+ qss->samplers[i].texture = softpipe->texture[i];
}
/* find output slots for depth, color */
diff --git a/src/gallium/drivers/softpipe/sp_state_clip.c b/src/gallium/drivers/softpipe/sp_state_clip.c
index c797c0dd3b..4946c776e3 100644
--- a/src/gallium/drivers/softpipe/sp_state_clip.c
+++ b/src/gallium/drivers/softpipe/sp_state_clip.c
@@ -42,24 +42,16 @@ void softpipe_set_clip_state( struct pipe_context *pipe,
}
-
-/* Called when driver state tracker notices changes to the viewport
- * matrix:
- */
void softpipe_set_viewport_state( struct pipe_context *pipe,
const struct pipe_viewport_state *viewport )
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- softpipe->viewport = *viewport; /* struct copy */
- softpipe->dirty |= SP_NEW_VIEWPORT;
-
/* pass the viewport info to the draw module */
draw_set_viewport_state(softpipe->draw, viewport);
- /* Using tnl/ and vf/ modules is temporary while getting started.
- * Full pipe will have vertex shader, vertex fetch of its own.
- */
+ softpipe->viewport = *viewport; /* struct copy */
+ softpipe->dirty |= SP_NEW_VIEWPORT;
}
@@ -68,7 +60,9 @@ void softpipe_set_scissor_state( struct pipe_context *pipe,
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- memcpy( &softpipe->scissor, scissor, sizeof(*scissor) );
+ draw_flush(softpipe->draw);
+
+ softpipe->scissor = *scissor; /* struct copy */
softpipe->dirty |= SP_NEW_SCISSOR;
}
@@ -78,6 +72,8 @@ void softpipe_set_polygon_stipple( struct pipe_context *pipe,
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- memcpy( &softpipe->poly_stipple, stipple, sizeof(*stipple) );
+ draw_flush(softpipe->draw);
+
+ softpipe->poly_stipple = *stipple; /* struct copy */
softpipe->dirty |= SP_NEW_STIPPLE;
}
diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c
index 9d8fd8b750..f9f2c5eaa8 100644
--- a/src/gallium/drivers/softpipe/sp_state_derived.c
+++ b/src/gallium/drivers/softpipe/sp_state_derived.c
@@ -44,7 +44,8 @@
* condition that users shouldn't hit anyway.
*/
static int
-find_vs_output(const struct pipe_shader_state *vs,
+find_vs_output(struct softpipe_context *sp,
+ const struct pipe_shader_state *vs,
uint semantic_name,
uint semantic_index)
{
@@ -54,7 +55,9 @@ find_vs_output(const struct pipe_shader_state *vs,
vs->output_semantic_index[i] == semantic_index)
return i;
}
- return 0;
+
+ /* See if the draw module is introducing a new attribute... */
+ return draw_find_vs_output(sp->draw, semantic_name, semantic_index);
}
@@ -111,24 +114,24 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
int src;
switch (fs->input_semantic_name[i]) {
case TGSI_SEMANTIC_POSITION:
- src = find_vs_output(vs, TGSI_SEMANTIC_POSITION, 0);
+ src = find_vs_output(softpipe, vs, TGSI_SEMANTIC_POSITION, 0);
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_POS, src);
break;
case TGSI_SEMANTIC_COLOR:
- src = find_vs_output(vs, TGSI_SEMANTIC_COLOR,
+ src = find_vs_output(softpipe, vs, TGSI_SEMANTIC_COLOR,
fs->input_semantic_index[i]);
draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
break;
case TGSI_SEMANTIC_FOG:
- src = find_vs_output(vs, TGSI_SEMANTIC_FOG, 0);
+ src = find_vs_output(softpipe, vs, TGSI_SEMANTIC_FOG, 0);
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
break;
case TGSI_SEMANTIC_GENERIC:
/* this includes texcoords and varying vars */
- src = find_vs_output(vs, TGSI_SEMANTIC_GENERIC,
+ src = find_vs_output(softpipe, vs, TGSI_SEMANTIC_GENERIC,
fs->input_semantic_index[i]);
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
break;
@@ -138,7 +141,7 @@ softpipe_get_vertex_info(struct softpipe_context *softpipe)
}
}
- softpipe->psize_slot = find_vs_output(vs, TGSI_SEMANTIC_PSIZE, 0);
+ softpipe->psize_slot = find_vs_output(softpipe, vs, TGSI_SEMANTIC_PSIZE, 0);
if (softpipe->psize_slot > 0) {
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_CONSTANT,
softpipe->psize_slot);
diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c
index 460adccec4..18669a1c6e 100644
--- a/src/gallium/drivers/softpipe/sp_state_sampler.c
+++ b/src/gallium/drivers/softpipe/sp_state_sampler.c
@@ -30,6 +30,7 @@
*/
#include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
#include "draw/draw_context.h"
@@ -82,9 +83,9 @@ softpipe_set_sampler_texture(struct pipe_context *pipe,
draw_flush(softpipe->draw);
assert(unit < PIPE_MAX_SAMPLERS);
- softpipe->texture[unit] = softpipe_texture(texture); /* ptr, not struct */
+ pipe_texture_reference(pipe, &softpipe->texture[unit], texture);
- sp_tile_cache_set_texture(softpipe->tex_cache[unit], texture);
+ sp_tile_cache_set_texture(pipe, softpipe->tex_cache[unit], texture);
softpipe->dirty |= SP_NEW_TEXTURE;
}
diff --git a/src/gallium/drivers/softpipe/sp_state_surface.c b/src/gallium/drivers/softpipe/sp_state_surface.c
index e2c6893e9f..124b18b708 100644
--- a/src/gallium/drivers/softpipe/sp_state_surface.c
+++ b/src/gallium/drivers/softpipe/sp_state_surface.c
@@ -27,7 +27,7 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "p_inlines.h"
+#include "pipe/p_inlines.h"
#include "sp_context.h"
#include "sp_state.h"
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index c54e9d385c..43d5085895 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -332,6 +332,61 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
}
+/**
+ * For RECT textures / unnormalized texcoords
+ * Only a subset of wrap modes supported.
+ */
+static INLINE int
+nearest_texcoord_unnorm(unsigned wrapMode, float s, unsigned size)
+{
+ int i;
+ switch (wrapMode) {
+ case PIPE_TEX_WRAP_CLAMP:
+ i = ifloor(s);
+ return CLAMP(i, 0, size-1);
+ case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
+ /* fall-through */
+ case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
+ return ifloor( CLAMP(s, 0.5F, (float) size - 0.5F) );
+ default:
+ assert(0);
+ return 0;
+ }
+}
+
+
+/**
+ * For RECT textures / unnormalized texcoords.
+ * Only a subset of wrap modes supported.
+ */
+static INLINE void
+linear_texcoord_unnorm(unsigned wrapMode, float s, unsigned size,
+ int *i0, int *i1, float *a)
+{
+ switch (wrapMode) {
+ case PIPE_TEX_WRAP_CLAMP:
+ /* Not exactly what the spec says, but it matches NVIDIA output */
+ s = CLAMP(s - 0.5F, 0.0, (float) size - 1.0);
+ *i0 = ifloor(s);
+ *i1 = *i0 + 1;
+ break;
+ case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
+ /* fall-through */
+ case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
+ s = CLAMP(s, 0.5F, (float) size - 0.5F);
+ s -= 0.5F;
+ *i0 = ifloor(s);
+ *i1 = *i0 + 1;
+ if (*i1 > size - 1)
+ *i1 = size - 1;
+ break;
+ default:
+ assert(0);
+ }
+ *a = FRAC(s);
+}
+
+
static unsigned
choose_cube_face(float rx, float ry, float rz, float *newS, float *newT)
{
@@ -415,15 +470,15 @@ compute_lambda(struct tgsi_sampler *sampler,
{
float rho, lambda;
+ assert(sampler->state->normalized_coords);
+
assert(s);
{
float dsdx = s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT];
float dsdy = s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT];
dsdx = FABSF(dsdx);
dsdy = FABSF(dsdy);
- rho = MAX2(dsdx, dsdy);
- if (sampler->state->normalized_coords)
- rho *= sampler->texture->width[0];
+ rho = MAX2(dsdx, dsdy) * sampler->texture->width[0];
}
if (t) {
float dtdx = t[QUAD_BOTTOM_RIGHT] - t[QUAD_BOTTOM_LEFT];
@@ -431,9 +486,7 @@ compute_lambda(struct tgsi_sampler *sampler,
float max;
dtdx = FABSF(dtdx);
dtdy = FABSF(dtdy);
- max = MAX2(dtdx, dtdy);
- if (sampler->state->normalized_coords)
- max *= sampler->texture->height[0];
+ max = MAX2(dtdx, dtdy) * sampler->texture->height[0];
rho = MAX2(rho, max);
}
if (p) {
@@ -442,9 +495,7 @@ compute_lambda(struct tgsi_sampler *sampler,
float max;
dpdx = FABSF(dpdx);
dpdy = FABSF(dpdy);
- max = MAX2(dpdx, dpdy);
- if (sampler->state->normalized_coords)
- max *= sampler->texture->depth[0];
+ max = MAX2(dpdx, dpdy) * sampler->texture->depth[0];
rho = MAX2(rho, max);
}
@@ -628,13 +679,10 @@ sp_get_samples_2d_common(struct tgsi_sampler *sampler,
choose_mipmap_levels(sampler, s, t, p, lodbias,
&level0, &level1, &levelBlend, &imgFilter);
- if (sampler->state->normalized_coords) {
- width = sampler->texture->width[level0];
- height = sampler->texture->height[level0];
- }
- else {
- width = height = 1;
- }
+ assert(sampler->state->normalized_coords);
+
+ width = sampler->texture->width[level0];
+ height = sampler->texture->height[level0];
assert(width > 0);
@@ -765,14 +813,11 @@ sp_get_samples_3d(struct tgsi_sampler *sampler,
choose_mipmap_levels(sampler, s, t, p, lodbias,
&level0, &level1, &levelBlend, &imgFilter);
- if (sampler->state->normalized_coords) {
- width = sampler->texture->width[level0];
- height = sampler->texture->height[level0];
- depth = sampler->texture->depth[level0];
- }
- else {
- width = height = depth = 1;
- }
+ assert(sampler->state->normalized_coords);
+
+ width = sampler->texture->width[level0];
+ height = sampler->texture->height[level0];
+ depth = sampler->texture->depth[level0];
assert(width > 0);
assert(height > 0);
@@ -889,6 +934,73 @@ sp_get_samples_cube(struct tgsi_sampler *sampler,
}
+static void
+sp_get_samples_rect(struct tgsi_sampler *sampler,
+ const float s[QUAD_SIZE],
+ const float t[QUAD_SIZE],
+ const float p[QUAD_SIZE],
+ float lodbias,
+ float rgba[NUM_CHANNELS][QUAD_SIZE])
+{
+ //sp_get_samples_2d_common(sampler, s, t, p, lodbias, rgba, faces);
+ static const uint face = 0;
+ const uint compare_func = sampler->state->compare_func;
+ unsigned level0, level1, j, imgFilter;
+ int width, height;
+ float levelBlend;
+
+ choose_mipmap_levels(sampler, s, t, p, lodbias,
+ &level0, &level1, &levelBlend, &imgFilter);
+
+ /* texture RECTS cannot be mipmapped */
+ assert(level0 == level1);
+
+ width = sampler->texture->width[level0];
+ height = sampler->texture->height[level0];
+
+ assert(width > 0);
+
+ switch (imgFilter) {
+ case PIPE_TEX_FILTER_NEAREST:
+ for (j = 0; j < QUAD_SIZE; j++) {
+ int x = nearest_texcoord_unnorm(sampler->state->wrap_s, s[j], width);
+ int y = nearest_texcoord_unnorm(sampler->state->wrap_t, t[j], height);
+ get_texel(sampler, face, level0, x, y, 0, rgba, j);
+ if (sampler->state->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
+ shadow_compare(compare_func, rgba, p, j);
+ }
+ }
+ break;
+ case PIPE_TEX_FILTER_LINEAR:
+ for (j = 0; j < QUAD_SIZE; j++) {
+ float tx[4][4], a, b;
+ int x0, y0, x1, y1, c;
+ linear_texcoord_unnorm(sampler->state->wrap_s, s[j], width, &x0, &x1, &a);
+ linear_texcoord_unnorm(sampler->state->wrap_t, t[j], height, &y0, &y1, &b);
+ get_texel(sampler, face, level0, x0, y0, 0, tx, 0);
+ get_texel(sampler, face, level0, x1, y0, 0, tx, 1);
+ get_texel(sampler, face, level0, x0, y1, 0, tx, 2);
+ get_texel(sampler, face, level0, x1, y1, 0, tx, 3);
+ if (sampler->state->compare_mode == PIPE_TEX_COMPARE_R_TO_TEXTURE) {
+ shadow_compare(compare_func, tx, p, 0);
+ shadow_compare(compare_func, tx, p, 1);
+ shadow_compare(compare_func, tx, p, 2);
+ shadow_compare(compare_func, tx, p, 3);
+ }
+
+ for (c = 0; c < 4; c++) {
+ rgba[c][j] = lerp_2d(a, b, tx[c][0], tx[c][1], tx[c][2], tx[c][3]);
+ }
+ }
+ break;
+ default:
+ assert(0);
+ }
+}
+
+
+
+
/**
* Called via tgsi_sampler::get_samples()
* Use the sampler's state setting to get a filtered RGBA value
@@ -914,15 +1026,21 @@ sp_get_samples(struct tgsi_sampler *sampler,
switch (sampler->texture->target) {
case PIPE_TEXTURE_1D:
+ assert(sampler->state->normalized_coords);
sp_get_samples_1d(sampler, s, t, p, lodbias, rgba);
break;
case PIPE_TEXTURE_2D:
- sp_get_samples_2d(sampler, s, t, p, lodbias, rgba);
+ if (sampler->state->normalized_coords)
+ sp_get_samples_2d(sampler, s, t, p, lodbias, rgba);
+ else
+ sp_get_samples_rect(sampler, s, t, p, lodbias, rgba);
break;
case PIPE_TEXTURE_3D:
+ assert(sampler->state->normalized_coords);
sp_get_samples_3d(sampler, s, t, p, lodbias, rgba);
break;
case PIPE_TEXTURE_CUBE:
+ assert(sampler->state->normalized_coords);
sp_get_samples_cube(sampler, s, t, p, lodbias, rgba);
break;
default:
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index 6de7a9b543..6ba0f09e0a 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -39,6 +39,7 @@
#include "sp_context.h"
#include "sp_state.h"
#include "sp_texture.h"
+#include "sp_tile_cache.h"
/* Simple, maximally packed layout.
@@ -88,6 +89,7 @@ softpipe_texture_create(struct pipe_context *pipe,
return NULL;
spt->base = *templat;
+ spt->base.refcount = 1;
softpipe_texture_layout(spt);
@@ -99,6 +101,8 @@ softpipe_texture_create(struct pipe_context *pipe,
return NULL;
}
+ assert(spt->base.refcount == 1);
+
return &spt->base;
}
@@ -128,6 +132,20 @@ 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()
*/
diff --git a/src/gallium/drivers/softpipe/sp_texture.h b/src/gallium/drivers/softpipe/sp_texture.h
index fa646c0de9..50fc100427 100644
--- a/src/gallium/drivers/softpipe/sp_texture.h
+++ b/src/gallium/drivers/softpipe/sp_texture.h
@@ -62,6 +62,10 @@ softpipe_texture_create(struct pipe_context *pipe,
extern void
softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
+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,
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c
index dde3fabc81..da30dd6c48 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
@@ -212,14 +212,15 @@ sp_tile_cache_unmap_surfaces(struct softpipe_tile_cache *tc)
* Specify the texture to cache.
*/
void
-sp_tile_cache_set_texture(struct softpipe_tile_cache *tc,
+sp_tile_cache_set_texture(struct pipe_context *pipe,
+ struct softpipe_tile_cache *tc,
struct pipe_texture *texture)
{
uint i;
assert(!tc->surface);
- tc->texture = texture;
+ pipe_texture_reference(pipe, &tc->texture, texture);
if (tc->tex_surf_map) {
pipe_surface_unmap(tc->tex_surf);
@@ -358,30 +359,37 @@ sp_flush_tile_cache(struct softpipe_context *softpipe,
struct pipe_surface *ps = tc->surface;
int inuse = 0, pos;
- if (!ps || !ps->buffer)
- return;
-
- for (pos = 0; pos < NUM_ENTRIES; pos++) {
- struct softpipe_cached_tile *tile = tc->entries + pos;
- if (tile->x >= 0) {
- if (tc->depth_stencil) {
- pipe_put_tile_raw(pipe, ps,
- tile->x, tile->y, TILE_SIZE, TILE_SIZE,
- tile->data.depth32, 0/*STRIDE*/);
- }
- else {
- pipe_put_tile_rgba(pipe, ps,
- tile->x, tile->y, TILE_SIZE, TILE_SIZE,
- (float *) tile->data.color);
+ if (ps && ps->buffer) {
+ /* caching a drawing surface */
+ for (pos = 0; pos < NUM_ENTRIES; pos++) {
+ struct softpipe_cached_tile *tile = tc->entries + pos;
+ if (tile->x >= 0) {
+ if (tc->depth_stencil) {
+ pipe_put_tile_raw(pipe, ps,
+ tile->x, tile->y, TILE_SIZE, TILE_SIZE,
+ tile->data.depth32, 0/*STRIDE*/);
+ }
+ else {
+ pipe_put_tile_rgba(pipe, ps,
+ tile->x, tile->y, TILE_SIZE, TILE_SIZE,
+ (float *) tile->data.color);
+ }
+ tile->x = tile->y = -1; /* mark as empty */
+ inuse++;
}
- tile->x = tile->y = -1; /* mark as empty */
- inuse++;
}
- }
#if TILE_CLEAR_OPTIMIZATION
- sp_tile_cache_flush_clear(&softpipe->pipe, tc);
+ sp_tile_cache_flush_clear(&softpipe->pipe, tc);
#endif
+ }
+ else if (tc->texture) {
+ /* caching a texture, mark all entries as embpy */
+ for (pos = 0; pos < NUM_ENTRIES; pos++) {
+ tc->entries[pos].x = -1;
+ }
+ tc->tex_face = -1;
+ }
#if 0
debug_printf("flushed tiles in use: %d\n", inuse);
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.h b/src/gallium/drivers/softpipe/sp_tile_cache.h
index 7fd1081286..2631e29a3a 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.h
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.h
@@ -80,7 +80,8 @@ extern void
sp_tile_cache_unmap_surfaces(struct softpipe_tile_cache *tc);
extern void
-sp_tile_cache_set_texture(struct softpipe_tile_cache *tc,
+sp_tile_cache_set_texture(struct pipe_context *pipe,
+ struct softpipe_tile_cache *tc,
struct pipe_texture *texture);
extern void