summaryrefslogtreecommitdiff
path: root/src/gallium/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/cell/common.h5
-rw-r--r--src/gallium/drivers/cell/ppu/Makefile2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_batch.c56
-rw-r--r--src/gallium/drivers/cell/ppu/cell_batch.h3
-rw-r--r--src/gallium/drivers/cell/ppu/cell_clear.c36
-rw-r--r--src/gallium/drivers/cell/ppu/cell_context.c46
-rw-r--r--src/gallium/drivers/cell/ppu/cell_context.h29
-rw-r--r--src/gallium/drivers/cell/ppu/cell_draw_arrays.c73
-rw-r--r--src/gallium/drivers/cell/ppu/cell_draw_arrays.h10
-rw-r--r--src/gallium/drivers/cell/ppu/cell_flush.c14
-rw-r--r--src/gallium/drivers/cell/ppu/cell_flush.h2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_pipe_state.c31
-rw-r--r--src/gallium/drivers/cell/ppu/cell_render.c2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_screen.c2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_spu.c28
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state.h16
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_derived.c31
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_emit.c34
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_shader.c32
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_vertex.c12
-rw-r--r--src/gallium/drivers/cell/ppu/cell_surface.c99
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.c143
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.h1
-rw-r--r--src/gallium/drivers/cell/ppu/cell_vbuf.c13
-rw-r--r--src/gallium/drivers/cell/ppu/cell_vertex_fetch.c4
-rw-r--r--src/gallium/drivers/cell/ppu/cell_vertex_shader.c7
-rw-r--r--src/gallium/drivers/cell/ppu/cell_winsys.c2
-rw-r--r--src/gallium/drivers/cell/spu/Makefile2
-rw-r--r--src/gallium/drivers/cell/spu/spu_exec.c151
-rw-r--r--src/gallium/drivers/cell/spu/spu_exec.h2
-rw-r--r--src/gallium/drivers/cell/spu/spu_main.c138
-rw-r--r--src/gallium/drivers/cell/spu/spu_main.h8
-rw-r--r--src/gallium/drivers/cell/spu/spu_per_fragment_op.c4
-rw-r--r--src/gallium/drivers/cell/spu/spu_render.c2
-rw-r--r--src/gallium/drivers/cell/spu/spu_tile.c6
-rw-r--r--src/gallium/drivers/cell/spu/spu_tri.c2
-rw-r--r--src/gallium/drivers/cell/spu/spu_util.c24
-rw-r--r--src/gallium/drivers/cell/spu/spu_vertex_fetch.c3
-rw-r--r--src/gallium/drivers/cell/spu/spu_vertex_shader.c29
-rw-r--r--src/gallium/drivers/failover/fo_context.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_context.c13
-rw-r--r--src/gallium/drivers/i915simple/i915_debug_fp.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_fpc.h1
-rw-r--r--src/gallium/drivers/i915simple/i915_fpc_emit.c1
-rw-r--r--src/gallium/drivers/i915simple/i915_fpc_translate.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_prim_emit.c4
-rw-r--r--src/gallium/drivers/i915simple/i915_prim_vbuf.c41
-rw-r--r--src/gallium/drivers/i915simple/i915_screen.c7
-rw-r--r--src/gallium/drivers/i915simple/i915_state.c3
-rw-r--r--src/gallium/drivers/i915simple/i915_state_derived.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_state_dynamic.c4
-rw-r--r--src/gallium/drivers/i915simple/i915_state_immediate.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_state_sampler.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_surface.c4
-rw-r--r--src/gallium/drivers/i915simple/i915_texture.c23
-rw-r--r--src/gallium/drivers/i965simple/brw_cc.c6
-rw-r--r--src/gallium/drivers/i965simple/brw_clip_state.c3
-rw-r--r--src/gallium/drivers/i965simple/brw_context.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_curbe.c3
-rw-r--r--src/gallium/drivers/i965simple/brw_draw_upload.c1
-rw-r--r--src/gallium/drivers/i965simple/brw_gs_state.c3
-rw-r--r--src/gallium/drivers/i965simple/brw_screen.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_sf_state.c5
-rw-r--r--src/gallium/drivers/i965simple/brw_shader_info.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_state.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_state_batch.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_state_cache.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_state_pool.c13
-rw-r--r--src/gallium/drivers/i965simple/brw_state_upload.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_surface.c4
-rw-r--r--src/gallium/drivers/i965simple/brw_tex_layout.c20
-rw-r--r--src/gallium/drivers/i965simple/brw_vs_state.c3
-rw-r--r--src/gallium/drivers/i965simple/brw_wm.c2
-rw-r--r--src/gallium/drivers/i965simple/brw_wm_decl.c3
-rw-r--r--src/gallium/drivers/i965simple/brw_wm_glsl.c3
-rw-r--r--src/gallium/drivers/i965simple/brw_wm_sampler_state.c3
-rw-r--r--src/gallium/drivers/i965simple/brw_wm_state.c3
-rw-r--r--src/gallium/drivers/softpipe/sp_clear.c31
-rw-r--r--src/gallium/drivers/softpipe/sp_context.c56
-rw-r--r--src/gallium/drivers/softpipe/sp_context.h10
-rw-r--r--src/gallium/drivers/softpipe/sp_draw_arrays.c9
-rw-r--r--src/gallium/drivers/softpipe/sp_flush.c13
-rw-r--r--src/gallium/drivers/softpipe/sp_fs_exec.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_fs_llvm.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_fs_sse.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_headers.h29
-rw-r--r--src/gallium/drivers/softpipe/sp_prim_setup.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_prim_vbuf.c1
-rw-r--r--src/gallium/drivers/softpipe/sp_quad.c102
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_alpha_test.c9
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_blend.c45
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_bufloop.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_colormask.c11
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_coverage.c16
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_depth_test.c54
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_earlyz.c14
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_fs.c25
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_occlusion.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_output.c12
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_stencil.c46
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_stipple.c24
-rw-r--r--src/gallium/drivers/softpipe/sp_query.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_screen.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_setup.c436
-rw-r--r--src/gallium/drivers/softpipe/sp_state_blend.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_state_derived.c3
-rw-r--r--src/gallium/drivers/softpipe/sp_state_fs.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_state_rasterizer.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_state_sampler.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_surface.c121
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.c77
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c13
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.c4
-rw-r--r--src/gallium/drivers/trace/README53
-rw-r--r--src/gallium/drivers/trace/SConscript10
-rw-r--r--src/gallium/drivers/trace/tr_context.c596
-rw-r--r--src/gallium/drivers/trace/tr_context.h13
-rw-r--r--src/gallium/drivers/trace/tr_dump.c349
-rw-r--r--src/gallium/drivers/trace/tr_dump.h126
-rw-r--r--src/gallium/drivers/trace/tr_screen.c329
-rw-r--r--src/gallium/drivers/trace/tr_screen.h23
-rw-r--r--src/gallium/drivers/trace/tr_state.c519
-rw-r--r--src/gallium/drivers/trace/tr_state.h59
-rw-r--r--src/gallium/drivers/trace/tr_stream.h52
-rw-r--r--src/gallium/drivers/trace/tr_texture.c112
-rw-r--r--src/gallium/drivers/trace/tr_texture.h (renamed from src/gallium/drivers/trace/tr_stream.c)101
-rw-r--r--src/gallium/drivers/trace/tr_winsys.c265
-rw-r--r--src/gallium/drivers/trace/tr_winsys.h16
128 files changed, 2941 insertions, 2181 deletions
diff --git a/src/gallium/drivers/cell/common.h b/src/gallium/drivers/cell/common.h
index f430e88b9c..c0ca201e1d 100644
--- a/src/gallium/drivers/cell/common.h
+++ b/src/gallium/drivers/cell/common.h
@@ -34,7 +34,6 @@
#define CELL_COMMON_H
#include "pipe/p_compiler.h"
-#include "pipe/p_util.h"
#include "pipe/p_format.h"
#include "pipe/p_state.h"
@@ -107,6 +106,9 @@
#define CELL_BUFFER_STATUS_USED 20
+#define CELL_DEBUG_CHECKER (1 << 0)
+#define CELL_DEBUG_SYNC (1 << 1)
+
/**
*/
@@ -264,6 +266,7 @@ struct cell_init_info
{
unsigned id;
unsigned num_spus;
+ unsigned debug_flags; /**< mask of CELL_DEBUG_x flags */
struct cell_command *cmd;
/** Buffers for command batches, vertex/index data */
diff --git a/src/gallium/drivers/cell/ppu/Makefile b/src/gallium/drivers/cell/ppu/Makefile
index 0389a9554c..25473e200c 100644
--- a/src/gallium/drivers/cell/ppu/Makefile
+++ b/src/gallium/drivers/cell/ppu/Makefile
@@ -5,7 +5,7 @@
TOP = ../../../../..
-include $(TOP)/configs/linux-cell
+include $(TOP)/configs/current
# This is the "top-level" cell PPU driver code, will get pulled into libGL.so
diff --git a/src/gallium/drivers/cell/ppu/cell_batch.c b/src/gallium/drivers/cell/ppu/cell_batch.c
index f45e5f25b6..16882c0129 100644
--- a/src/gallium/drivers/cell/ppu/cell_batch.c
+++ b/src/gallium/drivers/cell/ppu/cell_batch.c
@@ -32,6 +32,13 @@
+/**
+ * Search the buffer pool for an empty/free buffer and return its index.
+ * Buffers are used for storing vertex data, state and commands which
+ * will be sent to the SPUs.
+ * If no empty buffers are available, wait for one.
+ * \return buffer index in [0, CELL_NUM_BUFFERS-1]
+ */
uint
cell_get_empty_buffer(struct cell_context *cell)
{
@@ -74,6 +81,11 @@ cell_get_empty_buffer(struct cell_context *cell)
}
+/**
+ * Flush the current batch buffer to the SPUs.
+ * An empty buffer will be found and set as the new current batch buffer
+ * for subsequent commands/data.
+ */
void
cell_batch_flush(struct cell_context *cell)
{
@@ -93,11 +105,11 @@ cell_batch_flush(struct cell_context *cell)
/*
printf("cell_batch_dispatch: buf %u at %p, size %u\n",
- batch, &cell->batch_buffer[batch][0], size);
+ batch, &cell->buffer[batch][0], size);
*/
/*
- * Build "BATCH" command and sent to all SPUs.
+ * Build "BATCH" command and send to all SPUs.
*/
cmd_word = CELL_CMD_BATCH | (batch << 8) | (size << 16);
@@ -120,6 +132,9 @@ cell_batch_flush(struct cell_context *cell)
}
+/**
+ * Return the number of bytes free in the current batch buffer.
+ */
uint
cell_batch_free_space(const struct cell_context *cell)
{
@@ -129,7 +144,9 @@ cell_batch_free_space(const struct cell_context *cell)
/**
- * Append data to current batch.
+ * Append data to the current batch buffer.
+ * \param data address of block of bytes to append
+ * \param bytes size of block of bytes
*/
void
cell_batch_append(struct cell_context *cell, const void *data, uint bytes)
@@ -165,6 +182,10 @@ cell_batch_append(struct cell_context *cell, const void *data, uint bytes)
}
+/**
+ * Allocate space in the current batch buffer for 'bytes' space.
+ * \return address in batch buffer to put data
+ */
void *
cell_batch_alloc(struct cell_context *cell, uint bytes)
{
@@ -172,6 +193,10 @@ cell_batch_alloc(struct cell_context *cell, uint bytes)
}
+/**
+ * Same as \sa cell_batch_alloc, but return an address at a particular
+ * alignment.
+ */
void *
cell_batch_alloc_aligned(struct cell_context *cell, uint bytes,
uint alignment)
@@ -215,3 +240,28 @@ cell_batch_alloc_aligned(struct cell_context *cell, uint bytes,
return pos;
}
+
+
+/**
+ * One-time init of batch buffers.
+ */
+void
+cell_init_batch_buffers(struct cell_context *cell)
+{
+ uint spu, buf;
+
+ /* init command, vertex/index buffer info */
+ for (buf = 0; buf < CELL_NUM_BUFFERS; buf++) {
+ cell->buffer_size[buf] = 0;
+
+ /* init batch buffer status values,
+ * mark 0th buffer as used, rest as free.
+ */
+ for (spu = 0; spu < cell->num_spus; spu++) {
+ if (buf == 0)
+ cell->buffer_status[spu][buf][0] = CELL_BUFFER_STATUS_USED;
+ else
+ cell->buffer_status[spu][buf][0] = CELL_BUFFER_STATUS_FREE;
+ }
+ }
+}
diff --git a/src/gallium/drivers/cell/ppu/cell_batch.h b/src/gallium/drivers/cell/ppu/cell_batch.h
index a6eee0a8b1..f74dd60079 100644
--- a/src/gallium/drivers/cell/ppu/cell_batch.h
+++ b/src/gallium/drivers/cell/ppu/cell_batch.h
@@ -54,5 +54,8 @@ extern void *
cell_batch_alloc_aligned(struct cell_context *cell, uint bytes,
uint alignment);
+extern void
+cell_init_batch_buffers(struct cell_context *cell);
+
#endif /* CELL_BATCH_H */
diff --git a/src/gallium/drivers/cell/ppu/cell_clear.c b/src/gallium/drivers/cell/ppu/cell_clear.c
index 3ffe09add6..c9c0c721bb 100644
--- a/src/gallium/drivers/cell/ppu/cell_clear.c
+++ b/src/gallium/drivers/cell/ppu/cell_clear.c
@@ -34,7 +34,8 @@
#include <assert.h>
#include <stdint.h>
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
+#include "util/u_pack_color.h"
#include "cell/common.h"
#include "cell_clear.h"
#include "cell_context.h"
@@ -44,10 +45,32 @@
#include "cell_state.h"
+/**
+ * Convert packed pixel from one format to another.
+ */
+static unsigned
+convert_color(enum pipe_format srcFormat, unsigned srcColor,
+ enum pipe_format dstFormat)
+{
+ ubyte r, g, b, a;
+ unsigned dstColor;
+
+ util_unpack_color_ub(srcFormat, &srcColor, &r, &g, &b, &a);
+ util_pack_color_ub(r, g, b, a, dstFormat, &dstColor);
+
+ return dstColor;
+}
+
+
+
+/**
+ * Called via pipe->clear()
+ */
void
cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps,
unsigned clearValue)
{
+ struct pipe_screen *screen = pipe->screen;
struct cell_context *cell = cell_context(pipe);
uint surfIndex;
@@ -56,16 +79,25 @@ cell_clear_surface(struct pipe_context *pipe, struct pipe_surface *ps,
if (!cell->cbuf_map[0])
- cell->cbuf_map[0] = pipe_surface_map(ps);
+ cell->cbuf_map[0] = screen->surface_map(screen, ps,
+ PIPE_BUFFER_USAGE_GPU_WRITE);
if (ps == cell->framebuffer.zsbuf) {
+ /* clear z/stencil buffer */
surfIndex = 1;
}
else {
+ /* clear color buffer */
surfIndex = 0;
+
+ if (ps->format != PIPE_FORMAT_A8R8G8B8_UNORM) {
+ clearValue = convert_color(PIPE_FORMAT_A8R8G8B8_UNORM, clearValue,
+ ps->format);
+ }
}
+ /* Build a CLEAR command and place it in the current batch buffer */
{
struct cell_command_clear_surface *clr
= (struct cell_command_clear_surface *)
diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c
index 12eb5aa254..71f1a3049d 100644
--- a/src/gallium/drivers/cell/ppu/cell_context.c
+++ b/src/gallium/drivers/cell/ppu/cell_context.c
@@ -35,7 +35,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_format.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_winsys.h"
#include "pipe/p_screen.h"
@@ -43,11 +43,11 @@
#include "draw/draw_private.h"
#include "cell/common.h"
+#include "cell_batch.h"
#include "cell_clear.h"
#include "cell_context.h"
#include "cell_draw_arrays.h"
#include "cell_flush.h"
-#include "cell_render.h"
#include "cell_state.h"
#include "cell_surface.h"
#include "cell_spu.h"
@@ -73,22 +73,32 @@ cell_draw_create(struct cell_context *cell)
{
struct draw_context *draw = draw_create();
+#if 0 /* broken */
if (getenv("GALLIUM_CELL_VS")) {
/* plug in SPU-based vertex transformation code */
draw->shader_queue_flush = cell_vertex_shader_queue_flush;
draw->driver_private = cell;
}
+#endif
return draw;
}
+#ifdef DEBUG
+static const struct debug_named_value cell_debug_flags[] = {
+ {"checker", CELL_DEBUG_CHECKER},/**< modulate tile clear color by SPU ID */
+ {"sync", CELL_DEBUG_SYNC}, /**< SPUs do synchronous DMA */
+ {NULL, 0}
+};
+#endif
+
+
struct pipe_context *
cell_create_context(struct pipe_screen *screen,
struct cell_winsys *cws)
{
struct cell_context *cell;
- uint spu, buf;
/* some fields need to be 16-byte aligned, so align the whole object */
cell = (struct cell_context*) align_malloc(sizeof(struct cell_context), 16);
@@ -102,13 +112,6 @@ cell_create_context(struct pipe_screen *screen,
cell->pipe.screen = screen;
cell->pipe.destroy = cell_destroy_context;
- /* state setters */
- cell->pipe.set_vertex_buffers = cell_set_vertex_buffers;
- cell->pipe.set_vertex_elements = cell_set_vertex_elements;
-
- cell->pipe.draw_arrays = cell_draw_arrays;
- cell->pipe.draw_elements = cell_draw_elements;
-
cell->pipe.clear = cell_clear_surface;
cell->pipe.flush = cell_flush;
@@ -118,20 +121,28 @@ cell_create_context(struct pipe_screen *screen,
cell->pipe.wait_query = cell_wait_query;
#endif
+ cell_init_draw_functions(cell);
cell_init_state_functions(cell);
cell_init_shader_functions(cell);
cell_init_surface_functions(cell);
cell_init_texture_functions(cell);
+ cell_init_vertex_functions(cell);
cell->draw = cell_draw_create(cell);
cell_init_vbuf(cell);
+
draw_set_rasterize_stage(cell->draw, cell->vbuf);
/* convert all points/lines to tris for the time being */
draw_wide_point_threshold(cell->draw, 0.0);
draw_wide_line_threshold(cell->draw, 0.0);
+ /* get env vars or read config file to get debug flags */
+ cell->debug_flags = debug_get_flags_option("CELL_DEBUG",
+ cell_debug_flags,
+ 0 );
+
/*
* SPU stuff
*/
@@ -142,20 +153,7 @@ cell_create_context(struct pipe_screen *screen,
cell_start_spus(cell);
- /* init command, vertex/index buffer info */
- for (buf = 0; buf < CELL_NUM_BUFFERS; buf++) {
- cell->buffer_size[buf] = 0;
-
- /* init batch buffer status values,
- * mark 0th buffer as used, rest as free.
- */
- for (spu = 0; spu < cell->num_spus; spu++) {
- if (buf == 0)
- cell->buffer_status[spu][buf][0] = CELL_BUFFER_STATUS_USED;
- else
- cell->buffer_status[spu][buf][0] = CELL_BUFFER_STATUS_FREE;
- }
- }
+ cell_init_batch_buffers(cell);
return &cell->pipe;
}
diff --git a/src/gallium/drivers/cell/ppu/cell_context.h b/src/gallium/drivers/cell/ppu/cell_context.h
index f1d1ca89a9..8cec9f45b2 100644
--- a/src/gallium/drivers/cell/ppu/cell_context.h
+++ b/src/gallium/drivers/cell/ppu/cell_context.h
@@ -39,8 +39,13 @@
#include "rtasm/rtasm_ppc_spe.h"
#include "tgsi/tgsi_scan.h"
+
struct cell_vbuf_render;
+
+/**
+ * Cell vertex shader state, subclass of pipe_shader_state.
+ */
struct cell_vertex_shader_state
{
struct pipe_shader_state shader;
@@ -49,6 +54,9 @@ struct cell_vertex_shader_state
};
+/**
+ * Cell fragment shader state, subclass of pipe_shader_state.
+ */
struct cell_fragment_shader_state
{
struct pipe_shader_state shader;
@@ -57,7 +65,11 @@ struct cell_fragment_shader_state
};
-struct cell_blend_state {
+/**
+ * Cell blend state atom, subclass of pipe_blend_state.
+ */
+struct cell_blend_state
+{
struct pipe_blend_state base;
/**
@@ -67,17 +79,24 @@ struct cell_blend_state {
};
-struct cell_depth_stencil_alpha_state {
- struct pipe_depth_stencil_alpha_state base;
+/**
+ * Cell depth/stencil/alpha state atom, subclass of
+ * pipe_depth_stencil_alpha_state.
+ */
+struct cell_depth_stencil_alpha_state
+{
+ struct pipe_depth_stencil_alpha_state base;
/**
* Generated code to perform alpha, stencil, and depth testing on the SPE
*/
struct spe_function code;
-
};
+/**
+ * Per-context state, subclass of pipe_context.
+ */
struct cell_context
{
struct pipe_context pipe;
@@ -144,6 +163,8 @@ struct cell_context
struct spe_function attrib_fetch;
unsigned attrib_fetch_offsets[PIPE_MAX_ATTRIBS];
+
+ unsigned debug_flags;
};
diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
index 6e08cf6fe8..880d535320 100644
--- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
+++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.c
@@ -34,6 +34,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_context.h"
#include "pipe/p_winsys.h"
+#include "pipe/p_inlines.h"
#include "cell_context.h"
#include "cell_draw_arrays.h"
@@ -59,7 +60,8 @@ cell_map_constant_buffers(struct cell_context *sp)
}
draw_set_mapped_constant_buffer(sp->draw,
- sp->mapped_constants[PIPE_SHADER_VERTEX]);
+ sp->mapped_constants[PIPE_SHADER_VERTEX],
+ sp->constants[PIPE_SHADER_VERTEX].size);
}
static void
@@ -75,14 +77,6 @@ cell_unmap_constant_buffers(struct cell_context *sp)
}
-boolean
-cell_draw_arrays(struct pipe_context *pipe, unsigned mode,
- unsigned start, unsigned count)
-{
- return cell_draw_elements(pipe, NULL, 0, mode, start, count);
-}
-
-
/**
* Draw vertex arrays, with optional indexing.
@@ -91,11 +85,13 @@ cell_draw_arrays(struct pipe_context *pipe, unsigned mode,
*
* XXX should the element buffer be specified/bound with a separate function?
*/
-boolean
-cell_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned mode, unsigned start, unsigned count)
+static boolean
+cell_draw_range_elements(struct pipe_context *pipe,
+ struct pipe_buffer *indexBuffer,
+ unsigned indexSize,
+ unsigned min_index,
+ unsigned max_index,
+ unsigned mode, unsigned start, unsigned count)
{
struct cell_context *sp = cell_context(pipe);
struct draw_context *draw = sp->draw;
@@ -113,7 +109,7 @@ cell_draw_elements(struct pipe_context *pipe,
* Map vertex buffers
*/
for (i = 0; i < sp->num_vertex_buffers; i++) {
- void *buf = pipe->winsys->buffer_map(pipe->winsys,
+ void *buf = pipe_buffer_map(pipe->screen,
sp->vertex_buffer[i].buffer,
PIPE_BUFFER_USAGE_CPU_READ);
cell_flush_buffer_range(sp, buf, sp->vertex_buffer[i].buffer->size);
@@ -121,7 +117,7 @@ cell_draw_elements(struct pipe_context *pipe,
}
/* Map index buffer, if present */
if (indexBuffer) {
- void *mapped_indexes = pipe->winsys->buffer_map(pipe->winsys,
+ void *mapped_indexes = pipe_buffer_map(pipe->screen,
indexBuffer,
PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_element_buffer(draw, indexSize, mapped_indexes);
@@ -140,11 +136,11 @@ cell_draw_elements(struct pipe_context *pipe,
*/
for (i = 0; i < sp->num_vertex_buffers; i++) {
draw_set_mapped_vertex_buffer(draw, i, NULL);
- pipe->winsys->buffer_unmap(pipe->winsys, sp->vertex_buffer[i].buffer);
+ pipe_buffer_unmap(pipe->screen, sp->vertex_buffer[i].buffer);
}
if (indexBuffer) {
draw_set_mapped_element_buffer(draw, 0, NULL);
- pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
+ pipe_buffer_unmap(pipe->screen, indexBuffer);
}
/* Note: leave drawing surfaces mapped */
@@ -152,3 +148,44 @@ cell_draw_elements(struct pipe_context *pipe,
return TRUE;
}
+
+
+static boolean
+cell_draw_elements(struct pipe_context *pipe,
+ struct pipe_buffer *indexBuffer,
+ unsigned indexSize,
+ unsigned mode, unsigned start, unsigned count)
+{
+ return cell_draw_range_elements( pipe, indexBuffer,
+ indexSize,
+ 0, 0xffffffff,
+ mode, start, count );
+}
+
+
+static boolean
+cell_draw_arrays(struct pipe_context *pipe, unsigned mode,
+ unsigned start, unsigned count)
+{
+ return cell_draw_elements(pipe, NULL, 0, mode, start, count);
+}
+
+
+static void
+cell_set_edgeflags(struct pipe_context *pipe, const unsigned *edgeflags)
+{
+ struct cell_context *cell = cell_context(pipe);
+ draw_set_edgeflags(cell->draw, edgeflags);
+}
+
+
+
+void
+cell_init_draw_functions(struct cell_context *cell)
+{
+ cell->pipe.draw_arrays = cell_draw_arrays;
+ cell->pipe.draw_elements = cell_draw_elements;
+ cell->pipe.draw_range_elements = cell_draw_range_elements;
+ cell->pipe.set_edgeflags = cell_set_edgeflags;
+}
+
diff --git a/src/gallium/drivers/cell/ppu/cell_draw_arrays.h b/src/gallium/drivers/cell/ppu/cell_draw_arrays.h
index d5df4aa05f..148873aa67 100644
--- a/src/gallium/drivers/cell/ppu/cell_draw_arrays.h
+++ b/src/gallium/drivers/cell/ppu/cell_draw_arrays.h
@@ -29,14 +29,8 @@
#define CELL_DRAW_ARRAYS_H
-boolean cell_draw_arrays(struct pipe_context *pipe, unsigned mode,
- unsigned start, unsigned count);
-
-boolean cell_draw_elements(struct pipe_context *pipe,
- struct pipe_buffer *indexBuffer,
- unsigned indexSize,
- unsigned mode, unsigned start, unsigned count);
-
+extern void
+cell_init_draw_functions(struct cell_context *cell);
#endif /* CELL_DRAW_ARRAYS_H */
diff --git a/src/gallium/drivers/cell/ppu/cell_flush.c b/src/gallium/drivers/cell/ppu/cell_flush.c
index 3aaf3de668..6596b72010 100644
--- a/src/gallium/drivers/cell/ppu/cell_flush.c
+++ b/src/gallium/drivers/cell/ppu/cell_flush.c
@@ -34,6 +34,9 @@
#include "draw/draw_context.h"
+/**
+ * Called via pipe->flush()
+ */
void
cell_flush(struct pipe_context *pipe, unsigned flags,
struct pipe_fence_handle **fence)
@@ -50,16 +53,19 @@ cell_flush(struct pipe_context *pipe, unsigned flags,
flags |= CELL_FLUSH_WAIT;
draw_flush( cell->draw );
- cell_flush_int(pipe, flags);
+ cell_flush_int(cell, flags);
}
-/** internal flush */
+/**
+ * Cell internal flush function. Send the current batch buffer to all SPUs.
+ * If flags & CELL_FLUSH_WAIT, do not return until the SPUs are idle.
+ * \param flags bitmask of flags CELL_FLUSH_WAIT, or zero
+ */
void
-cell_flush_int(struct pipe_context *pipe, unsigned flags)
+cell_flush_int(struct cell_context *cell, unsigned flags)
{
static boolean flushing = FALSE; /* recursion catcher */
- struct cell_context *cell = cell_context(pipe);
uint i;
ASSERT(!flushing);
diff --git a/src/gallium/drivers/cell/ppu/cell_flush.h b/src/gallium/drivers/cell/ppu/cell_flush.h
index 8f0645c429..509ae6239a 100644
--- a/src/gallium/drivers/cell/ppu/cell_flush.h
+++ b/src/gallium/drivers/cell/ppu/cell_flush.h
@@ -36,7 +36,7 @@ cell_flush(struct pipe_context *pipe, unsigned flags,
struct pipe_fence_handle **fence);
extern void
-cell_flush_int(struct pipe_context *pipe, unsigned flags);
+cell_flush_int(struct cell_context *cell, unsigned flags);
extern void
cell_flush_buffer_range(struct cell_context *cell, void *ptr,
diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
index 67b87f16d7..e04cf5f274 100644
--- a/src/gallium/drivers/cell/ppu/cell_pipe_state.c
+++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
@@ -30,10 +30,11 @@
* Brian Paul
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "draw/draw_context.h"
#include "cell_context.h"
+#include "cell_flush.h"
#include "cell_state.h"
#include "cell_texture.h"
#include "cell_state_per_fragment.h"
@@ -130,8 +131,9 @@ cell_delete_depth_stencil_alpha_state(struct pipe_context *pipe, void *depth)
}
-static void cell_set_clip_state( struct pipe_context *pipe,
- const struct pipe_clip_state *clip )
+static void
+cell_set_clip_state(struct pipe_context *pipe,
+ const struct pipe_clip_state *clip)
{
struct cell_context *cell = cell_context(pipe);
@@ -294,6 +296,8 @@ cell_set_framebuffer_state(struct pipe_context *pipe,
struct pipe_surface *csurf = fb->cbufs[0];
struct pipe_surface *zsurf = fb->zsbuf;
uint i;
+ uint flags = (PIPE_BUFFER_USAGE_GPU_WRITE |
+ PIPE_BUFFER_USAGE_GPU_READ);
/* unmap old surfaces */
for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
@@ -308,15 +312,28 @@ cell_set_framebuffer_state(struct pipe_context *pipe,
cell->zsbuf_map = NULL;
}
- /* update my state */
- cell->framebuffer = *fb;
+ /* Finish any pending rendering to the current surface before
+ * installing a new surface!
+ */
+ cell_flush_int(cell, CELL_FLUSH_WAIT);
+
+ /* update my state
+ * (this is also where old surfaces will finally get freed)
+ */
+ cell->framebuffer.width = fb->width;
+ cell->framebuffer.height = fb->height;
+ cell->framebuffer.num_cbufs = fb->num_cbufs;
+ for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
+ pipe_surface_reference(&cell->framebuffer.cbufs[i], fb->cbufs[i]);
+ }
+ pipe_surface_reference(&cell->framebuffer.zsbuf, fb->zsbuf);
/* map new surfaces */
if (csurf)
- cell->cbuf_map[0] = pipe_surface_map(csurf);
+ cell->cbuf_map[0] = pipe_surface_map(csurf, flags);
if (zsurf)
- cell->zsbuf_map = pipe_surface_map(zsurf);
+ cell->zsbuf_map = pipe_surface_map(zsurf, flags);
cell->dirty |= CELL_NEW_FRAMEBUFFER;
}
diff --git a/src/gallium/drivers/cell/ppu/cell_render.c b/src/gallium/drivers/cell/ppu/cell_render.c
index b663b37622..dd25ae880e 100644
--- a/src/gallium/drivers/cell/ppu/cell_render.c
+++ b/src/gallium/drivers/cell/ppu/cell_render.c
@@ -33,7 +33,7 @@
#include "cell_context.h"
#include "cell_render.h"
#include "cell_spu.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "draw/draw_private.h"
diff --git a/src/gallium/drivers/cell/ppu/cell_screen.c b/src/gallium/drivers/cell/ppu/cell_screen.c
index 2bf441a0c5..139b3719b6 100644
--- a/src/gallium/drivers/cell/ppu/cell_screen.c
+++ b/src/gallium/drivers/cell/ppu/cell_screen.c
@@ -26,7 +26,7 @@
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_winsys.h"
#include "pipe/p_defines.h"
#include "pipe/p_screen.h"
diff --git a/src/gallium/drivers/cell/ppu/cell_spu.c b/src/gallium/drivers/cell/ppu/cell_spu.c
index 973c0b1aa1..9508227e29 100644
--- a/src/gallium/drivers/cell/ppu/cell_spu.c
+++ b/src/gallium/drivers/cell/ppu/cell_spu.c
@@ -26,6 +26,11 @@
**************************************************************************/
+/**
+ * Utility/wrappers for communicating with the SPUs.
+ */
+
+
#include <pthread.h>
#include "cell_spu.h"
@@ -40,6 +45,9 @@ helpful headers:
*/
+/**
+ * Cell/SPU info that's not per-context.
+ */
struct cell_global_info cell_global;
@@ -74,7 +82,11 @@ wait_mbox_message(spe_context_ptr_t ctx)
}
-static void *cell_thread_function(void *arg)
+/**
+ * Called by pthread_create() to spawn an SPU thread.
+ */
+static void *
+cell_thread_function(void *arg)
{
struct cell_init_info *init = (struct cell_init_info *) arg;
unsigned entry = SPE_DEFAULT_ENTRY;
@@ -92,7 +104,10 @@ static void *cell_thread_function(void *arg)
/**
- * Create the SPU threads
+ * Create the SPU threads. This is done once during driver initialization.
+ * This involves setting the the "init" message which is sent to each SPU.
+ * The init message specifies an SPU id, total number of SPUs, location
+ * and number of batch buffers, etc.
*/
void
cell_start_spus(struct cell_context *cell)
@@ -100,7 +115,6 @@ cell_start_spus(struct cell_context *cell)
static boolean one_time_init = FALSE;
uint i, j;
-
if (one_time_init) {
fprintf(stderr, "PPU: Multiple rendering contexts not yet supported "
"on Cell.\n");
@@ -120,6 +134,7 @@ cell_start_spus(struct cell_context *cell)
for (i = 0; i < cell->num_spus; i++) {
cell_global.inits[i].id = i;
cell_global.inits[i].num_spus = cell->num_spus;
+ cell_global.inits[i].debug_flags = cell->debug_flags;
cell_global.inits[i].cmd = &cell_global.command[i];
for (j = 0; j < CELL_NUM_BUFFERS; j++) {
cell_global.inits[i].buffers[j] = cell->buffer[j];
@@ -137,14 +152,17 @@ cell_start_spus(struct cell_context *cell)
exit(1);
}
- pthread_create(&cell_global.spe_threads[i], NULL, &cell_thread_function,
- &cell_global.inits[i]);
+ pthread_create(&cell_global.spe_threads[i], /* returned thread handle */
+ NULL, /* pthread attribs */
+ &cell_thread_function, /* start routine */
+ &cell_global.inits[i]); /* thread argument */
}
}
/**
* Tell all the SPUs to stop/exit.
+ * This is done when the driver's exiting / cleaning up.
*/
void
cell_spu_exit(struct cell_context *cell)
diff --git a/src/gallium/drivers/cell/ppu/cell_state.h b/src/gallium/drivers/cell/ppu/cell_state.h
index 82580ea35a..a7771a55a3 100644
--- a/src/gallium/drivers/cell/ppu/cell_state.h
+++ b/src/gallium/drivers/cell/ppu/cell_state.h
@@ -48,19 +48,17 @@
#define CELL_NEW_VERTEX_INFO 0x8000
-void cell_set_vertex_elements(struct pipe_context *,
- unsigned count,
- const struct pipe_vertex_element *);
+extern void
+cell_update_derived( struct cell_context *softpipe );
-void cell_set_vertex_buffers(struct pipe_context *,
- unsigned count,
- const struct pipe_vertex_buffer *);
-void cell_update_derived( struct cell_context *softpipe );
+extern void
+cell_init_shader_functions(struct cell_context *cell);
-void
-cell_init_shader_functions(struct cell_context *cell);
+extern void
+cell_init_vertex_functions(struct cell_context *cell);
+
#endif /* CELL_STATE_H */
diff --git a/src/gallium/drivers/cell/ppu/cell_state_derived.c b/src/gallium/drivers/cell/ppu/cell_state_derived.c
index 5480534ad9..efc4f78364 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_derived.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_derived.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "draw/draw_context.h"
#include "draw/draw_vertex.h"
@@ -35,21 +35,6 @@
#include "cell_state_emit.h"
-static int
-find_vs_output(const struct cell_vertex_shader_state *vs,
- uint semantic_name,
- uint semantic_index)
-{
- uint i;
- for (i = 0; i < vs->info.num_outputs; i++) {
- if (vs->info.output_semantic_name[i] == semantic_name &&
- vs->info.output_semantic_index[i] == semantic_index)
- return i;
- }
- return -1;
-}
-
-
/**
* Determine how to map vertex program outputs to fragment program inputs.
* Basically, this will be used when computing the triangle interpolation
@@ -58,7 +43,6 @@ find_vs_output(const struct cell_vertex_shader_state *vs,
static void
calculate_vertex_layout( struct cell_context *cell )
{
- const struct cell_vertex_shader_state *vs = cell->vs;
const struct cell_fragment_shader_state *fs = cell->fs;
const enum interp_mode colorInterp
= cell->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
@@ -82,7 +66,7 @@ calculate_vertex_layout( struct cell_context *cell )
vinfo->num_attribs = 0;
/* we always want to emit vertex pos */
- src = find_vs_output(vs, TGSI_SEMANTIC_POSITION, 0);
+ src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_POSITION, 0);
assert(src >= 0);
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_POS, src);
@@ -98,14 +82,14 @@ calculate_vertex_layout( struct cell_context *cell )
break;
case TGSI_SEMANTIC_COLOR:
- src = find_vs_output(vs, TGSI_SEMANTIC_COLOR,
- fs->info.input_semantic_index[i]);
+ src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_COLOR,
+ fs->info.input_semantic_index[i]);
assert(src >= 0);
draw_emit_vertex_attr(vinfo, EMIT_4F, colorInterp, src);
break;
case TGSI_SEMANTIC_FOG:
- src = find_vs_output(vs, TGSI_SEMANTIC_FOG, 0);
+ src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_FOG, 0);
#if 1
if (src < 0) /* XXX temp hack, try demos/fogcoord.c with this */
src = 0;
@@ -116,7 +100,7 @@ calculate_vertex_layout( struct cell_context *cell )
case TGSI_SEMANTIC_GENERIC:
/* this includes texcoords and varying vars */
- src = find_vs_output(vs, TGSI_SEMANTIC_GENERIC,
+ src = draw_find_vs_output(cell->draw, TGSI_SEMANTIC_GENERIC,
fs->info.input_semantic_index[i]);
assert(src >= 0);
draw_emit_vertex_attr(vinfo, EMIT_4F, INTERP_PERSPECTIVE, src);
@@ -163,6 +147,9 @@ compute_cliprect(struct cell_context *sp)
+/**
+ * Update derived state, send current state to SPUs prior to rendering.
+ */
void cell_update_derived( struct cell_context *cell )
{
if (cell->dirty & (CELL_NEW_RASTERIZER |
diff --git a/src/gallium/drivers/cell/ppu/cell_state_emit.c b/src/gallium/drivers/cell/ppu/cell_state_emit.c
index 9cae67f091..f2feaa329a 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_emit.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_emit.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "cell_context.h"
#include "cell_state.h"
#include "cell_state_emit.h"
@@ -47,7 +47,10 @@ emit_state_cmd(struct cell_context *cell, uint cmd,
}
-
+/**
+ * For state marked as 'dirty', construct a state-update command block
+ * and insert it into the current batch buffer.
+ */
void
cell_emit_state(struct cell_context *cell)
{
@@ -90,7 +93,8 @@ cell_emit_state(struct cell_context *cell)
blend.size = (char *) cell->blend->code.csr
- (char *) cell->blend->code.store;
blend.read_fb = TRUE;
- } else {
+ }
+ else {
blend.base = 0;
blend.size = 0;
blend.read_fb = FALSE;
@@ -101,7 +105,6 @@ cell_emit_state(struct cell_context *cell)
if (cell->dirty & CELL_NEW_DEPTH_STENCIL) {
struct cell_command_depth_stencil_alpha_test dsat;
-
if (cell->depth_stencil != NULL) {
dsat.base = (intptr_t) cell->depth_stencil->code.store;
@@ -109,15 +112,15 @@ cell_emit_state(struct cell_context *cell)
- (char *) cell->depth_stencil->code.store;
dsat.read_depth = TRUE;
dsat.read_stencil = FALSE;
- } else {
+ }
+ else {
dsat.base = 0;
dsat.size = 0;
dsat.read_depth = FALSE;
dsat.read_stencil = FALSE;
}
- emit_state_cmd(cell, CELL_CMD_STATE_DEPTH_STENCIL, &dsat,
- sizeof(dsat));
+ emit_state_cmd(cell, CELL_CMD_STATE_DEPTH_STENCIL, &dsat, sizeof(dsat));
}
if (cell->dirty & CELL_NEW_SAMPLER) {
@@ -162,15 +165,14 @@ cell_emit_state(struct cell_context *cell)
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;
+ info.num_outputs = draw_num_vs_outputs(draw);
+ info.declarations = (uintptr_t) draw->vs.machine.Declarations;
+ info.num_declarations = draw->vs.machine.NumDeclarations;
+ info.instructions = (uintptr_t) draw->vs.machine.Instructions;
+ info.num_instructions = draw->vs.machine.NumInstructions;
+ info.immediates = (uintptr_t) draw->vs.machine.Imms;
+ info.num_immediates = draw->vs.machine.ImmLimit / 4;
- emit_state_cmd(cell, CELL_CMD_STATE_BIND_VS,
- & info, sizeof(info));
+ emit_state_cmd(cell, CELL_CMD_STATE_BIND_VS, &info, sizeof(info));
}
}
diff --git a/src/gallium/drivers/cell/ppu/cell_state_shader.c b/src/gallium/drivers/cell/ppu/cell_state_shader.c
index f5707f2bb8..97e44eeb1a 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_shader.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_shader.c
@@ -26,7 +26,7 @@
**************************************************************************/
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
#include "draw/draw_context.h"
@@ -41,7 +41,7 @@
static INLINE struct cell_fragment_shader_state *
cell_fragment_shader_state(void *shader)
{
- return (struct pipe_shader_state *) shader;
+ return (struct cell_fragment_shader_state *) shader;
}
@@ -49,11 +49,14 @@ cell_fragment_shader_state(void *shader)
static INLINE struct cell_vertex_shader_state *
cell_vertex_shader_state(void *shader)
{
- return (struct pipe_shader_state *) shader;
+ return (struct cell_vertex_shader_state *) shader;
}
-
+/**
+ * Create fragment shader state.
+ * Called via pipe->create_fs_state()
+ */
static void *
cell_create_fs_state(struct pipe_context *pipe,
const struct pipe_shader_state *templ)
@@ -77,6 +80,9 @@ cell_create_fs_state(struct pipe_context *pipe,
}
+/**
+ * Called via pipe->bind_fs_state()
+ */
static void
cell_bind_fs_state(struct pipe_context *pipe, void *fs)
{
@@ -88,6 +94,9 @@ cell_bind_fs_state(struct pipe_context *pipe, void *fs)
}
+/**
+ * Called via pipe->delete_fs_state()
+ */
static void
cell_delete_fs_state(struct pipe_context *pipe, void *fs)
{
@@ -98,6 +107,10 @@ cell_delete_fs_state(struct pipe_context *pipe, void *fs)
}
+/**
+ * Create vertex shader state.
+ * Called via pipe->create_vs_state()
+ */
static void *
cell_create_vs_state(struct pipe_context *pipe,
const struct pipe_shader_state *templ)
@@ -128,6 +141,9 @@ cell_create_vs_state(struct pipe_context *pipe,
}
+/**
+ * Called via pipe->bind_vs_state()
+ */
static void
cell_bind_vs_state(struct pipe_context *pipe, void *vs)
{
@@ -142,6 +158,9 @@ cell_bind_vs_state(struct pipe_context *pipe, void *vs)
}
+/**
+ * Called via pipe->delete_vs_state()
+ */
static void
cell_delete_vs_state(struct pipe_context *pipe, void *vs)
{
@@ -154,6 +173,9 @@ cell_delete_vs_state(struct pipe_context *pipe, void *vs)
}
+/**
+ * Called via pipe->set_constant_buffer()
+ */
static void
cell_set_constant_buffer(struct pipe_context *pipe,
uint shader, uint index,
@@ -166,7 +188,7 @@ cell_set_constant_buffer(struct pipe_context *pipe,
assert(index == 0);
/* note: reference counting */
- pipe_buffer_reference(ws,
+ winsys_buffer_reference(ws,
&cell->constants[shader].buffer,
buf->buffer);
cell->constants[shader].size = buf->size;
diff --git a/src/gallium/drivers/cell/ppu/cell_state_vertex.c b/src/gallium/drivers/cell/ppu/cell_state_vertex.c
index 114684c2a3..fbe55c8472 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_vertex.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_vertex.c
@@ -35,7 +35,7 @@
#include "draw/draw_context.h"
-void
+static void
cell_set_vertex_elements(struct pipe_context *pipe,
unsigned count,
const struct pipe_vertex_element *elements)
@@ -53,7 +53,7 @@ cell_set_vertex_elements(struct pipe_context *pipe,
}
-void
+static void
cell_set_vertex_buffers(struct pipe_context *pipe,
unsigned count,
const struct pipe_vertex_buffer *buffers)
@@ -69,3 +69,11 @@ cell_set_vertex_buffers(struct pipe_context *pipe,
draw_set_vertex_buffers(cell->draw, count, buffers);
}
+
+
+void
+cell_init_vertex_functions(struct cell_context *cell)
+{
+ cell->pipe.set_vertex_buffers = cell_set_vertex_buffers;
+ cell->pipe.set_vertex_elements = cell_set_vertex_elements;
+}
diff --git a/src/gallium/drivers/cell/ppu/cell_surface.c b/src/gallium/drivers/cell/ppu/cell_surface.c
index 5549eb496d..732c64082e 100644
--- a/src/gallium/drivers/cell/ppu/cell_surface.c
+++ b/src/gallium/drivers/cell/ppu/cell_surface.c
@@ -25,106 +25,13 @@
*
**************************************************************************/
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "pipe/p_inlines.h"
-#include "pipe/p_winsys.h"
-#include "util/p_tile.h"
+#include "util/u_rect.h"
#include "cell_context.h"
-#include "cell_surface.h"
-
-
-static void
-cell_surface_copy(struct pipe_context *pipe,
- boolean do_flip,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- struct pipe_surface *src,
- unsigned srcx, unsigned srcy,
- unsigned width, unsigned height)
-{
- assert( dst->cpp == src->cpp );
-
- pipe_copy_rect(pipe_surface_map(dst),
- &dst->block,
- dst->stride,
- dstx, dsty,
- width, height,
- pipe_surface_map(src),
- do_flip ? -src->stride : src->stride,
- srcx, do_flip ? height - 1 - srcy : srcy);
-
- pipe_surface_unmap(src);
- pipe_surface_unmap(dst);
-}
-
-
-static void *
-get_pointer(struct pipe_surface *dst, void *dst_map, unsigned x, unsigned y)
-{
- return (char *)dst_map + y / dst->block.height * dst->stride + x / dst->block.width * dst->block.size;
-}
-
-
-#define UBYTE_TO_USHORT(B) ((B) | ((B) << 8))
-
-
-/**
- * Fill a rectangular sub-region. Need better logic about when to
- * push buffers into AGP - will currently do so whenever possible.
- */
-static void
-cell_surface_fill(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height, unsigned value)
-{
- unsigned i, j;
- void *dst_map = pipe_surface_map(dst);
-
- assert(dst->stride > 0);
-
- switch (dst->block.size) {
- case 1:
- case 2:
- case 4:
- pipe_fill_rect(dst_map, &dst->block, dst->stride, dstx, dsty, width, height, value);
- break;
- case 8:
- {
- /* expand the 4-byte clear value to an 8-byte value */
- ushort *row = (ushort *) get_pointer(dst, dst_map, dstx, dsty);
- ushort val0 = UBYTE_TO_USHORT((value >> 0) & 0xff);
- ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff);
- ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff);
- ushort val3 = UBYTE_TO_USHORT((value >> 24) & 0xff);
- val0 = (val0 << 8) | val0;
- val1 = (val1 << 8) | val1;
- val2 = (val2 << 8) | val2;
- val3 = (val3 << 8) | val3;
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++) {
- row[j*4+0] = val0;
- row[j*4+1] = val1;
- row[j*4+2] = val2;
- row[j*4+3] = val3;
- }
- row += dst->stride/2;
- }
- }
- break;
- default:
- assert(0);
- break;
- }
-
- pipe_surface_unmap( dst );
-}
void
cell_init_surface_functions(struct cell_context *cell)
{
- cell->pipe.surface_copy = cell_surface_copy;
- cell->pipe.surface_fill = cell_surface_fill;
+ cell->pipe.surface_copy = util_surface_copy;
+ cell->pipe.surface_fill = util_surface_fill;
}
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c
index 533b64227d..b6590dfb86 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.c
+++ b/src/gallium/drivers/cell/ppu/cell_texture.c
@@ -33,8 +33,9 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "cell_context.h"
#include "cell_state.h"
@@ -62,17 +63,30 @@ cell_texture_layout(struct cell_texture * spt)
spt->buffer_size = 0;
for ( level = 0 ; level <= pt->last_level ; level++ ) {
+ unsigned size;
+ unsigned w_tile, h_tile;
+
+ /* width, height, rounded up to tile size */
+ w_tile = align(width, TILE_SIZE);
+ h_tile = align(height, TILE_SIZE);
+
pt->width[level] = width;
pt->height[level] = height;
pt->depth[level] = depth;
- pt->nblocksx[level] = pf_get_nblocksx(&pt->block, width);
- pt->nblocksy[level] = pf_get_nblocksy(&pt->block, height);
+ pt->nblocksx[level] = pf_get_nblocksx(&pt->block, w_tile);
+ pt->nblocksy[level] = pf_get_nblocksy(&pt->block, h_tile);
+
+ spt->stride[level] = pt->nblocksx[level] * pt->block.size;
spt->level_offset[level] = spt->buffer_size;
- spt->buffer_size += (pt->nblocksy[level] *
- ((pt->target == PIPE_TEXTURE_CUBE) ? 6 : depth) *
- pt->nblocksx[level] * pt->block.size;
+ size = pt->nblocksx[level] * pt->nblocksy[level] * pt->block.size;
+ if (pt->target == PIPE_TEXTURE_CUBE)
+ size *= 6;
+ else
+ size *= depth;
+
+ spt->buffer_size += size;
width = minify(width);
height = minify(height);
@@ -82,8 +96,8 @@ cell_texture_layout(struct cell_texture * spt)
static struct pipe_texture *
-cell_texture_create_screen(struct pipe_screen *screen,
- const struct pipe_texture *templat)
+cell_texture_create(struct pipe_screen *screen,
+ const struct pipe_texture *templat)
{
struct pipe_winsys *ws = screen->winsys;
struct cell_texture *spt = CALLOC_STRUCT(cell_texture);
@@ -110,8 +124,8 @@ cell_texture_create_screen(struct pipe_screen *screen,
static void
-cell_texture_release_screen(struct pipe_screen *screen,
- struct pipe_texture **pt)
+cell_texture_release(struct pipe_screen *screen,
+ struct pipe_texture **pt)
{
if (!*pt)
return;
@@ -127,7 +141,7 @@ cell_texture_release_screen(struct pipe_screen *screen,
DBG("%s deleting %p\n", __FUNCTION__, (void *) spt);
*/
- pipe_buffer_reference(screen->winsys, &spt->buffer, NULL);
+ pipe_buffer_reference(screen, &spt->buffer, NULL);
FREE(spt);
}
@@ -135,6 +149,7 @@ cell_texture_release_screen(struct pipe_screen *screen,
}
+#if 0
static void
cell_texture_update(struct pipe_context *pipe, struct pipe_texture *texture,
uint face, uint levelsMask)
@@ -142,12 +157,14 @@ cell_texture_update(struct pipe_context *pipe, struct pipe_texture *texture,
/* XXX TO DO: re-tile the texture data ... */
}
+#endif
static struct pipe_surface *
-cell_get_tex_surface_screen(struct pipe_screen *screen,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice)
+cell_get_tex_surface(struct pipe_screen *screen,
+ struct pipe_texture *pt,
+ unsigned face, unsigned level, unsigned zslice,
+ unsigned usage)
{
struct pipe_winsys *ws = screen->winsys;
struct cell_texture *spt = cell_texture(pt);
@@ -157,7 +174,7 @@ cell_get_tex_surface_screen(struct pipe_screen *screen,
if (ps) {
assert(ps->refcount);
assert(ps->winsys);
- pipe_buffer_reference(ws, &ps->buffer, spt->buffer);
+ winsys_buffer_reference(ws, &ps->buffer, spt->buffer);
ps->format = pt->format;
ps->block = pt->block;
ps->width = pt->width[level];
@@ -166,12 +183,21 @@ cell_get_tex_surface_screen(struct pipe_screen *screen,
ps->nblocksy = pt->nblocksy[level];
ps->stride = spt->stride[level];
ps->offset = spt->level_offset[level];
+ ps->usage = usage;
+
+ /* XXX may need to override usage flags (see sp_texture.c) */
+
+ pipe_texture_reference(&ps->texture, pt);
+ ps->face = face;
+ ps->level = level;
+ ps->zslice = zslice;
if (pt->target == PIPE_TEXTURE_CUBE || pt->target == PIPE_TEXTURE_3D) {
ps->offset += ((pt->target == PIPE_TEXTURE_CUBE) ? face : zslice) *
ps->nblocksy *
ps->stride;
- } else {
+ }
+ else {
assert(face == 0);
assert(zslice == 0);
}
@@ -181,6 +207,11 @@ cell_get_tex_surface_screen(struct pipe_screen *screen,
+/**
+ * Copy tile data from linear layout to tiled layout.
+ * XXX this should be rolled into the future surface-creation code.
+ * XXX also need "untile" code...
+ */
static void
tile_copy_data(uint w, uint h, uint tile_size, uint *dst, const uint *src)
{
@@ -211,6 +242,7 @@ tile_copy_data(uint w, uint h, uint tile_size, uint *dst, const uint *src)
/**
* Convert linear texture image data to tiled format for SPU usage.
+ * XXX recast this in terms of pipe_surfaces (aka texture views).
*/
static void
cell_tile_texture(struct cell_context *cell,
@@ -228,10 +260,11 @@ cell_tile_texture(struct cell_context *cell,
assert(w % TILE_SIZE == 0);
assert(h % TILE_SIZE == 0);
- surf = screen->get_tex_surface(screen, &texture->base, face, level, zslice);
+ surf = screen->get_tex_surface(screen, &texture->base, face, level, zslice,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
ASSERT(surf);
- src = (const uint *) pipe_surface_map(surf);
+ src = (const uint *) pipe_surface_map(surf, PIPE_BUFFER_USAGE_CPU_WRITE);
if (texture->tiled_data) {
align_free(texture->tiled_data);
@@ -246,11 +279,12 @@ cell_tile_texture(struct cell_context *cell,
}
-
void
cell_update_texture_mapping(struct cell_context *cell)
{
+#if 0
uint face = 0, level = 0, zslice = 0;
+#endif
uint i;
for (i = 0; i < CELL_MAX_SAMPLERS; i++) {
@@ -275,16 +309,79 @@ cell_update_texture_mapping(struct cell_context *cell)
}
+static void
+cell_tex_surface_release(struct pipe_screen *screen,
+ struct pipe_surface **s)
+{
+ /* Effectively do the texture_update work here - if texture images
+ * needed post-processing to put them into hardware layout, this is
+ * where it would happen. For softpipe, nothing to do.
+ */
+ assert ((*s)->texture);
+ pipe_texture_reference(&(*s)->texture, NULL);
+
+ screen->winsys->surface_release(screen->winsys, s);
+}
+
+
+static void *
+cell_surface_map( struct pipe_screen *screen,
+ struct pipe_surface *surface,
+ unsigned flags )
+{
+ ubyte *map;
+
+ if (flags & ~surface->usage) {
+ assert(0);
+ return NULL;
+ }
+
+ map = pipe_buffer_map( screen, surface->buffer, flags );
+ if (map == NULL)
+ return NULL;
+
+ /* May want to different things here depending on read/write nature
+ * of the map:
+ */
+ if (surface->texture &&
+ (flags & PIPE_BUFFER_USAGE_CPU_WRITE))
+ {
+ /* Do something to notify sharing contexts of a texture change.
+ * In softpipe, that would mean flushing the texture cache.
+ */
+#if 0
+ cell_screen(screen)->timestamp++;
+#endif
+ }
+
+ return map + surface->offset;
+}
+
+
+static void
+cell_surface_unmap(struct pipe_screen *screen,
+ struct pipe_surface *surface)
+{
+ pipe_buffer_unmap( screen, surface->buffer );
+}
+
+
void
cell_init_texture_functions(struct cell_context *cell)
{
- cell->pipe.texture_update = cell_texture_update;
+ /*cell->pipe.texture_update = cell_texture_update;*/
}
+
void
cell_init_screen_texture_funcs(struct pipe_screen *screen)
{
- screen->texture_create = cell_texture_create_screen;
- screen->texture_release = cell_texture_release_screen;
- screen->get_tex_surface = cell_get_tex_surface_screen;
+ screen->texture_create = cell_texture_create;
+ screen->texture_release = cell_texture_release;
+
+ screen->get_tex_surface = cell_get_tex_surface;
+ screen->tex_surface_release = cell_tex_surface_release;
+
+ screen->surface_map = cell_surface_map;
+ screen->surface_unmap = cell_surface_unmap;
}
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.h b/src/gallium/drivers/cell/ppu/cell_texture.h
index fcee069d05..6d37e95ebc 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.h
+++ b/src/gallium/drivers/cell/ppu/cell_texture.h
@@ -41,6 +41,7 @@ struct cell_texture
struct pipe_texture base;
unsigned long level_offset[PIPE_MAX_TEXTURE_LEVELS];
+ unsigned long stride[PIPE_MAX_TEXTURE_LEVELS];
/* The data is held here:
*/
diff --git a/src/gallium/drivers/cell/ppu/cell_vbuf.c b/src/gallium/drivers/cell/ppu/cell_vbuf.c
index 3a181b585c..aa63435b93 100644
--- a/src/gallium/drivers/cell/ppu/cell_vbuf.c
+++ b/src/gallium/drivers/cell/ppu/cell_vbuf.c
@@ -26,6 +26,11 @@
**************************************************************************/
/**
+ * Vertex buffer code. The draw module transforms vertices to window
+ * coords, etc. and emits the vertices into buffer supplied by this module.
+ * When a vertex buffer is full, or we flush, we'll send the vertex data
+ * to the SPUs.
+ *
* Authors
* Brian Paul
*/
@@ -37,6 +42,7 @@
#include "cell_spu.h"
#include "cell_vbuf.h"
#include "draw/draw_vbuf.h"
+#include "util/u_memory.h"
/** Allow vertex data to be inlined after RENDER command */
@@ -112,7 +118,7 @@ cell_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices,
}
cvbr->vertex_buf = ~0;
- cell_flush_int(&cell->pipe, 0x0);
+ cell_flush_int(cell, 0x0);
assert(vertices == cvbr->vertex_buffer);
cvbr->vertex_buffer = NULL;
@@ -120,12 +126,13 @@ cell_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices,
-static void
+static boolean
cell_vbuf_set_primitive(struct vbuf_render *vbr, unsigned prim)
{
struct cell_vbuf_render *cvbr = cell_vbuf_render(vbr);
cvbr->prim = prim;
/*printf("cell_set_prim %u\n", prim);*/
+ return TRUE;
}
@@ -243,7 +250,7 @@ cell_vbuf_draw(struct vbuf_render *vbr,
#if 0
/* helpful for debug */
- cell_flush_int(&cell->pipe, CELL_FLUSH_WAIT);
+ cell_flush_int(cell, CELL_FLUSH_WAIT);
#endif
}
diff --git a/src/gallium/drivers/cell/ppu/cell_vertex_fetch.c b/src/gallium/drivers/cell/ppu/cell_vertex_fetch.c
index 49d5443cde..2ece0250f6 100644
--- a/src/gallium/drivers/cell/ppu/cell_vertex_fetch.c
+++ b/src/gallium/drivers/cell/ppu/cell_vertex_fetch.c
@@ -260,6 +260,7 @@ emit_fetch(struct spe_function *p,
void cell_update_vertex_fetch(struct draw_context *draw)
{
+#if 0
struct cell_context *const cell =
(struct cell_context *) draw->driver_private;
struct spe_function *p = &cell->attrib_fetch;
@@ -337,4 +338,7 @@ void cell_update_vertex_fetch(struct draw_context *draw)
cell->attrib_fetch_offsets[function_index[i]];
}
}
+#else
+ assert(0);
+#endif
}
diff --git a/src/gallium/drivers/cell/ppu/cell_vertex_shader.c b/src/gallium/drivers/cell/ppu/cell_vertex_shader.c
index f753960a0f..2b10c116fa 100644
--- a/src/gallium/drivers/cell/ppu/cell_vertex_shader.c
+++ b/src/gallium/drivers/cell/ppu/cell_vertex_shader.c
@@ -32,6 +32,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_context.h"
#include "pipe/p_winsys.h"
+#include "util/u_math.h"
#include "cell_context.h"
#include "cell_draw_arrays.h"
@@ -50,6 +51,7 @@
void
cell_vertex_shader_queue_flush(struct draw_context *draw)
{
+#if 0
struct cell_context *const cell =
(struct cell_context *) draw->driver_private;
struct cell_command_vs *const vs = &cell_global.command[0].vs;
@@ -133,9 +135,12 @@ cell_vertex_shader_queue_flush(struct draw_context *draw)
vs->num_elts = n;
send_mbox_message(cell_global.spe_contexts[0], CELL_CMD_VS_EXECUTE);
- cell_flush_int(& cell->pipe, CELL_FLUSH_WAIT);
+ cell_flush_int(cell, CELL_FLUSH_WAIT);
}
draw->vs.post_nr = draw->vs.queue_nr;
draw->vs.queue_nr = 0;
+#else
+ assert(0);
+#endif
}
diff --git a/src/gallium/drivers/cell/ppu/cell_winsys.c b/src/gallium/drivers/cell/ppu/cell_winsys.c
index ebabce3c8f..d570bbd2f9 100644
--- a/src/gallium/drivers/cell/ppu/cell_winsys.c
+++ b/src/gallium/drivers/cell/ppu/cell_winsys.c
@@ -26,7 +26,7 @@
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "cell_winsys.h"
diff --git a/src/gallium/drivers/cell/spu/Makefile b/src/gallium/drivers/cell/spu/Makefile
index 8e83610790..d49abb2e82 100644
--- a/src/gallium/drivers/cell/spu/Makefile
+++ b/src/gallium/drivers/cell/spu/Makefile
@@ -5,7 +5,7 @@
TOP = ../../../../..
-include $(TOP)/configs/linux-cell
+include $(TOP)/configs/current
PROG = g3d
diff --git a/src/gallium/drivers/cell/spu/spu_exec.c b/src/gallium/drivers/cell/spu/spu_exec.c
index 42e5022f30..e27df2dfb3 100644
--- a/src/gallium/drivers/cell/spu/spu_exec.c
+++ b/src/gallium/drivers/cell/spu/spu_exec.c
@@ -63,7 +63,6 @@
#include "pipe/p_compiler.h"
#include "pipe/p_state.h"
-#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_util.h"
@@ -383,10 +382,10 @@ fetch_src_file_channel(
break;
case TGSI_FILE_IMMEDIATE:
- assert( index->i[0] < (int) mach->ImmLimit );
- assert( index->i[1] < (int) mach->ImmLimit );
- assert( index->i[2] < (int) mach->ImmLimit );
- assert( index->i[3] < (int) mach->ImmLimit );
+ ASSERT( index->i[0] < (int) mach->ImmLimit );
+ ASSERT( index->i[1] < (int) mach->ImmLimit );
+ ASSERT( index->i[2] < (int) mach->ImmLimit );
+ ASSERT( index->i[3] < (int) mach->ImmLimit );
chan->f[0] = mach->Imms[index->i[0]][swizzle];
chan->f[1] = mach->Imms[index->i[1]][swizzle];
@@ -410,7 +409,7 @@ fetch_src_file_channel(
break;
default:
- assert( 0 );
+ ASSERT( 0 );
}
break;
@@ -423,7 +422,7 @@ fetch_src_file_channel(
break;
default:
- assert( 0 );
+ ASSERT( 0 );
}
}
@@ -472,7 +471,7 @@ fetch_source(
index.q = si_shli(index.q, 12);
break;
default:
- assert( 0 );
+ ASSERT( 0 );
}
index.i[0] += reg->SrcRegisterDim.Index;
@@ -559,7 +558,7 @@ store_dest(
break;
default:
- assert( 0 );
+ ASSERT( 0 );
return;
}
@@ -583,11 +582,11 @@ store_dest(
break;
case TGSI_SAT_MINUS_PLUS_ONE:
- assert( 0 );
+ ASSERT( 0 );
break;
default:
- assert( 0 );
+ ASSERT( 0 );
}
}
@@ -770,7 +769,7 @@ exec_tex(struct spu_exec_machine *mach,
break;
default:
- assert (0);
+ ASSERT (0);
}
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
@@ -862,7 +861,7 @@ exec_declaration(struct spu_exec_machine *mach,
break;
default:
- assert( 0 );
+ ASSERT( 0 );
}
if( mask == TGSI_WRITEMASK_XYZW ) {
@@ -972,11 +971,11 @@ exec_instruction(
break;
case TGSI_OPCODE_EXP:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_LOG:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_MUL:
@@ -1152,24 +1151,24 @@ exec_instruction(
break;
case TGSI_OPCODE_CND:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_CND0:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_DOT2ADD:
/* TGSI_OPCODE_DP2A */
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_INDEX:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_NEGATE:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_FRAC:
@@ -1182,7 +1181,7 @@ exec_instruction(
break;
case TGSI_OPCODE_CLAMP:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_FLOOR:
@@ -1277,7 +1276,7 @@ exec_instruction(
break;
case TGSI_OPCODE_MULTIPLYMATRIX:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_ABS:
@@ -1291,7 +1290,7 @@ exec_instruction(
break;
case TGSI_OPCODE_RCC:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_DPH:
@@ -1354,23 +1353,23 @@ exec_instruction(
break;
case TGSI_OPCODE_PK2H:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_PK2US:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_PK4B:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_PK4UB:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_RFL:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_SEQ:
@@ -1385,7 +1384,7 @@ exec_instruction(
break;
case TGSI_OPCODE_SFL:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_SGT:
@@ -1430,7 +1429,7 @@ exec_instruction(
break;
case TGSI_OPCODE_STR:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_TEX:
@@ -1453,7 +1452,7 @@ exec_instruction(
/* src[1] = d[strq]/dx */
/* src[2] = d[strq]/dy */
/* src[3] = sampler unit */
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_TXL:
@@ -1471,35 +1470,35 @@ exec_instruction(
break;
case TGSI_OPCODE_UP2H:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_UP2US:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_UP4B:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_UP4UB:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_X2D:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_ARA:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_ARR:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_BRA:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_CAL:
@@ -1508,14 +1507,14 @@ exec_instruction(
/* do the call */
/* push the Cond, Loop, Cont stacks */
- assert(mach->CondStackTop < TGSI_EXEC_MAX_COND_NESTING);
+ ASSERT(mach->CondStackTop < TGSI_EXEC_MAX_COND_NESTING);
mach->CondStack[mach->CondStackTop++] = mach->CondMask;
- assert(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
+ ASSERT(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
- assert(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
+ ASSERT(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
mach->ContStack[mach->ContStackTop++] = mach->ContMask;
- assert(mach->FuncStackTop < TGSI_EXEC_MAX_CALL_NESTING);
+ ASSERT(mach->FuncStackTop < TGSI_EXEC_MAX_CALL_NESTING);
mach->FuncStack[mach->FuncStackTop++] = mach->FuncMask;
/* note that PC was already incremented above */
@@ -1539,13 +1538,13 @@ exec_instruction(
*pc = mach->CallStack[--mach->CallStackTop];
/* pop the Cond, Loop, Cont stacks */
- assert(mach->CondStackTop > 0);
+ ASSERT(mach->CondStackTop > 0);
mach->CondMask = mach->CondStack[--mach->CondStackTop];
- assert(mach->LoopStackTop > 0);
+ ASSERT(mach->LoopStackTop > 0);
mach->LoopMask = mach->LoopStack[--mach->LoopStackTop];
- assert(mach->ContStackTop > 0);
+ ASSERT(mach->ContStackTop > 0);
mach->ContMask = mach->ContStack[--mach->ContStackTop];
- assert(mach->FuncStackTop > 0);
+ ASSERT(mach->FuncStackTop > 0);
mach->FuncMask = mach->FuncStack[--mach->FuncStackTop];
UPDATE_EXEC_MASK(mach);
@@ -1553,7 +1552,7 @@ exec_instruction(
break;
case TGSI_OPCODE_SSG:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_CMP:
@@ -1593,11 +1592,11 @@ exec_instruction(
break;
case TGSI_OPCODE_NRM:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_DIV:
- assert( 0 );
+ ASSERT( 0 );
break;
case TGSI_OPCODE_DP2:
@@ -1616,7 +1615,7 @@ exec_instruction(
case TGSI_OPCODE_IF:
/* push CondMask */
- assert(mach->CondStackTop < TGSI_EXEC_MAX_COND_NESTING);
+ ASSERT(mach->CondStackTop < TGSI_EXEC_MAX_COND_NESTING);
mach->CondStack[mach->CondStackTop++] = mach->CondMask;
FETCH( &r[0], 0, CHAN_X );
/* update CondMask */
@@ -1640,7 +1639,7 @@ exec_instruction(
/* invert CondMask wrt previous mask */
{
uint prevMask;
- assert(mach->CondStackTop > 0);
+ ASSERT(mach->CondStackTop > 0);
prevMask = mach->CondStack[mach->CondStackTop - 1];
mach->CondMask = ~mach->CondMask & prevMask;
UPDATE_EXEC_MASK(mach);
@@ -1650,7 +1649,7 @@ exec_instruction(
case TGSI_OPCODE_ENDIF:
/* pop CondMask */
- assert(mach->CondStackTop > 0);
+ ASSERT(mach->CondStackTop > 0);
mach->CondMask = mach->CondStack[--mach->CondStackTop];
UPDATE_EXEC_MASK(mach);
break;
@@ -1661,19 +1660,19 @@ exec_instruction(
break;
case TGSI_OPCODE_REP:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_ENDREP:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_PUSHA:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_POPA:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_CEIL:
@@ -1747,7 +1746,7 @@ exec_instruction(
break;
case TGSI_OPCODE_MOD:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_XOR:
@@ -1760,15 +1759,15 @@ exec_instruction(
break;
case TGSI_OPCODE_SAD:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_TXF:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_TXQ:
- assert (0);
+ ASSERT (0);
break;
case TGSI_OPCODE_EMIT:
@@ -1785,9 +1784,9 @@ exec_instruction(
/* fall-through (for now) */
case TGSI_OPCODE_BGNLOOP2:
/* push LoopMask and ContMasks */
- assert(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
+ ASSERT(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
- assert(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
+ ASSERT(mach->ContStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
mach->ContStack[mach->ContStackTop++] = mach->ContMask;
break;
@@ -1795,7 +1794,7 @@ exec_instruction(
/* fall-through (for now at least) */
case TGSI_OPCODE_ENDLOOP2:
/* Restore ContMask, but don't pop */
- assert(mach->ContStackTop > 0);
+ ASSERT(mach->ContStackTop > 0);
mach->ContMask = mach->ContStack[mach->ContStackTop - 1];
if (mach->LoopMask) {
/* repeat loop: jump to instruction just past BGNLOOP */
@@ -1803,10 +1802,10 @@ exec_instruction(
}
else {
/* exit loop: pop LoopMask */
- assert(mach->LoopStackTop > 0);
+ ASSERT(mach->LoopStackTop > 0);
mach->LoopMask = mach->LoopStack[--mach->LoopStackTop];
/* pop ContMask */
- assert(mach->ContStackTop > 0);
+ ASSERT(mach->ContStackTop > 0);
mach->ContMask = mach->ContStack[--mach->ContStackTop];
}
UPDATE_EXEC_MASK(mach);
@@ -1835,26 +1834,26 @@ exec_instruction(
break;
case TGSI_OPCODE_NOISE1:
- assert( 0 );
+ ASSERT( 0 );
break;
case TGSI_OPCODE_NOISE2:
- assert( 0 );
+ ASSERT( 0 );
break;
case TGSI_OPCODE_NOISE3:
- assert( 0 );
+ ASSERT( 0 );
break;
case TGSI_OPCODE_NOISE4:
- assert( 0 );
+ ASSERT( 0 );
break;
case TGSI_OPCODE_NOP:
break;
default:
- assert( 0 );
+ ASSERT( 0 );
}
}
@@ -1875,11 +1874,11 @@ spu_exec_machine_run( struct spu_exec_machine *mach )
mach->FuncMask = 0xf;
mach->ExecMask = 0xf;
- mach->CondStackTop = 0; /* temporarily subvert this assertion */
- assert(mach->CondStackTop == 0);
- assert(mach->LoopStackTop == 0);
- assert(mach->ContStackTop == 0);
- assert(mach->CallStackTop == 0);
+ mach->CondStackTop = 0; /* temporarily subvert this ASSERTion */
+ ASSERT(mach->CondStackTop == 0);
+ ASSERT(mach->LoopStackTop == 0);
+ ASSERT(mach->ContStackTop == 0);
+ ASSERT(mach->CallStackTop == 0);
mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] = 0;
mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] = 0;
diff --git a/src/gallium/drivers/cell/spu/spu_exec.h b/src/gallium/drivers/cell/spu/spu_exec.h
index c68f78f59b..8605679940 100644
--- a/src/gallium/drivers/cell/spu/spu_exec.h
+++ b/src/gallium/drivers/cell/spu/spu_exec.h
@@ -99,7 +99,7 @@ struct spu_exec_machine
* 1 address
*/
struct spu_exec_vector Temps[TGSI_EXEC_NUM_TEMPS
- + TGSI_EXEC_NUM_ADDRS + 1]
+ + TGSI_EXEC_NUM_TEMP_EXTRAS + 1]
ALIGN16_ATTRIB;
struct spu_exec_vector *Addrs;
diff --git a/src/gallium/drivers/cell/spu/spu_main.c b/src/gallium/drivers/cell/spu/spu_main.c
index e04ffeb9b1..d223f32d94 100644
--- a/src/gallium/drivers/cell/spu/spu_main.c
+++ b/src/gallium/drivers/cell/spu/spu_main.c
@@ -55,6 +55,10 @@ struct spu_global spu;
struct spu_vs_context draw;
+
+/**
+ * Buffers containing dynamically generated SPU code:
+ */
static unsigned char attribute_fetch_code_buffer[136 * PIPE_MAX_ATTRIBS]
ALIGN16_ATTRIB;
@@ -136,54 +140,75 @@ really_clear_tiles(uint surfaceIndex)
static void
cmd_clear_surface(const struct cell_command_clear_surface *clear)
{
- const uint num_tiles = spu.fb.width_tiles * spu.fb.height_tiles;
- uint i;
-
if (Debug)
printf("SPU %u: CLEAR SURF %u to 0x%08x\n", spu.init.id,
clear->surface, clear->value);
-#define CLEAR_OPT 1
-#if CLEAR_OPT
- /* set all tile's status to CLEAR */
if (clear->surface == 0) {
- memset(spu.ctile_status, TILE_STATUS_CLEAR, sizeof(spu.ctile_status));
spu.fb.color_clear_value = clear->value;
+ if (spu.init.debug_flags & CELL_DEBUG_CHECKER) {
+ uint x = (spu.init.id << 4) | (spu.init.id << 12) |
+ (spu.init.id << 20) | (spu.init.id << 28);
+ spu.fb.color_clear_value ^= x;
+ }
}
else {
- memset(spu.ztile_status, TILE_STATUS_CLEAR, sizeof(spu.ztile_status));
spu.fb.depth_clear_value = clear->value;
}
- return;
-#endif
+#define CLEAR_OPT 1
+#if CLEAR_OPT
+
+ /* Simply set all tiles' status to CLEAR.
+ * When we actually begin rendering into a tile, we'll initialize it to
+ * the clear value. If any tiles go untouched during the frame,
+ * really_clear_tiles() will set them to the clear value.
+ */
if (clear->surface == 0) {
- spu.fb.color_clear_value = clear->value;
- clear_c_tile(&spu.ctile);
+ memset(spu.ctile_status, TILE_STATUS_CLEAR, sizeof(spu.ctile_status));
}
else {
- spu.fb.depth_clear_value = clear->value;
- clear_z_tile(&spu.ztile);
+ memset(spu.ztile_status, TILE_STATUS_CLEAR, sizeof(spu.ztile_status));
}
+#else
+
+ /*
+ * This path clears the whole framebuffer to the clear color right now.
+ */
+
/*
printf("SPU: %s num=%d w=%d h=%d\n",
__FUNCTION__, num_tiles, spu.fb.width_tiles, spu.fb.height_tiles);
*/
- for (i = spu.init.id; i < num_tiles; i += spu.init.num_spus) {
- uint tx = i % spu.fb.width_tiles;
- uint ty = i / spu.fb.width_tiles;
- if (clear->surface == 0)
- put_tile(tx, ty, &spu.ctile, TAG_SURFACE_CLEAR, 0);
- else
- put_tile(tx, ty, &spu.ztile, TAG_SURFACE_CLEAR, 1);
- /* XXX we don't want this here, but it fixes bad tile results */
+ /* init a single tile to the clear value */
+ if (clear->surface == 0) {
+ clear_c_tile(&spu.ctile);
+ }
+ else {
+ clear_z_tile(&spu.ztile);
}
-#if 0
- wait_on_mask(1 << TAG_SURFACE_CLEAR);
-#endif
+ /* walk over my tiles, writing the 'clear' tile's data */
+ {
+ const uint num_tiles = spu.fb.width_tiles * spu.fb.height_tiles;
+ uint i;
+ for (i = spu.init.id; i < num_tiles; i += spu.init.num_spus) {
+ uint tx = i % spu.fb.width_tiles;
+ uint ty = i / spu.fb.width_tiles;
+ if (clear->surface == 0)
+ put_tile(tx, ty, &spu.ctile, TAG_SURFACE_CLEAR, 0);
+ else
+ put_tile(tx, ty, &spu.ztile, TAG_SURFACE_CLEAR, 1);
+ }
+ }
+
+ if (spu.init.debug_flags & CELL_DEBUG_SYNC) {
+ wait_on_mask(1 << TAG_SURFACE_CLEAR);
+ }
+
+#endif /* CLEAR_OPT */
if (Debug)
printf("SPU %u: CLEAR SURF done\n", spu.init.id);
@@ -312,6 +337,21 @@ cmd_state_depth_stencil(const struct cell_command_depth_stencil_alpha_test *stat
static void
+cmd_state_logicop(const struct cell_command_logicop * code)
+{
+ mfc_get(logicop_code_buffer,
+ (unsigned int) code->base, /* src */
+ code->size,
+ TAG_BATCH_BUFFER,
+ 0, /* tid */
+ 0 /* rid */);
+ wait_on_mask(1 << TAG_BATCH_BUFFER);
+
+ spu.logicop = (logicop_func) logicop_code_buffer;
+}
+
+
+static void
cmd_state_sampler(const struct cell_command_sampler *sampler)
{
if (Debug)
@@ -381,6 +421,21 @@ cmd_state_vs_array_info(const struct cell_array_info *vs_info)
static void
+cmd_state_attrib_fetch(const struct cell_attribute_fetch_code *code)
+{
+ mfc_get(attribute_fetch_code_buffer,
+ (unsigned int) code->base, /* src */
+ code->size,
+ TAG_BATCH_BUFFER,
+ 0, /* tid */
+ 0 /* rid */);
+ wait_on_mask(1 << TAG_BATCH_BUFFER);
+
+ draw.vertex_fetch.code = attribute_fetch_code_buffer;
+}
+
+
+static void
cmd_finish(void)
{
if (Debug)
@@ -518,38 +573,15 @@ cmd_batch(uint opcode)
(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];
-
- mfc_get(attribute_fetch_code_buffer,
- (unsigned int) code->base, /* src */
- code->size,
- TAG_BATCH_BUFFER,
- 0, /* tid */
- 0 /* rid */);
- wait_on_mask(1 << TAG_BATCH_BUFFER);
-
- draw.vertex_fetch.code = attribute_fetch_code_buffer;
+ case CELL_CMD_STATE_ATTRIB_FETCH:
+ cmd_state_attrib_fetch((struct cell_attribute_fetch_code *)
+ &buffer[pos+1]);
pos += (1 + ROUNDUP8(sizeof(struct cell_attribute_fetch_code)) / 8);
break;
- }
- case CELL_CMD_STATE_LOGICOP: {
- struct cell_command_logicop *code =
- (struct cell_command_logicop *) &buffer[pos+1];
-
- mfc_get(logicop_code_buffer,
- (unsigned int) code->base, /* src */
- code->size,
- TAG_BATCH_BUFFER,
- 0, /* tid */
- 0 /* rid */);
- wait_on_mask(1 << TAG_BATCH_BUFFER);
-
- spu.logicop = (logicop_func) logicop_code_buffer;
+ case CELL_CMD_STATE_LOGICOP:
+ cmd_state_logicop((struct cell_command_logicop *) &buffer[pos+1]);
pos += (1 + ROUNDUP8(sizeof(struct cell_command_logicop)) / 8);
break;
- }
case CELL_CMD_FLUSH_BUFFER_RANGE: {
struct cell_buffer_range *br = (struct cell_buffer_range *)
&buffer[pos+1];
diff --git a/src/gallium/drivers/cell/spu/spu_main.h b/src/gallium/drivers/cell/spu/spu_main.h
index e962e1426c..4879f8c9c8 100644
--- a/src/gallium/drivers/cell/spu/spu_main.h
+++ b/src/gallium/drivers/cell/spu/spu_main.h
@@ -124,13 +124,13 @@ struct spu_global
struct spu_framebuffer fb;
boolean read_depth;
boolean read_stencil;
- frag_test_func frag_test;
+ frag_test_func frag_test; /**< Current depth/stencil test code */
- boolean read_fb;
- blend_func blend;
+ boolean read_fb; /**< Does current blend mode require framebuffer read? */
+ blend_func blend; /**< Current blend code */
qword const_blend_color[4] ALIGN16_ATTRIB;
- logicop_func logicop;
+ logicop_func logicop; /**< Current logicop code **/
struct pipe_sampler_state sampler[PIPE_MAX_SAMPLERS];
struct spu_texture texture[PIPE_MAX_SAMPLERS];
diff --git a/src/gallium/drivers/cell/spu/spu_per_fragment_op.c b/src/gallium/drivers/cell/spu/spu_per_fragment_op.c
index b4cffeeb32..c0a729b3d2 100644
--- a/src/gallium/drivers/cell/spu/spu_per_fragment_op.c
+++ b/src/gallium/drivers/cell/spu/spu_per_fragment_op.c
@@ -95,7 +95,7 @@ read_ds_quad(tile_t *buffer, unsigned x, unsigned y,
default:
- assert(0);
+ ASSERT(0);
break;
}
}
@@ -153,7 +153,7 @@ write_ds_quad(tile_t *buffer, unsigned x, unsigned y,
default:
- assert(0);
+ ASSERT(0);
break;
}
}
diff --git a/src/gallium/drivers/cell/spu/spu_render.c b/src/gallium/drivers/cell/spu/spu_render.c
index 6df59abd36..305dc98881 100644
--- a/src/gallium/drivers/cell/spu/spu_render.c
+++ b/src/gallium/drivers/cell/spu/spu_render.c
@@ -35,7 +35,7 @@
#include "spu_tri.h"
#include "spu_tile.h"
#include "cell/common.h"
-
+#include "util/u_memory.h"
/**
diff --git a/src/gallium/drivers/cell/spu/spu_tile.c b/src/gallium/drivers/cell/spu/spu_tile.c
index 12dc246328..216a33126b 100644
--- a/src/gallium/drivers/cell/spu/spu_tile.c
+++ b/src/gallium/drivers/cell/spu/spu_tile.c
@@ -31,6 +31,9 @@
#include "spu_main.h"
+/**
+ * Get tile of color or Z values from main memory, put into SPU memory.
+ */
void
get_tile(uint tx, uint ty, tile_t *tile, int tag, int zBuf)
{
@@ -56,6 +59,9 @@ get_tile(uint tx, uint ty, tile_t *tile, int tag, int zBuf)
}
+/**
+ * Move tile of color or Z values from SPU memory to main memory.
+ */
void
put_tile(uint tx, uint ty, const tile_t *tile, int tag, int zBuf)
{
diff --git a/src/gallium/drivers/cell/spu/spu_tri.c b/src/gallium/drivers/cell/spu/spu_tri.c
index ab4ff8160a..2a4e0b423c 100644
--- a/src/gallium/drivers/cell/spu/spu_tri.c
+++ b/src/gallium/drivers/cell/spu/spu_tri.c
@@ -32,7 +32,7 @@
#include <transpose_matrix4x4.h>
#include "pipe/p_compiler.h"
#include "pipe/p_format.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
#include "spu_colorpack.h"
#include "spu_main.h"
#include "spu_texture.h"
diff --git a/src/gallium/drivers/cell/spu/spu_util.c b/src/gallium/drivers/cell/spu/spu_util.c
index 74ab2bbd1f..b8a0d4a265 100644
--- a/src/gallium/drivers/cell/spu/spu_util.c
+++ b/src/gallium/drivers/cell/spu/spu_util.c
@@ -1,5 +1,7 @@
-#include "pipe/p_util.h"
+
+#include "cell/common.h"
#include "pipe/p_shader_tokens.h"
+#include "pipe/p_debug.h"
#include "tgsi/tgsi_parse.h"
//#include "tgsi_build.h"
#include "tgsi/tgsi_util.h"
@@ -19,7 +21,7 @@ tgsi_util_get_src_register_swizzle(
case 3:
return reg->SwizzleW;
default:
- assert( 0 );
+ ASSERT( 0 );
}
return 0;
}
@@ -39,7 +41,7 @@ tgsi_util_get_src_register_extswizzle(
case 3:
return reg->ExtSwizzleW;
default:
- assert( 0 );
+ ASSERT( 0 );
}
return 0;
}
@@ -59,12 +61,12 @@ tgsi_util_get_full_src_register_extswizzle(
&reg->SrcRegisterExtSwz,
component );
- assert (TGSI_SWIZZLE_X == TGSI_EXTSWIZZLE_X);
- assert (TGSI_SWIZZLE_Y == TGSI_EXTSWIZZLE_Y);
- assert (TGSI_SWIZZLE_Z == TGSI_EXTSWIZZLE_Z);
- assert (TGSI_SWIZZLE_W == TGSI_EXTSWIZZLE_W);
- assert (TGSI_EXTSWIZZLE_ZERO > TGSI_SWIZZLE_W);
- assert (TGSI_EXTSWIZZLE_ONE > TGSI_SWIZZLE_W);
+ ASSERT (TGSI_SWIZZLE_X == TGSI_EXTSWIZZLE_X);
+ ASSERT (TGSI_SWIZZLE_Y == TGSI_EXTSWIZZLE_Y);
+ ASSERT (TGSI_SWIZZLE_Z == TGSI_EXTSWIZZLE_Z);
+ ASSERT (TGSI_SWIZZLE_W == TGSI_EXTSWIZZLE_W);
+ ASSERT (TGSI_EXTSWIZZLE_ZERO > TGSI_SWIZZLE_W);
+ ASSERT (TGSI_EXTSWIZZLE_ONE > TGSI_SWIZZLE_W);
/*
* Second, calculate the simple swizzle for the unswizzled channel index.
@@ -94,7 +96,7 @@ tgsi_util_get_src_register_extnegate(
case 3:
return reg->NegateW;
default:
- assert( 0 );
+ ASSERT( 0 );
}
return 0;
}
@@ -119,7 +121,7 @@ tgsi_util_set_src_register_extnegate(
reg->NegateW = negate;
break;
default:
- assert( 0 );
+ 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 219fd90cc0..03375d84a5 100644
--- a/src/gallium/drivers/cell/spu/spu_vertex_fetch.c
+++ b/src/gallium/drivers/cell/spu/spu_vertex_fetch.c
@@ -32,7 +32,6 @@
* Ian Romanick <idr@us.ibm.com>
*/
-#include "pipe/p_util.h"
#include "pipe/p_state.h"
#include "pipe/p_shader_tokens.h"
#include "spu_exec.h"
@@ -93,7 +92,7 @@ static void generic_vertex_fetch(struct spu_vs_context *draw,
unsigned nr_attrs = draw->vertex_fetch.nr_attrs;
unsigned attr;
- assert(count <= 4);
+ ASSERT(count <= 4);
#if DRAW_DBG
printf("SPU: %s count = %u, nr_attrs = %u\n",
diff --git a/src/gallium/drivers/cell/spu/spu_vertex_shader.c b/src/gallium/drivers/cell/spu/spu_vertex_shader.c
index 3119a78c06..fbe5b34d39 100644
--- a/src/gallium/drivers/cell/spu/spu_vertex_shader.c
+++ b/src/gallium/drivers/cell/spu/spu_vertex_shader.c
@@ -34,16 +34,37 @@
#include <spu_mfcio.h>
-#include "pipe/p_util.h"
#include "pipe/p_state.h"
#include "pipe/p_shader_tokens.h"
-#include "spu_vertex_shader.h"
-#include "spu_exec.h"
+#include "util/u_math.h"
#include "draw/draw_private.h"
#include "draw/draw_context.h"
#include "cell/common.h"
+#include "spu_vertex_shader.h"
+#include "spu_exec.h"
#include "spu_main.h"
+
+#define MAX_VERTEX_SIZE ((2 + PIPE_MAX_SHADER_OUTPUTS) * 4 * sizeof(float))
+
+
+#define CLIP_RIGHT_BIT 0x01
+#define CLIP_LEFT_BIT 0x02
+#define CLIP_TOP_BIT 0x04
+#define CLIP_BOTTOM_BIT 0x08
+#define CLIP_FAR_BIT 0x10
+#define CLIP_NEAR_BIT 0x20
+
+
+static INLINE float
+dot4(const float *a, const float *b)
+{
+ return (a[0]*b[0] +
+ a[1]*b[1] +
+ a[2]*b[2] +
+ a[3]*b[3]);
+}
+
static INLINE unsigned
compute_clipmask(const float *clip, /*const*/ float plane[][4], unsigned nr)
{
@@ -91,7 +112,7 @@ run_vertex_program(struct spu_vs_context *draw,
const float *scale = draw->viewport.scale;
const float *trans = draw->viewport.translate;
- assert(count <= 4);
+ ASSERT(count <= 4);
machine->Processor = TGSI_PROCESSOR_VERTEX;
diff --git a/src/gallium/drivers/failover/fo_context.c b/src/gallium/drivers/failover/fo_context.c
index 014a3e31d5..10c4ffc209 100644
--- a/src/gallium/drivers/failover/fo_context.c
+++ b/src/gallium/drivers/failover/fo_context.c
@@ -28,7 +28,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_context.h"
#include "fo_context.h"
diff --git a/src/gallium/drivers/i915simple/i915_context.c b/src/gallium/drivers/i915simple/i915_context.c
index e3d19017b5..6dd3eda85d 100644
--- a/src/gallium/drivers/i915simple/i915_context.c
+++ b/src/gallium/drivers/i915simple/i915_context.c
@@ -35,7 +35,8 @@
#include "draw/draw_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
+#include "pipe/p_inlines.h"
+#include "util/u_memory.h"
#include "pipe/p_screen.h"
@@ -45,7 +46,7 @@ static void i915_destroy( struct pipe_context *pipe )
draw_destroy( i915->draw );
- if(i915->winsys)
+ if(i915->winsys->destroy)
i915->winsys->destroy(i915->winsys);
FREE( i915 );
@@ -72,7 +73,7 @@ i915_draw_range_elements(struct pipe_context *pipe,
*/
for (i = 0; i < i915->num_vertex_buffers; i++) {
void *buf
- = pipe->winsys->buffer_map(pipe->winsys,
+ = pipe_buffer_map(pipe->screen,
i915->vertex_buffer[i].buffer,
PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_vertex_buffer(draw, i, buf);
@@ -80,7 +81,7 @@ i915_draw_range_elements(struct pipe_context *pipe,
/* Map index buffer, if present */
if (indexBuffer) {
void *mapped_indexes
- = pipe->winsys->buffer_map(pipe->winsys, indexBuffer,
+ = pipe_buffer_map(pipe->screen, indexBuffer,
PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_element_buffer_range(draw, indexSize,
min_index,
@@ -105,11 +106,11 @@ i915_draw_range_elements(struct pipe_context *pipe,
* unmap vertex/index buffers
*/
for (i = 0; i < i915->num_vertex_buffers; i++) {
- pipe->winsys->buffer_unmap(pipe->winsys, i915->vertex_buffer[i].buffer);
+ pipe_buffer_unmap(pipe->screen, i915->vertex_buffer[i].buffer);
draw_set_mapped_vertex_buffer(draw, i, NULL);
}
if (indexBuffer) {
- pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
+ pipe_buffer_unmap(pipe->screen, indexBuffer);
draw_set_mapped_element_buffer_range(draw, 0, start, start + count - 1, NULL);
}
diff --git a/src/gallium/drivers/i915simple/i915_debug_fp.c b/src/gallium/drivers/i915simple/i915_debug_fp.c
index c024a051a5..48be3e1472 100644
--- a/src/gallium/drivers/i915simple/i915_debug_fp.c
+++ b/src/gallium/drivers/i915simple/i915_debug_fp.c
@@ -29,7 +29,7 @@
#include "i915_reg.h"
#include "i915_debug.h"
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
static void
diff --git a/src/gallium/drivers/i915simple/i915_fpc.h b/src/gallium/drivers/i915simple/i915_fpc.h
index 80a9576304..2f0f99d046 100644
--- a/src/gallium/drivers/i915simple/i915_fpc.h
+++ b/src/gallium/drivers/i915simple/i915_fpc.h
@@ -29,7 +29,6 @@
#ifndef I915_FPC_H
#define I915_FPC_H
-#include "pipe/p_util.h"
#include "i915_context.h"
#include "i915_reg.h"
diff --git a/src/gallium/drivers/i915simple/i915_fpc_emit.c b/src/gallium/drivers/i915simple/i915_fpc_emit.c
index 4bdeefb449..b054ce41d3 100644
--- a/src/gallium/drivers/i915simple/i915_fpc_emit.c
+++ b/src/gallium/drivers/i915simple/i915_fpc_emit.c
@@ -28,6 +28,7 @@
#include "i915_reg.h"
#include "i915_context.h"
#include "i915_fpc.h"
+#include "util/u_math.h"
#define A0_DEST( reg ) (((reg)&UREG_TYPE_NR_MASK)>>UREG_A0_DEST_SHIFT_LEFT)
diff --git a/src/gallium/drivers/i915simple/i915_fpc_translate.c b/src/gallium/drivers/i915simple/i915_fpc_translate.c
index 64432982c4..34b4a846c1 100644
--- a/src/gallium/drivers/i915simple/i915_fpc_translate.c
+++ b/src/gallium/drivers/i915simple/i915_fpc_translate.c
@@ -33,6 +33,8 @@
#include "i915_fpc.h"
#include "pipe/p_shader_tokens.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "util/u_string.h"
#include "tgsi/tgsi_parse.h"
#include "tgsi/tgsi_dump.h"
diff --git a/src/gallium/drivers/i915simple/i915_prim_emit.c b/src/gallium/drivers/i915simple/i915_prim_emit.c
index 9ffa460138..d194c2fb15 100644
--- a/src/gallium/drivers/i915simple/i915_prim_emit.c
+++ b/src/gallium/drivers/i915simple/i915_prim_emit.c
@@ -27,7 +27,9 @@
#include "draw/draw_pipe.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "util/u_pack_color.h"
#include "i915_context.h"
#include "i915_winsys.h"
diff --git a/src/gallium/drivers/i915simple/i915_prim_vbuf.c b/src/gallium/drivers/i915simple/i915_prim_vbuf.c
index aef3682bbf..4fda1ab64f 100644
--- a/src/gallium/drivers/i915simple/i915_prim_vbuf.c
+++ b/src/gallium/drivers/i915simple/i915_prim_vbuf.c
@@ -41,9 +41,10 @@
#include "draw/draw_context.h"
#include "draw/draw_vbuf.h"
#include "pipe/p_debug.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "i915_context.h"
#include "i915_reg.h"
@@ -114,7 +115,7 @@ i915_vbuf_render_allocate_vertices( struct vbuf_render *render,
{
struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
struct i915_context *i915 = i915_render->i915;
- struct pipe_winsys *winsys = i915->pipe.winsys;
+ struct pipe_screen *screen = i915->pipe.screen;
size_t size = (size_t)vertex_size * (size_t)nr_vertices;
/* FIXME: handle failure */
@@ -123,20 +124,20 @@ i915_vbuf_render_allocate_vertices( struct vbuf_render *render,
if (i915_render->vbo_size > size + i915_render->vbo_offset && !i915->vbo_flushed) {
} else {
i915->vbo_flushed = 0;
- pipe_buffer_reference(winsys, &i915_render->vbo, NULL);
+ pipe_buffer_reference(screen, &i915_render->vbo, NULL);
}
if (!i915_render->vbo) {
i915_render->vbo_size = MAX2(size, i915_render->vbo_alloc_size);
i915_render->vbo_offset = 0;
- i915_render->vbo = winsys->buffer_create(winsys,
- 64,
- I915_BUFFER_USAGE_LIT_VERTEX,
- i915_render->vbo_size);
- i915_render->vbo_ptr = winsys->buffer_map(winsys,
- i915_render->vbo,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- winsys->buffer_unmap(winsys, i915_render->vbo);
+ i915_render->vbo = pipe_buffer_create(screen,
+ 64,
+ I915_BUFFER_USAGE_LIT_VERTEX,
+ i915_render->vbo_size);
+ i915_render->vbo_ptr = pipe_buffer_map(screen,
+ i915_render->vbo,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
+ pipe_buffer_unmap(screen, i915_render->vbo);
}
i915->vbo = i915_render->vbo;
@@ -487,7 +488,7 @@ static struct vbuf_render *
i915_vbuf_render_create( struct i915_context *i915 )
{
struct i915_vbuf_render *i915_render = CALLOC_STRUCT(i915_vbuf_render);
- struct pipe_winsys *winsys = i915->pipe.winsys;
+ struct pipe_screen *screen = i915->pipe.screen;
i915_render->i915 = i915;
@@ -509,14 +510,14 @@ i915_vbuf_render_create( struct i915_context *i915 )
i915_render->vbo_alloc_size = 128 * 4096;
i915_render->vbo_size = i915_render->vbo_alloc_size;
i915_render->vbo_offset = 0;
- i915_render->vbo = winsys->buffer_create(winsys,
- 64,
- I915_BUFFER_USAGE_LIT_VERTEX,
- i915_render->vbo_size);
- i915_render->vbo_ptr = winsys->buffer_map(winsys,
- i915_render->vbo,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- winsys->buffer_unmap(winsys, i915_render->vbo);
+ i915_render->vbo = pipe_buffer_create(screen,
+ 64,
+ I915_BUFFER_USAGE_LIT_VERTEX,
+ i915_render->vbo_size);
+ i915_render->vbo_ptr = pipe_buffer_map(screen,
+ i915_render->vbo,
+ PIPE_BUFFER_USAGE_CPU_WRITE);
+ pipe_buffer_unmap(screen, i915_render->vbo);
return &i915_render->base;
}
diff --git a/src/gallium/drivers/i915simple/i915_screen.c b/src/gallium/drivers/i915simple/i915_screen.c
index 0afa17bed8..1c976082df 100644
--- a/src/gallium/drivers/i915simple/i915_screen.c
+++ b/src/gallium/drivers/i915simple/i915_screen.c
@@ -26,8 +26,9 @@
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_winsys.h"
+#include "pipe/p_inlines.h"
#include "util/u_string.h"
#include "i915_reg.h"
@@ -207,7 +208,7 @@ i915_surface_map( struct pipe_screen *screen,
struct pipe_surface *surface,
unsigned flags )
{
- char *map = screen->winsys->buffer_map( screen->winsys, surface->buffer, flags );
+ char *map = pipe_buffer_map( screen, surface->buffer, flags );
if (map == NULL)
return NULL;
@@ -226,7 +227,7 @@ static void
i915_surface_unmap(struct pipe_screen *screen,
struct pipe_surface *surface)
{
- screen->winsys->buffer_unmap( screen->winsys, surface->buffer );
+ pipe_buffer_unmap( screen, surface->buffer );
}
diff --git a/src/gallium/drivers/i915simple/i915_state.c b/src/gallium/drivers/i915simple/i915_state.c
index e8521b385e..d2487d8277 100644
--- a/src/gallium/drivers/i915simple/i915_state.c
+++ b/src/gallium/drivers/i915simple/i915_state.c
@@ -31,8 +31,9 @@
#include "draw/draw_context.h"
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "tgsi/tgsi_parse.h"
#include "i915_context.h"
diff --git a/src/gallium/drivers/i915simple/i915_state_derived.c b/src/gallium/drivers/i915simple/i915_state_derived.c
index 4daccec6e0..488615067c 100644
--- a/src/gallium/drivers/i915simple/i915_state_derived.c
+++ b/src/gallium/drivers/i915simple/i915_state_derived.c
@@ -26,7 +26,7 @@
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "draw/draw_context.h"
#include "draw/draw_vertex.h"
diff --git a/src/gallium/drivers/i915simple/i915_state_dynamic.c b/src/gallium/drivers/i915simple/i915_state_dynamic.c
index 8cfbdddd19..86126a5a15 100644
--- a/src/gallium/drivers/i915simple/i915_state_dynamic.c
+++ b/src/gallium/drivers/i915simple/i915_state_dynamic.c
@@ -30,7 +30,9 @@
#include "i915_context.h"
#include "i915_reg.h"
#include "i915_state.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "util/u_pack_color.h"
#define FILE_DEBUG_FLAG DEBUG_STATE
diff --git a/src/gallium/drivers/i915simple/i915_state_immediate.c b/src/gallium/drivers/i915simple/i915_state_immediate.c
index 2501f2d7cb..8c16bb4e27 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 "pipe/p_util.h"
+#include "util/u_memory.h"
/* All state expressable with the LOAD_STATE_IMMEDIATE_1 packet.
diff --git a/src/gallium/drivers/i915simple/i915_state_sampler.c b/src/gallium/drivers/i915simple/i915_state_sampler.c
index 7868f21ca6..c09c10601b 100644
--- a/src/gallium/drivers/i915simple/i915_state_sampler.c
+++ b/src/gallium/drivers/i915simple/i915_state_sampler.c
@@ -27,7 +27,7 @@
#include "pipe/p_context.h"
#include "pipe/p_state.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "i915_state_inlines.h"
#include "i915_context.h"
diff --git a/src/gallium/drivers/i915simple/i915_surface.c b/src/gallium/drivers/i915simple/i915_surface.c
index 4430e81626..62f1926644 100644
--- a/src/gallium/drivers/i915simple/i915_surface.c
+++ b/src/gallium/drivers/i915simple/i915_surface.c
@@ -30,10 +30,10 @@
#include "i915_state.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
-#include "util/p_tile.h"
+#include "util/u_tile.h"
+#include "util/u_rect.h"
/* Assumes all values are within bounds -- no checking at this level -
diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c
index cf4964b26b..bd87217063 100644
--- a/src/gallium/drivers/i915simple/i915_texture.c
+++ b/src/gallium/drivers/i915simple/i915_texture.c
@@ -34,8 +34,9 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "i915_context.h"
#include "i915_texture.h"
@@ -79,7 +80,7 @@ static unsigned
power_of_two(unsigned x)
{
unsigned value = 1;
- while (value <= x)
+ while (value < x)
value = value << 1;
return value;
}
@@ -206,7 +207,7 @@ i945_miptree_layout_2d( struct i915_texture *tex )
unsigned nblocksy = pt->nblocksy[0];
#if 0 /* used for tiled display targets */
- if (pt->last_level == 0 && pt->cpp == 4)
+ if (pt->last_level == 0 && pt->block.size == 4)
if (i915_displaytarget_layout(tex))
return;
#endif
@@ -220,7 +221,7 @@ i945_miptree_layout_2d( struct i915_texture *tex )
*/
if (pt->last_level > 0) {
unsigned mip1_nblocksx
- = align_int(pf_get_nblocksx(&pt->block, minify(width)), align_x)
+ = align(pf_get_nblocksx(&pt->block, minify(width)), align_x)
+ pf_get_nblocksx(&pt->block, minify(minify(width)));
if (mip1_nblocksx > nblocksx)
@@ -229,14 +230,14 @@ i945_miptree_layout_2d( struct i915_texture *tex )
/* Pitch must be a whole number of dwords
*/
- tex->stride = align_int(tex->stride, 64);
+ tex->stride = align(tex->stride, 64);
tex->total_nblocksy = 0;
for (level = 0; level <= pt->last_level; level++) {
i915_miptree_set_level_info(tex, level, 1, width, height, 1);
i915_miptree_set_image_offset(tex, level, 0, x, y);
- nblocksy = align_int(nblocksy, align_y);
+ nblocksy = align(nblocksy, align_y);
/* Because the images are packed better, the final offset
* might not be the maximal one:
@@ -246,7 +247,7 @@ i945_miptree_layout_2d( struct i915_texture *tex )
/* Layout_below: step right after second mipmap level.
*/
if (level == 1) {
- x += align_int(nblocksx, align_x);
+ x += align(nblocksx, align_x);
}
else {
y += nblocksy;
@@ -644,7 +645,7 @@ i915_texture_release(struct pipe_screen *screen,
DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
- pipe_buffer_reference(screen->winsys, &tex->buffer, NULL);
+ pipe_buffer_reference(screen, &tex->buffer, NULL);
for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
if (tex->image_offset[i])
@@ -683,7 +684,7 @@ i915_get_tex_surface(struct pipe_screen *screen,
ps->refcount = 1;
ps->winsys = ws;
pipe_texture_reference(&ps->texture, pt);
- pipe_buffer_reference(ws, &ps->buffer, tex->buffer);
+ pipe_buffer_reference(screen, &ps->buffer, tex->buffer);
ps->format = pt->format;
ps->width = pt->width[level];
ps->height = pt->height[level];
@@ -727,7 +728,7 @@ i915_texture_blanket(struct pipe_screen * screen,
i915_miptree_set_level_info(tex, 0, 1, base->width[0], base->height[0], 1);
i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
- pipe_buffer_reference(screen->winsys, &tex->buffer, buffer);
+ pipe_buffer_reference(screen, &tex->buffer, buffer);
return &tex->base;
}
@@ -755,7 +756,7 @@ i915_tex_surface_release(struct pipe_screen *screen,
}
pipe_texture_reference(&surf->texture, NULL);
- pipe_buffer_reference(screen->winsys, &surf->buffer, NULL);
+ pipe_buffer_reference(screen, &surf->buffer, NULL);
FREE(surf);
}
diff --git a/src/gallium/drivers/i965simple/brw_cc.c b/src/gallium/drivers/i965simple/brw_cc.c
index 337e4f95f6..79d4150383 100644
--- a/src/gallium/drivers/i965simple/brw_cc.c
+++ b/src/gallium/drivers/i965simple/brw_cc.c
@@ -29,7 +29,8 @@
* Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "brw_context.h"
#include "brw_state.h"
@@ -232,8 +233,7 @@ static void upload_cc_unit( struct brw_context *brw )
cc.cc3.alpha_test_func =
brw_translate_compare_func(brw->attribs.DepthStencil->alpha.func);
- UNCLAMPED_FLOAT_TO_UBYTE(cc.cc7.alpha_ref.ub[0],
- brw->attribs.DepthStencil->alpha.ref);
+ cc.cc7.alpha_ref.ub[0] = float_to_ubyte(brw->attribs.DepthStencil->alpha.ref);
cc.cc3.alpha_test_format = BRW_ALPHATEST_FORMAT_UNORM8;
}
diff --git a/src/gallium/drivers/i965simple/brw_clip_state.c b/src/gallium/drivers/i965simple/brw_clip_state.c
index ea5c05a279..8e78dd51be 100644
--- a/src/gallium/drivers/i965simple/brw_clip_state.c
+++ b/src/gallium/drivers/i965simple/brw_clip_state.c
@@ -32,7 +32,8 @@
#include "brw_context.h"
#include "brw_state.h"
#include "brw_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
static void upload_clip_unit( struct brw_context *brw )
diff --git a/src/gallium/drivers/i965simple/brw_context.c b/src/gallium/drivers/i965simple/brw_context.c
index 8326f7b9c4..96920df008 100644
--- a/src/gallium/drivers/i965simple/brw_context.c
+++ b/src/gallium/drivers/i965simple/brw_context.c
@@ -39,7 +39,7 @@
#include "pipe/p_winsys.h"
#include "pipe/p_context.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_screen.h"
diff --git a/src/gallium/drivers/i965simple/brw_curbe.c b/src/gallium/drivers/i965simple/brw_curbe.c
index 52bbd525c1..824ee7fd6d 100644
--- a/src/gallium/drivers/i965simple/brw_curbe.c
+++ b/src/gallium/drivers/i965simple/brw_curbe.c
@@ -39,7 +39,8 @@
#include "brw_wm.h"
#include "pipe/p_state.h"
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#define FILE_DEBUG_FLAG DEBUG_FALLBACKS
diff --git a/src/gallium/drivers/i965simple/brw_draw_upload.c b/src/gallium/drivers/i965simple/brw_draw_upload.c
index 9c0c78c236..7c20ea52af 100644
--- a/src/gallium/drivers/i965simple/brw_draw_upload.c
+++ b/src/gallium/drivers/i965simple/brw_draw_upload.c
@@ -33,6 +33,7 @@
#include "brw_context.h"
#include "brw_state.h"
+
struct brw_array_state {
union header_union header;
diff --git a/src/gallium/drivers/i965simple/brw_gs_state.c b/src/gallium/drivers/i965simple/brw_gs_state.c
index 3932e9e939..5b8016b2e9 100644
--- a/src/gallium/drivers/i965simple/brw_gs_state.c
+++ b/src/gallium/drivers/i965simple/brw_gs_state.c
@@ -34,7 +34,8 @@
#include "brw_context.h"
#include "brw_state.h"
#include "brw_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
diff --git a/src/gallium/drivers/i965simple/brw_screen.c b/src/gallium/drivers/i965simple/brw_screen.c
index fadfbf94ab..ab7cd624b2 100644
--- a/src/gallium/drivers/i965simple/brw_screen.c
+++ b/src/gallium/drivers/i965simple/brw_screen.c
@@ -26,7 +26,7 @@
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_winsys.h"
#include "util/u_string.h"
diff --git a/src/gallium/drivers/i965simple/brw_sf_state.c b/src/gallium/drivers/i965simple/brw_sf_state.c
index 9acd3ea61b..2a5de61c21 100644
--- a/src/gallium/drivers/i965simple/brw_sf_state.c
+++ b/src/gallium/drivers/i965simple/brw_sf_state.c
@@ -30,11 +30,12 @@
*/
-
#include "brw_context.h"
#include "brw_state.h"
#include "brw_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
static void upload_sf_vp(struct brw_context *brw)
{
diff --git a/src/gallium/drivers/i965simple/brw_shader_info.c b/src/gallium/drivers/i965simple/brw_shader_info.c
index 30f37a99d4..86d877d7ef 100644
--- a/src/gallium/drivers/i965simple/brw_shader_info.c
+++ b/src/gallium/drivers/i965simple/brw_shader_info.c
@@ -1,7 +1,7 @@
#include "brw_context.h"
#include "brw_state.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/i965simple/brw_state.c b/src/gallium/drivers/i965simple/brw_state.c
index 27ca32843d..af46cb546f 100644
--- a/src/gallium/drivers/i965simple/brw_state.c
+++ b/src/gallium/drivers/i965simple/brw_state.c
@@ -31,7 +31,7 @@
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_dump.h"
diff --git a/src/gallium/drivers/i965simple/brw_state_batch.c b/src/gallium/drivers/i965simple/brw_state_batch.c
index 35db76b594..43a1c89fc4 100644
--- a/src/gallium/drivers/i965simple/brw_state_batch.c
+++ b/src/gallium/drivers/i965simple/brw_state_batch.c
@@ -32,7 +32,7 @@
#include "brw_state.h"
#include "brw_winsys.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
/* A facility similar to the data caching code above, which aims to
* prevent identical commands being issued repeatedly.
diff --git a/src/gallium/drivers/i965simple/brw_state_cache.c b/src/gallium/drivers/i965simple/brw_state_cache.c
index b3a5124461..094248fa69 100644
--- a/src/gallium/drivers/i965simple/brw_state_cache.c
+++ b/src/gallium/drivers/i965simple/brw_state_cache.c
@@ -38,7 +38,7 @@
#include "brw_sf.h"
#include "brw_gs.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
diff --git a/src/gallium/drivers/i965simple/brw_state_pool.c b/src/gallium/drivers/i965simple/brw_state_pool.c
index f3174bfe0a..007dc8f9de 100644
--- a/src/gallium/drivers/i965simple/brw_state_pool.c
+++ b/src/gallium/drivers/i965simple/brw_state_pool.c
@@ -43,7 +43,8 @@
*/
#include "pipe/p_winsys.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "brw_context.h"
#include "brw_state.h"
@@ -91,10 +92,10 @@ static void brw_init_pool( struct brw_context *brw,
pool->size = size;
pool->brw = brw;
- pool->buffer = brw->pipe.winsys->buffer_create(brw->pipe.winsys,
- 4096,
- 0 /* DRM_BO_FLAG_MEM_TT */,
- size);
+ pool->buffer = pipe_buffer_create(brw->pipe.screen,
+ 4096,
+ 0 /* DRM_BO_FLAG_MEM_TT */,
+ size);
}
static void brw_destroy_pool( struct brw_context *brw,
@@ -102,7 +103,7 @@ static void brw_destroy_pool( struct brw_context *brw,
{
struct brw_mem_pool *pool = &brw->pool[pool_id];
- pipe_buffer_reference( pool->brw->pipe.winsys,
+ pipe_buffer_reference( pool->brw->pipe.screen,
&pool->buffer,
NULL );
}
diff --git a/src/gallium/drivers/i965simple/brw_state_upload.c b/src/gallium/drivers/i965simple/brw_state_upload.c
index e727601e1e..bac9161b5f 100644
--- a/src/gallium/drivers/i965simple/brw_state_upload.c
+++ b/src/gallium/drivers/i965simple/brw_state_upload.c
@@ -33,7 +33,7 @@
#include "brw_context.h"
#include "brw_state.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
/* This is used to initialize brw->state.atoms[]. We could use this
* list directly except for a single atom, brw_constant_buffer, which
diff --git a/src/gallium/drivers/i965simple/brw_surface.c b/src/gallium/drivers/i965simple/brw_surface.c
index 0be3dfc743..b89756c47b 100644
--- a/src/gallium/drivers/i965simple/brw_surface.c
+++ b/src/gallium/drivers/i965simple/brw_surface.c
@@ -29,10 +29,10 @@
#include "brw_context.h"
#include "brw_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
-#include "util/p_tile.h"
+#include "util/u_tile.h"
+#include "util/u_rect.h"
diff --git a/src/gallium/drivers/i965simple/brw_tex_layout.c b/src/gallium/drivers/i965simple/brw_tex_layout.c
index 8c7725605b..cc0c665e02 100644
--- a/src/gallium/drivers/i965simple/brw_tex_layout.c
+++ b/src/gallium/drivers/i965simple/brw_tex_layout.c
@@ -33,16 +33,16 @@
/* Code to layout images in a mipmap tree for i965.
*/
-#include "brw_tex_layout.h"
-
#include "pipe/p_state.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
-
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "brw_context.h"
+#include "brw_tex_layout.h"
+
#define FILE_DEBUG_FLAG DEBUG_TEXTURE
@@ -144,7 +144,7 @@ static void i945_miptree_layout_2d(struct brw_texture *tex)
*/
if (pt->last_level > 0) {
unsigned mip1_nblocksx
- = align_int(pf_get_nblocksx(&pt->block, minify(width)), align_x)
+ = align(pf_get_nblocksx(&pt->block, minify(width)), align_x)
+ pf_get_nblocksx(&pt->block, minify(minify(width)));
if (mip1_nblocksx > nblocksx)
@@ -153,14 +153,14 @@ static void i945_miptree_layout_2d(struct brw_texture *tex)
/* Pitch must be a whole number of dwords
*/
- tex->stride = align_int(tex->stride, 64);
+ tex->stride = align(tex->stride, 64);
tex->total_nblocksy = 0;
for (level = 0; level <= pt->last_level; level++) {
intel_miptree_set_level_info(tex, level, 1, x, y, width,
height, 1);
- nblocksy = align_int(nblocksy, align_y);
+ nblocksy = align(nblocksy, align_y);
/* Because the images are packed better, the final offset
* might not be the maximal one:
@@ -170,7 +170,7 @@ static void i945_miptree_layout_2d(struct brw_texture *tex)
/* Layout_below: step right after second mipmap level.
*/
if (level == 1) {
- x += align_int(nblocksx, align_x);
+ x += align(nblocksx, align_x);
}
else {
y += nblocksy;
@@ -330,7 +330,7 @@ brw_texture_release_screen(struct pipe_screen *screen,
DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
- pipe_buffer_reference(ws, &tex->buffer, NULL);
+ winsys_buffer_reference(ws, &tex->buffer, NULL);
for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
if (tex->image_offset[i])
@@ -369,7 +369,7 @@ brw_get_tex_surface_screen(struct pipe_screen *screen,
if (ps) {
assert(ps->format);
assert(ps->refcount);
- pipe_buffer_reference(ws, &ps->buffer, tex->buffer);
+ winsys_buffer_reference(ws, &ps->buffer, tex->buffer);
ps->format = pt->format;
ps->width = pt->width[level];
ps->height = pt->height[level];
diff --git a/src/gallium/drivers/i965simple/brw_vs_state.c b/src/gallium/drivers/i965simple/brw_vs_state.c
index c73469929c..1eaff87892 100644
--- a/src/gallium/drivers/i965simple/brw_vs_state.c
+++ b/src/gallium/drivers/i965simple/brw_vs_state.c
@@ -34,7 +34,8 @@
#include "brw_state.h"
#include "brw_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
static void upload_vs_unit( struct brw_context *brw )
{
diff --git a/src/gallium/drivers/i965simple/brw_wm.c b/src/gallium/drivers/i965simple/brw_wm.c
index 7fc5f59a98..8de565b96c 100644
--- a/src/gallium/drivers/i965simple/brw_wm.c
+++ b/src/gallium/drivers/i965simple/brw_wm.c
@@ -35,7 +35,7 @@
#include "brw_wm.h"
#include "brw_eu.h"
#include "brw_state.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
diff --git a/src/gallium/drivers/i965simple/brw_wm_decl.c b/src/gallium/drivers/i965simple/brw_wm_decl.c
index e6f1a44817..d50e66f613 100644
--- a/src/gallium/drivers/i965simple/brw_wm_decl.c
+++ b/src/gallium/drivers/i965simple/brw_wm_decl.c
@@ -2,7 +2,8 @@
#include "brw_context.h"
#include "brw_eu.h"
#include "brw_wm.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/i965simple/brw_wm_glsl.c b/src/gallium/drivers/i965simple/brw_wm_glsl.c
index 6a4a5aef09..ab6410aa60 100644
--- a/src/gallium/drivers/i965simple/brw_wm_glsl.c
+++ b/src/gallium/drivers/i965simple/brw_wm_glsl.c
@@ -2,7 +2,8 @@
#include "brw_context.h"
#include "brw_eu.h"
#include "brw_wm.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/i965simple/brw_wm_sampler_state.c b/src/gallium/drivers/i965simple/brw_wm_sampler_state.c
index b9eaee56ee..52b2909a65 100644
--- a/src/gallium/drivers/i965simple/brw_wm_sampler_state.c
+++ b/src/gallium/drivers/i965simple/brw_wm_sampler_state.c
@@ -34,7 +34,8 @@
#include "brw_state.h"
#include "brw_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#define COMPAREFUNC_ALWAYS 0
diff --git a/src/gallium/drivers/i965simple/brw_wm_state.c b/src/gallium/drivers/i965simple/brw_wm_state.c
index f3aa36b07f..37a9bf919c 100644
--- a/src/gallium/drivers/i965simple/brw_wm_state.c
+++ b/src/gallium/drivers/i965simple/brw_wm_state.c
@@ -34,7 +34,8 @@
#include "brw_state.h"
#include "brw_defines.h"
#include "brw_wm.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
/***********************************************************************
* WM unit - fragment programs and rasterization
diff --git a/src/gallium/drivers/softpipe/sp_clear.c b/src/gallium/drivers/softpipe/sp_clear.c
index 1236706891..dfa46c9fb7 100644
--- a/src/gallium/drivers/softpipe/sp_clear.c
+++ b/src/gallium/drivers/softpipe/sp_clear.c
@@ -31,6 +31,7 @@
#include "pipe/p_defines.h"
+#include "util/u_pack_color.h"
#include "sp_clear.h"
#include "sp_context.h"
#include "sp_surface.h"
@@ -39,8 +40,28 @@
/**
+ * Convert packed pixel from one format to another.
+ */
+static unsigned
+convert_color(enum pipe_format srcFormat, unsigned srcColor,
+ enum pipe_format dstFormat)
+{
+ ubyte r, g, b, a;
+ unsigned dstColor;
+
+ util_unpack_color_ub(srcFormat, &srcColor, &r, &g, &b, &a);
+ util_pack_color_ub(r, g, b, a, dstFormat, &dstColor);
+
+ return dstColor;
+}
+
+
+
+/**
* Clear the given surface to the specified value.
* No masking, no scissor (clear entire buffer).
+ * Note: when clearing a color buffer, the clearValue is always
+ * encoded as PIPE_FORMAT_A8R8G8B8_UNORM.
*/
void
softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps,
@@ -66,7 +87,15 @@ softpipe_clear(struct pipe_context *pipe, struct pipe_surface *ps,
for (i = 0; i < softpipe->framebuffer.num_cbufs; i++) {
if (ps == sp_tile_cache_get_surface(softpipe->cbuf_cache[i])) {
- sp_tile_cache_clear(softpipe->cbuf_cache[i], clearValue);
+ unsigned cv;
+ if (ps->format != PIPE_FORMAT_A8R8G8B8_UNORM) {
+ cv = convert_color(PIPE_FORMAT_A8R8G8B8_UNORM, clearValue,
+ ps->format);
+ }
+ else {
+ cv = clearValue;
+ }
+ sp_tile_cache_clear(softpipe->cbuf_cache[i], cv);
softpipe->framebuffer.cbufs[i]->status = PIPE_SURFACE_STATUS_CLEAR;
}
}
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index 626c3a9d4e..cd1e6663d8 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -32,7 +32,8 @@
#include "draw/draw_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "sp_clear.h"
#include "sp_context.h"
#include "sp_flush.h"
@@ -91,17 +92,19 @@ static void softpipe_destroy( struct pipe_context *pipe )
if (softpipe->draw)
draw_destroy( softpipe->draw );
- softpipe->quad.polygon_stipple->destroy( softpipe->quad.polygon_stipple );
- softpipe->quad.earlyz->destroy( softpipe->quad.earlyz );
- softpipe->quad.shade->destroy( softpipe->quad.shade );
- softpipe->quad.alpha_test->destroy( softpipe->quad.alpha_test );
- softpipe->quad.depth_test->destroy( softpipe->quad.depth_test );
- softpipe->quad.stencil_test->destroy( softpipe->quad.stencil_test );
- softpipe->quad.occlusion->destroy( softpipe->quad.occlusion );
- softpipe->quad.coverage->destroy( softpipe->quad.coverage );
- softpipe->quad.blend->destroy( softpipe->quad.blend );
- softpipe->quad.colormask->destroy( softpipe->quad.colormask );
- softpipe->quad.output->destroy( softpipe->quad.output );
+ for (i = 0; i < SP_NUM_QUAD_THREADS; i++) {
+ softpipe->quad[i].polygon_stipple->destroy( softpipe->quad[i].polygon_stipple );
+ softpipe->quad[i].earlyz->destroy( softpipe->quad[i].earlyz );
+ softpipe->quad[i].shade->destroy( softpipe->quad[i].shade );
+ softpipe->quad[i].alpha_test->destroy( softpipe->quad[i].alpha_test );
+ softpipe->quad[i].depth_test->destroy( softpipe->quad[i].depth_test );
+ softpipe->quad[i].stencil_test->destroy( softpipe->quad[i].stencil_test );
+ softpipe->quad[i].occlusion->destroy( softpipe->quad[i].occlusion );
+ softpipe->quad[i].coverage->destroy( softpipe->quad[i].coverage );
+ softpipe->quad[i].blend->destroy( softpipe->quad[i].blend );
+ softpipe->quad[i].colormask->destroy( softpipe->quad[i].colormask );
+ softpipe->quad[i].output->destroy( softpipe->quad[i].output );
+ }
for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
sp_destroy_tile_cache(softpipe->cbuf_cache[i]);
@@ -112,7 +115,7 @@ static void softpipe_destroy( struct pipe_context *pipe )
for (i = 0; i < Elements(softpipe->constants); i++) {
if (softpipe->constants[i].buffer) {
- pipe_buffer_reference(ws, &softpipe->constants[i].buffer, NULL);
+ winsys_buffer_reference(ws, &softpipe->constants[i].buffer, NULL);
}
}
@@ -128,6 +131,8 @@ softpipe_create( struct pipe_screen *screen,
struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
uint i;
+ util_init_math();
+
#ifdef PIPE_ARCH_X86
softpipe->use_sse = !debug_get_bool_option( "GALLIUM_NOSSE", FALSE );
#else
@@ -202,17 +207,19 @@ softpipe_create( struct pipe_screen *screen,
/* setup quad rendering stages */
- softpipe->quad.polygon_stipple = sp_quad_polygon_stipple_stage(softpipe);
- softpipe->quad.earlyz = sp_quad_earlyz_stage(softpipe);
- softpipe->quad.shade = sp_quad_shade_stage(softpipe);
- softpipe->quad.alpha_test = sp_quad_alpha_test_stage(softpipe);
- softpipe->quad.depth_test = sp_quad_depth_test_stage(softpipe);
- softpipe->quad.stencil_test = sp_quad_stencil_test_stage(softpipe);
- softpipe->quad.occlusion = sp_quad_occlusion_stage(softpipe);
- softpipe->quad.coverage = sp_quad_coverage_stage(softpipe);
- softpipe->quad.blend = sp_quad_blend_stage(softpipe);
- softpipe->quad.colormask = sp_quad_colormask_stage(softpipe);
- softpipe->quad.output = sp_quad_output_stage(softpipe);
+ for (i = 0; i < SP_NUM_QUAD_THREADS; i++) {
+ softpipe->quad[i].polygon_stipple = sp_quad_polygon_stipple_stage(softpipe);
+ softpipe->quad[i].earlyz = sp_quad_earlyz_stage(softpipe);
+ softpipe->quad[i].shade = sp_quad_shade_stage(softpipe);
+ softpipe->quad[i].alpha_test = sp_quad_alpha_test_stage(softpipe);
+ softpipe->quad[i].depth_test = sp_quad_depth_test_stage(softpipe);
+ softpipe->quad[i].stencil_test = sp_quad_stencil_test_stage(softpipe);
+ softpipe->quad[i].occlusion = sp_quad_occlusion_stage(softpipe);
+ softpipe->quad[i].coverage = sp_quad_coverage_stage(softpipe);
+ softpipe->quad[i].blend = sp_quad_blend_stage(softpipe);
+ softpipe->quad[i].colormask = sp_quad_colormask_stage(softpipe);
+ softpipe->quad[i].output = sp_quad_output_stage(softpipe);
+ }
/*
* Create drawing context and plug our rendering stage into it.
@@ -254,3 +261,4 @@ softpipe_create( struct pipe_screen *screen,
softpipe_destroy(&softpipe->pipe);
return NULL;
}
+
diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h
index 078886f93c..2b9a2a8ee5 100644
--- a/src/gallium/drivers/softpipe/sp_context.h
+++ b/src/gallium/drivers/softpipe/sp_context.h
@@ -45,6 +45,10 @@
*/
#define USE_DRAW_STAGE_PSTIPPLE 1
+/* Number of threads working on individual quads.
+ * Setting to 1 disables this feature.
+ */
+#define SP_NUM_QUAD_THREADS 1
struct softpipe_winsys;
struct softpipe_vbuf_render;
@@ -133,7 +137,7 @@ struct softpipe_context {
struct quad_stage *output;
struct quad_stage *first; /**< points to one of the above stages */
- } quad;
+ } quad[SP_NUM_QUAD_THREADS];
/** The primitive drawing context */
struct draw_context *draw;
@@ -151,13 +155,11 @@ struct softpipe_context {
};
-
-
static INLINE struct softpipe_context *
softpipe_context( struct pipe_context *pipe )
{
return (struct softpipe_context *)pipe;
}
-
#endif /* SP_CONTEXT_H */
+
diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c
index 12b44a8211..424bd56846 100644
--- a/src/gallium/drivers/softpipe/sp_draw_arrays.c
+++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c
@@ -34,6 +34,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_context.h"
#include "pipe/p_winsys.h"
+#include "pipe/p_inlines.h"
#include "sp_context.h"
#include "sp_state.h"
@@ -135,7 +136,7 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
*/
for (i = 0; i < sp->num_vertex_buffers; i++) {
void *buf
- = pipe->winsys->buffer_map(pipe->winsys,
+ = pipe_buffer_map(pipe->screen,
sp->vertex_buffer[i].buffer,
PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_vertex_buffer(draw, i, buf);
@@ -143,7 +144,7 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
/* Map index buffer, if present */
if (indexBuffer) {
void *mapped_indexes
- = pipe->winsys->buffer_map(pipe->winsys, indexBuffer,
+ = pipe_buffer_map(pipe->screen, indexBuffer,
PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_element_buffer_range(draw, indexSize,
min_index,
@@ -164,11 +165,11 @@ softpipe_draw_range_elements(struct pipe_context *pipe,
*/
for (i = 0; i < sp->num_vertex_buffers; i++) {
draw_set_mapped_vertex_buffer(draw, i, NULL);
- pipe->winsys->buffer_unmap(pipe->winsys, sp->vertex_buffer[i].buffer);
+ pipe_buffer_unmap(pipe->screen, sp->vertex_buffer[i].buffer);
}
if (indexBuffer) {
draw_set_mapped_element_buffer(draw, 0, NULL);
- pipe->winsys->buffer_unmap(pipe->winsys, indexBuffer);
+ pipe_buffer_unmap(pipe->screen, indexBuffer);
}
diff --git a/src/gallium/drivers/softpipe/sp_flush.c b/src/gallium/drivers/softpipe/sp_flush.c
index e03994b63b..401764bb43 100644
--- a/src/gallium/drivers/softpipe/sp_flush.c
+++ b/src/gallium/drivers/softpipe/sp_flush.c
@@ -73,6 +73,19 @@ softpipe_flush( struct pipe_context *pipe,
softpipe_unmap_surfaces(softpipe);
}
+ /* Enable to dump BMPs of the color/depth buffers each frame */
+#if 0
+ if(flags & PIPE_FLUSH_FRAME) {
+ static unsigned frame_no = 1;
+ static char filename[256];
+ util_snprintf(filename, sizeof(filename), "cbuf_%u.bmp", frame_no);
+ debug_dump_surface_bmp(filename, softpipe->framebuffer.cbufs[0]);
+ util_snprintf(filename, sizeof(filename), "zsbuf_%u.bmp", frame_no);
+ debug_dump_surface_bmp(filename, softpipe->framebuffer.zsbuf);
+ ++frame_no;
+ }
+#endif
+
if (fence)
*fence = NULL;
}
diff --git a/src/gallium/drivers/softpipe/sp_fs_exec.c b/src/gallium/drivers/softpipe/sp_fs_exec.c
index cc171bbc39..701ee4c72f 100644
--- a/src/gallium/drivers/softpipe/sp_fs_exec.c
+++ b/src/gallium/drivers/softpipe/sp_fs_exec.c
@@ -34,7 +34,7 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "tgsi/tgsi_exec.h"
#include "tgsi/tgsi_parse.h"
@@ -106,7 +106,7 @@ exec_run( const struct sp_fragment_shader *base,
/* Compute X, Y, Z, W vals for this quad */
sp_setup_pos_vector(quad->posCoef,
- (float)quad->x0, (float)quad->y0,
+ (float)quad->input.x0, (float)quad->input.y0,
&machine->QuadPos);
return tgsi_exec_machine_run( machine );
diff --git a/src/gallium/drivers/softpipe/sp_fs_llvm.c b/src/gallium/drivers/softpipe/sp_fs_llvm.c
index 20226da78c..34adac5226 100644
--- a/src/gallium/drivers/softpipe/sp_fs_llvm.c
+++ b/src/gallium/drivers/softpipe/sp_fs_llvm.c
@@ -36,7 +36,7 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "tgsi/tgsi_sse2.h"
diff --git a/src/gallium/drivers/softpipe/sp_fs_sse.c b/src/gallium/drivers/softpipe/sp_fs_sse.c
index 8b7da7c747..496ed43df2 100644
--- a/src/gallium/drivers/softpipe/sp_fs_sse.c
+++ b/src/gallium/drivers/softpipe/sp_fs_sse.c
@@ -34,7 +34,7 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "tgsi/tgsi_exec.h"
#include "tgsi/tgsi_sse2.h"
@@ -88,7 +88,7 @@ fs_sse_run( const struct sp_fragment_shader *base,
/* Compute X, Y, Z, W vals for this quad -- place in temp[0] for now */
sp_setup_pos_vector(quad->posCoef,
- (float)quad->x0, (float)quad->y0,
+ (float)quad->input.x0, (float)quad->input.y0,
machine->Temps);
/* init kill mask */
diff --git a/src/gallium/drivers/softpipe/sp_headers.h b/src/gallium/drivers/softpipe/sp_headers.h
index ae2ee210fc..4a42cb3c19 100644
--- a/src/gallium/drivers/softpipe/sp_headers.h
+++ b/src/gallium/drivers/softpipe/sp_headers.h
@@ -59,20 +59,31 @@
* Encodes everything we need to know about a 2x2 pixel block. Uses
* "Channel-Serial" or "SoA" layout.
*/
-struct quad_header {
+struct quad_header_input
+{
int x0;
int y0;
- unsigned mask:4;
+ float coverage[QUAD_SIZE]; /** fragment coverage for antialiasing */
unsigned facing:1; /**< Front (0) or back (1) facing? */
unsigned prim:2; /**< PRIM_POINT, LINE, TRI */
+};
+
+struct quad_header_inout
+{
+ unsigned mask:4;
+};
- struct {
- /** colors in SOA format (rrrr, gggg, bbbb, aaaa) */
- float color[PIPE_MAX_COLOR_BUFS][NUM_CHANNELS][QUAD_SIZE];
- float depth[QUAD_SIZE];
- } outputs;
+struct quad_header_output
+{
+ /** colors in SOA format (rrrr, gggg, bbbb, aaaa) */
+ float color[PIPE_MAX_COLOR_BUFS][NUM_CHANNELS][QUAD_SIZE];
+ float depth[QUAD_SIZE];
+};
- float coverage[QUAD_SIZE]; /** fragment coverage for antialiasing */
+struct quad_header {
+ struct quad_header_input input;
+ struct quad_header_inout inout;
+ struct quad_header_output output;
const struct tgsi_interp_coef *coef;
const struct tgsi_interp_coef *posCoef;
@@ -80,5 +91,5 @@ struct quad_header {
unsigned nr_attrs;
};
-
#endif /* SP_HEADERS_H */
+
diff --git a/src/gallium/drivers/softpipe/sp_prim_setup.c b/src/gallium/drivers/softpipe/sp_prim_setup.c
index 941ab62e00..038ff04d4f 100644
--- a/src/gallium/drivers/softpipe/sp_prim_setup.c
+++ b/src/gallium/drivers/softpipe/sp_prim_setup.c
@@ -41,7 +41,7 @@
#include "sp_prim_setup.h"
#include "draw/draw_pipe.h"
#include "draw/draw_vertex.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
/**
* Triangle setup info (derived from draw_stage).
diff --git a/src/gallium/drivers/softpipe/sp_prim_vbuf.c b/src/gallium/drivers/softpipe/sp_prim_vbuf.c
index e9fae951e0..425e13cd28 100644
--- a/src/gallium/drivers/softpipe/sp_prim_vbuf.c
+++ b/src/gallium/drivers/softpipe/sp_prim_vbuf.c
@@ -43,6 +43,7 @@
#include "sp_setup.h"
#include "draw/draw_context.h"
#include "draw/draw_vbuf.h"
+#include "util/u_memory.h"
#define SP_MAX_VBUF_INDEXES 1024
diff --git a/src/gallium/drivers/softpipe/sp_quad.c b/src/gallium/drivers/softpipe/sp_quad.c
index bc83d78ea1..892ef87ee9 100644
--- a/src/gallium/drivers/softpipe/sp_quad.c
+++ b/src/gallium/drivers/softpipe/sp_quad.c
@@ -33,29 +33,33 @@
static void
sp_push_quad_first(
struct softpipe_context *sp,
- struct quad_stage *quad )
+ struct quad_stage *quad,
+ uint i )
{
- quad->next = sp->quad.first;
- sp->quad.first = quad;
+ quad->next = sp->quad[i].first;
+ sp->quad[i].first = quad;
}
static void
sp_build_depth_stencil(
- struct softpipe_context *sp )
+ struct softpipe_context *sp,
+ uint i )
{
if (sp->depth_stencil->stencil[0].enabled ||
sp->depth_stencil->stencil[1].enabled) {
- sp_push_quad_first( sp, sp->quad.stencil_test );
+ sp_push_quad_first( sp, sp->quad[i].stencil_test, i );
}
else if (sp->depth_stencil->depth.enabled &&
sp->framebuffer.zsbuf) {
- sp_push_quad_first( sp, sp->quad.depth_test );
+ sp_push_quad_first( sp, sp->quad[i].depth_test, i );
}
}
void
sp_build_quad_pipeline(struct softpipe_context *sp)
{
+ uint i;
+
boolean early_depth_test =
sp->depth_stencil->depth.enabled &&
sp->framebuffer.zsbuf &&
@@ -64,49 +68,51 @@ sp_build_quad_pipeline(struct softpipe_context *sp)
!sp->fs->info.writes_z;
/* build up the pipeline in reverse order... */
-
- sp->quad.first = sp->quad.output;
-
- if (sp->blend->colormask != 0xf) {
- sp_push_quad_first( sp, sp->quad.colormask );
- }
-
- if (sp->blend->blend_enable ||
- sp->blend->logicop_enable) {
- sp_push_quad_first( sp, sp->quad.blend );
- }
-
- if (sp->depth_stencil->depth.occlusion_count) {
- sp_push_quad_first( sp, sp->quad.occlusion );
- }
-
- if (sp->rasterizer->poly_smooth ||
- sp->rasterizer->line_smooth ||
- sp->rasterizer->point_smooth) {
- sp_push_quad_first( sp, sp->quad.coverage );
- }
-
- if (!early_depth_test) {
- sp_build_depth_stencil( sp );
- }
-
- if (sp->depth_stencil->alpha.enabled) {
- sp_push_quad_first( sp, sp->quad.alpha_test );
- }
-
- /* XXX always enable shader? */
- if (1) {
- sp_push_quad_first( sp, sp->quad.shade );
- }
-
- if (early_depth_test) {
- sp_build_depth_stencil( sp );
- sp_push_quad_first( sp, sp->quad.earlyz );
- }
+ for (i = 0; i < SP_NUM_QUAD_THREADS; i++) {
+ sp->quad[i].first = sp->quad[i].output;
+
+ if (sp->blend->colormask != 0xf) {
+ sp_push_quad_first( sp, sp->quad[i].colormask, i );
+ }
+
+ if (sp->blend->blend_enable ||
+ sp->blend->logicop_enable) {
+ sp_push_quad_first( sp, sp->quad[i].blend, i );
+ }
+
+ if (sp->depth_stencil->depth.occlusion_count) {
+ sp_push_quad_first( sp, sp->quad[i].occlusion, i );
+ }
+
+ if (sp->rasterizer->poly_smooth ||
+ sp->rasterizer->line_smooth ||
+ sp->rasterizer->point_smooth) {
+ sp_push_quad_first( sp, sp->quad[i].coverage, i );
+ }
+
+ if (!early_depth_test) {
+ sp_build_depth_stencil( sp, i );
+ }
+
+ if (sp->depth_stencil->alpha.enabled) {
+ sp_push_quad_first( sp, sp->quad[i].alpha_test, i );
+ }
+
+ /* XXX always enable shader? */
+ if (1) {
+ sp_push_quad_first( sp, sp->quad[i].shade, i );
+ }
+
+ if (early_depth_test) {
+ sp_build_depth_stencil( sp, i );
+ sp_push_quad_first( sp, sp->quad[i].earlyz, i );
+ }
#if !USE_DRAW_STAGE_PSTIPPLE
- if (sp->rasterizer->poly_stipple_enable) {
- sp_push_quad_first( sp, sp->quad.polygon_stipple );
- }
+ if (sp->rasterizer->poly_stipple_enable) {
+ sp_push_quad_first( sp, sp->quad[i].polygon_stipple, i );
+ }
#endif
+ }
}
+
diff --git a/src/gallium/drivers/softpipe/sp_quad_alpha_test.c b/src/gallium/drivers/softpipe/sp_quad_alpha_test.c
index 7a42b08ef5..5bebd141e9 100644
--- a/src/gallium/drivers/softpipe/sp_quad_alpha_test.c
+++ b/src/gallium/drivers/softpipe/sp_quad_alpha_test.c
@@ -7,7 +7,7 @@
#include "sp_headers.h"
#include "sp_quad.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
static void
@@ -17,11 +17,10 @@ alpha_test_quad(struct quad_stage *qs, struct quad_header *quad)
const float ref = softpipe->depth_stencil->alpha.ref;
unsigned passMask = 0x0, j;
const uint cbuf = 0; /* only output[0].alpha is tested */
- const float *aaaa = quad->outputs.color[cbuf][3];
+ const float *aaaa = quad->output.color[cbuf][3];
switch (softpipe->depth_stencil->alpha.func) {
case PIPE_FUNC_NEVER:
- quad->mask = 0x0;
break;
case PIPE_FUNC_LESS:
/*
@@ -76,9 +75,9 @@ alpha_test_quad(struct quad_stage *qs, struct quad_header *quad)
assert(0);
}
- quad->mask &= passMask;
+ quad->inout.mask &= passMask;
- if (quad->mask)
+ if (quad->inout.mask)
qs->next->run(qs->next, quad);
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_blend.c b/src/gallium/drivers/softpipe/sp_quad_blend.c
index 74c6bff84a..6f64c6e584 100644
--- a/src/gallium/drivers/softpipe/sp_quad_blend.c
+++ b/src/gallium/drivers/softpipe/sp_quad_blend.c
@@ -31,7 +31,8 @@
*/
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_surface.h"
@@ -113,14 +114,14 @@ logicop_quad(struct quad_stage *qs, struct quad_header *quad)
struct softpipe_cached_tile *
tile = sp_get_cached_tile(softpipe,
softpipe->cbuf_cache[cbuf],
- quad->x0, quad->y0);
- float (*quadColor)[4] = quad->outputs.color[cbuf];
+ quad->input.x0, quad->input.y0);
+ float (*quadColor)[4] = quad->output.color[cbuf];
uint i, j;
/* get/swizzle dest colors */
for (j = 0; j < QUAD_SIZE; j++) {
- int x = (quad->x0 & (TILE_SIZE-1)) + (j & 1);
- int y = (quad->y0 & (TILE_SIZE-1)) + (j >> 1);
+ int x = (quad->input.x0 & (TILE_SIZE-1)) + (j & 1);
+ int y = (quad->input.y0 & (TILE_SIZE-1)) + (j >> 1);
for (i = 0; i < 4; i++) {
dest[i][j] = tile->data.color[y][x][i];
}
@@ -128,15 +129,15 @@ logicop_quad(struct quad_stage *qs, struct quad_header *quad)
/* convert to ubyte */
for (j = 0; j < 4; j++) { /* loop over R,G,B,A channels */
- UNCLAMPED_FLOAT_TO_UBYTE(dst[j][0], dest[j][0]); /* P0 */
- UNCLAMPED_FLOAT_TO_UBYTE(dst[j][1], dest[j][1]); /* P1 */
- UNCLAMPED_FLOAT_TO_UBYTE(dst[j][2], dest[j][2]); /* P2 */
- UNCLAMPED_FLOAT_TO_UBYTE(dst[j][3], dest[j][3]); /* P3 */
-
- UNCLAMPED_FLOAT_TO_UBYTE(src[j][0], quadColor[j][0]); /* P0 */
- UNCLAMPED_FLOAT_TO_UBYTE(src[j][1], quadColor[j][1]); /* P1 */
- UNCLAMPED_FLOAT_TO_UBYTE(src[j][2], quadColor[j][2]); /* P2 */
- UNCLAMPED_FLOAT_TO_UBYTE(src[j][3], quadColor[j][3]); /* P3 */
+ dst[j][0] = float_to_ubyte(dest[j][0]); /* P0 */
+ dst[j][1] = float_to_ubyte(dest[j][1]); /* P1 */
+ dst[j][2] = float_to_ubyte(dest[j][2]); /* P2 */
+ dst[j][3] = float_to_ubyte(dest[j][3]); /* P3 */
+
+ src[j][0] = float_to_ubyte(quadColor[j][0]); /* P0 */
+ src[j][1] = float_to_ubyte(quadColor[j][1]); /* P1 */
+ src[j][2] = float_to_ubyte(quadColor[j][2]); /* P2 */
+ src[j][3] = float_to_ubyte(quadColor[j][3]); /* P3 */
}
switch (softpipe->blend->logicop_func) {
@@ -209,10 +210,10 @@ logicop_quad(struct quad_stage *qs, struct quad_header *quad)
}
for (j = 0; j < 4; j++) {
- quadColor[j][0] = UBYTE_TO_FLOAT(res[j][0]);
- quadColor[j][1] = UBYTE_TO_FLOAT(res[j][1]);
- quadColor[j][2] = UBYTE_TO_FLOAT(res[j][2]);
- quadColor[j][3] = UBYTE_TO_FLOAT(res[j][3]);
+ quadColor[j][0] = ubyte_to_float(res[j][0]);
+ quadColor[j][1] = ubyte_to_float(res[j][1]);
+ quadColor[j][2] = ubyte_to_float(res[j][2]);
+ quadColor[j][3] = ubyte_to_float(res[j][3]);
}
}
@@ -243,14 +244,14 @@ blend_quad(struct quad_stage *qs, struct quad_header *quad)
struct softpipe_cached_tile *tile
= sp_get_cached_tile(softpipe,
softpipe->cbuf_cache[cbuf],
- quad->x0, quad->y0);
- float (*quadColor)[4] = quad->outputs.color[cbuf];
+ quad->input.x0, quad->input.y0);
+ float (*quadColor)[4] = quad->output.color[cbuf];
uint i, j;
/* get/swizzle dest colors */
for (j = 0; j < QUAD_SIZE; j++) {
- int x = (quad->x0 & (TILE_SIZE-1)) + (j & 1);
- int y = (quad->y0 & (TILE_SIZE-1)) + (j >> 1);
+ int x = (quad->input.x0 & (TILE_SIZE-1)) + (j & 1);
+ int y = (quad->input.y0 & (TILE_SIZE-1)) + (j >> 1);
for (i = 0; i < 4; i++) {
dest[i][j] = tile->data.color[y][x][i];
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_bufloop.c b/src/gallium/drivers/softpipe/sp_quad_bufloop.c
index b3db428ef1..92e9af09c1 100644
--- a/src/gallium/drivers/softpipe/sp_quad_bufloop.c
+++ b/src/gallium/drivers/softpipe/sp_quad_bufloop.c
@@ -1,5 +1,5 @@
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_surface.h"
diff --git a/src/gallium/drivers/softpipe/sp_quad_colormask.c b/src/gallium/drivers/softpipe/sp_quad_colormask.c
index 7fe080990b..f32bdfab78 100644
--- a/src/gallium/drivers/softpipe/sp_quad_colormask.c
+++ b/src/gallium/drivers/softpipe/sp_quad_colormask.c
@@ -31,7 +31,8 @@
*/
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_surface.h"
@@ -55,14 +56,14 @@ colormask_quad(struct quad_stage *qs, struct quad_header *quad)
struct softpipe_cached_tile *tile
= sp_get_cached_tile(softpipe,
softpipe->cbuf_cache[cbuf],
- quad->x0, quad->y0);
- float (*quadColor)[4] = quad->outputs.color[cbuf];
+ quad->input.x0, quad->input.y0);
+ float (*quadColor)[4] = quad->output.color[cbuf];
uint i, j;
/* get/swizzle dest colors */
for (j = 0; j < QUAD_SIZE; j++) {
- int x = (quad->x0 & (TILE_SIZE-1)) + (j & 1);
- int y = (quad->y0 & (TILE_SIZE-1)) + (j >> 1);
+ int x = (quad->input.x0 & (TILE_SIZE-1)) + (j & 1);
+ int y = (quad->input.y0 & (TILE_SIZE-1)) + (j >> 1);
for (i = 0; i < 4; i++) {
dest[i][j] = tile->data.color[y][x][i];
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_coverage.c b/src/gallium/drivers/softpipe/sp_quad_coverage.c
index dd5ebb2296..ee29aa7dfe 100644
--- a/src/gallium/drivers/softpipe/sp_quad_coverage.c
+++ b/src/gallium/drivers/softpipe/sp_quad_coverage.c
@@ -33,7 +33,7 @@
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_quad.h"
@@ -47,19 +47,19 @@ coverage_quad(struct quad_stage *qs, struct quad_header *quad)
{
struct softpipe_context *softpipe = qs->softpipe;
- if ((softpipe->rasterizer->poly_smooth && quad->prim == PRIM_TRI) ||
- (softpipe->rasterizer->line_smooth && quad->prim == PRIM_LINE) ||
- (softpipe->rasterizer->point_smooth && quad->prim == PRIM_POINT)) {
+ if ((softpipe->rasterizer->poly_smooth && quad->input.prim == PRIM_TRI) ||
+ (softpipe->rasterizer->line_smooth && quad->input.prim == PRIM_LINE) ||
+ (softpipe->rasterizer->point_smooth && quad->input.prim == PRIM_POINT)) {
uint cbuf;
/* loop over colorbuffer outputs */
for (cbuf = 0; cbuf < softpipe->framebuffer.num_cbufs; cbuf++) {
- float (*quadColor)[4] = quad->outputs.color[cbuf];
+ float (*quadColor)[4] = quad->output.color[cbuf];
unsigned j;
for (j = 0; j < QUAD_SIZE; j++) {
- assert(quad->coverage[j] >= 0.0);
- assert(quad->coverage[j] <= 1.0);
- quadColor[3][j] *= quad->coverage[j];
+ assert(quad->input.coverage[j] >= 0.0);
+ assert(quad->input.coverage[j] <= 1.0);
+ quadColor[3][j] *= quad->input.coverage[j];
}
}
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c
index 0c82692c6e..523bd3e080 100644
--- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c
+++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c
@@ -30,7 +30,7 @@
*/
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_surface.h"
@@ -60,7 +60,7 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
unsigned zmask = 0;
unsigned j;
struct softpipe_cached_tile *tile
- = sp_get_cached_tile(softpipe, softpipe->zsbuf_cache, quad->x0, quad->y0);
+ = sp_get_cached_tile(softpipe, softpipe->zsbuf_cache, quad->input.x0, quad->input.y0);
assert(ps); /* shouldn't get here if there's no zbuffer */
@@ -79,12 +79,12 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
float scale = 65535.0;
for (j = 0; j < QUAD_SIZE; j++) {
- qzzzz[j] = (unsigned) (quad->outputs.depth[j] * scale);
+ qzzzz[j] = (unsigned) (quad->output.depth[j] * scale);
}
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
bzzzz[j] = tile->data.depth16[y][x];
}
}
@@ -94,12 +94,12 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
double scale = (double) (uint) ~0UL;
for (j = 0; j < QUAD_SIZE; j++) {
- qzzzz[j] = (unsigned) (quad->outputs.depth[j] * scale);
+ qzzzz[j] = (unsigned) (quad->output.depth[j] * scale);
}
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
bzzzz[j] = tile->data.depth32[y][x];
}
}
@@ -111,12 +111,12 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
float scale = (float) ((1 << 24) - 1);
for (j = 0; j < QUAD_SIZE; j++) {
- qzzzz[j] = (unsigned) (quad->outputs.depth[j] * scale);
+ qzzzz[j] = (unsigned) (quad->output.depth[j] * scale);
}
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
bzzzz[j] = tile->data.depth32[y][x] & 0xffffff;
}
}
@@ -128,12 +128,12 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
float scale = (float) ((1 << 24) - 1);
for (j = 0; j < QUAD_SIZE; j++) {
- qzzzz[j] = (unsigned) (quad->outputs.depth[j] * scale);
+ qzzzz[j] = (unsigned) (quad->output.depth[j] * scale);
}
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
bzzzz[j] = tile->data.depth32[y][x] >> 8;
}
}
@@ -192,14 +192,14 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
assert(0);
}
- quad->mask &= zmask;
+ quad->inout.mask &= zmask;
if (softpipe->depth_stencil->depth.writemask) {
/* This is also efficient with sse / spe instructions:
*/
for (j = 0; j < QUAD_SIZE; j++) {
- if (quad->mask & (1 << j)) {
+ if (quad->inout.mask & (1 << j)) {
bzzzz[j] = qzzzz[j];
}
}
@@ -208,8 +208,8 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
switch (format) {
case PIPE_FORMAT_Z16_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
tile->data.depth16[y][x] = (ushort) bzzzz[j];
}
break;
@@ -218,15 +218,15 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
/* (yes, this falls through to a different case than above) */
case PIPE_FORMAT_Z32_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
tile->data.depth32[y][x] = bzzzz[j];
}
break;
case PIPE_FORMAT_S8Z24_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
uint s8z24 = tile->data.depth32[y][x];
s8z24 = (s8z24 & 0xff000000) | bzzzz[j];
tile->data.depth32[y][x] = s8z24;
@@ -234,8 +234,8 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
break;
case PIPE_FORMAT_Z24S8_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
uint z24s8 = tile->data.depth32[y][x];
z24s8 = (z24s8 & 0xff) | (bzzzz[j] << 8);
tile->data.depth32[y][x] = z24s8;
@@ -243,8 +243,8 @@ sp_depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
break;
case PIPE_FORMAT_Z24X8_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
tile->data.depth32[y][x] = bzzzz[j] << 8;
}
break;
@@ -260,7 +260,7 @@ depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
{
sp_depth_test_quad(qs, quad);
- if (quad->mask)
+ if (quad->inout.mask)
qs->next->run(qs->next, quad);
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_earlyz.c b/src/gallium/drivers/softpipe/sp_quad_earlyz.c
index 22ea99049f..6e2dde304e 100644
--- a/src/gallium/drivers/softpipe/sp_quad_earlyz.c
+++ b/src/gallium/drivers/softpipe/sp_quad_earlyz.c
@@ -30,7 +30,7 @@
*/
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_headers.h"
#include "sp_quad.h"
@@ -45,16 +45,16 @@ earlyz_quad(
struct quad_stage *qs,
struct quad_header *quad )
{
- const float fx = (float) quad->x0;
- const float fy = (float) quad->y0;
+ const float fx = (float) quad->input.x0;
+ const float fy = (float) quad->input.y0;
const float dzdx = quad->posCoef->dadx[2];
const float dzdy = quad->posCoef->dady[2];
const float z0 = quad->posCoef->a0[2] + dzdx * fx + dzdy * fy;
- quad->outputs.depth[0] = z0;
- quad->outputs.depth[1] = z0 + dzdx;
- quad->outputs.depth[2] = z0 + dzdy;
- quad->outputs.depth[3] = z0 + dzdx + dzdy;
+ quad->output.depth[0] = z0;
+ quad->output.depth[1] = z0 + dzdx;
+ quad->output.depth[2] = z0 + dzdy;
+ quad->output.depth[3] = z0 + dzdx + dzdy;
qs->next->run( qs->next, quad );
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_fs.c b/src/gallium/drivers/softpipe/sp_quad_fs.c
index 8c88c192f8..1f0cb3e035 100644
--- a/src/gallium/drivers/softpipe/sp_quad_fs.c
+++ b/src/gallium/drivers/softpipe/sp_quad_fs.c
@@ -35,7 +35,8 @@
* all the enabled attributes run contiguously.
*/
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "pipe/p_defines.h"
#include "pipe/p_shader_tokens.h"
@@ -84,7 +85,7 @@ shade_quad(
machine->InterpCoefs = quad->coef;
/* run shader */
- quad->mask &= softpipe->fs->run( softpipe->fs,
+ quad->inout.mask &= softpipe->fs->run( softpipe->fs,
&qss->machine,
quad );
@@ -100,16 +101,16 @@ shade_quad(
case TGSI_SEMANTIC_COLOR:
{
uint cbuf = sem_index[i];
- memcpy(quad->outputs.color[cbuf],
+ memcpy(quad->output.color[cbuf],
&machine->Outputs[i].xyzw[0].f[0],
- sizeof(quad->outputs.color[0]) );
+ sizeof(quad->output.color[0]) );
}
break;
case TGSI_SEMANTIC_POSITION:
{
uint j;
for (j = 0; j < 4; j++) {
- quad->outputs.depth[j] = machine->Outputs[0].xyzw[2].f[j];
+ quad->output.depth[j] = machine->Outputs[0].xyzw[2].f[j];
}
z_written = TRUE;
}
@@ -121,20 +122,20 @@ shade_quad(
if (!z_written) {
/* compute Z values now, as in the quad earlyz stage */
/* XXX we should really only do this if the earlyz stage is not used */
- const float fx = (float) quad->x0;
- const float fy = (float) quad->y0;
+ const float fx = (float) quad->input.x0;
+ const float fy = (float) quad->input.y0;
const float dzdx = quad->posCoef->dadx[2];
const float dzdy = quad->posCoef->dady[2];
const float z0 = quad->posCoef->a0[2] + dzdx * fx + dzdy * fy;
- quad->outputs.depth[0] = z0;
- quad->outputs.depth[1] = z0 + dzdx;
- quad->outputs.depth[2] = z0 + dzdy;
- quad->outputs.depth[3] = z0 + dzdx + dzdy;
+ quad->output.depth[0] = z0;
+ quad->output.depth[1] = z0 + dzdx;
+ quad->output.depth[2] = z0 + dzdy;
+ quad->output.depth[3] = z0 + dzdx + dzdy;
}
/* shader may cull fragments */
- if( quad->mask ) {
+ if( quad->inout.mask ) {
qs->next->run( qs->next, quad );
}
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_occlusion.c b/src/gallium/drivers/softpipe/sp_quad_occlusion.c
index 54254df1f1..169bd82876 100644
--- a/src/gallium/drivers/softpipe/sp_quad_occlusion.c
+++ b/src/gallium/drivers/softpipe/sp_quad_occlusion.c
@@ -33,7 +33,7 @@
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_surface.h"
@@ -54,7 +54,7 @@ occlusion_count_quad(struct quad_stage *qs, struct quad_header *quad)
{
struct softpipe_context *softpipe = qs->softpipe;
- softpipe->occlusion_count += count_bits(quad->mask);
+ softpipe->occlusion_count += count_bits(quad->inout.mask);
qs->next->run(qs->next, quad);
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_output.c b/src/gallium/drivers/softpipe/sp_quad_output.c
index 40083138a4..d05e12d1d9 100644
--- a/src/gallium/drivers/softpipe/sp_quad_output.c
+++ b/src/gallium/drivers/softpipe/sp_quad_output.c
@@ -25,7 +25,7 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_headers.h"
#include "sp_surface.h"
@@ -41,8 +41,8 @@ static void
output_quad(struct quad_stage *qs, struct quad_header *quad)
{
/* in-tile pos: */
- const int itx = quad->x0 % TILE_SIZE;
- const int ity = quad->y0 % TILE_SIZE;
+ const int itx = quad->input.x0 % TILE_SIZE;
+ const int ity = quad->input.y0 % TILE_SIZE;
struct softpipe_context *softpipe = qs->softpipe;
uint cbuf;
@@ -52,13 +52,13 @@ output_quad(struct quad_stage *qs, struct quad_header *quad)
struct softpipe_cached_tile *tile
= sp_get_cached_tile(softpipe,
softpipe->cbuf_cache[cbuf],
- quad->x0, quad->y0);
- float (*quadColor)[4] = quad->outputs.color[cbuf];
+ quad->input.x0, quad->input.y0);
+ float (*quadColor)[4] = quad->output.color[cbuf];
int i, j;
/* get/swizzle dest colors */
for (j = 0; j < QUAD_SIZE; j++) {
- if (quad->mask & (1 << j)) {
+ if (quad->inout.mask & (1 << j)) {
int x = itx + (j & 1);
int y = ity + (j >> 1);
for (i = 0; i < 4; i++) { /* loop over color chans */
diff --git a/src/gallium/drivers/softpipe/sp_quad_stencil.c b/src/gallium/drivers/softpipe/sp_quad_stencil.c
index b4c7e942fa..abb5487748 100644
--- a/src/gallium/drivers/softpipe/sp_quad_stencil.c
+++ b/src/gallium/drivers/softpipe/sp_quad_stencil.c
@@ -10,7 +10,7 @@
#include "sp_tile_cache.h"
#include "sp_quad.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
/** Only 8-bit stencil supported */
@@ -206,9 +206,9 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
ubyte ref, wrtMask, valMask;
ubyte stencilVals[QUAD_SIZE];
struct softpipe_cached_tile *tile
- = sp_get_cached_tile(softpipe, softpipe->zsbuf_cache, quad->x0, quad->y0);
+ = sp_get_cached_tile(softpipe, softpipe->zsbuf_cache, quad->input.x0, quad->input.y0);
uint j;
- uint face = quad->facing;
+ uint face = quad->input.facing;
if (!softpipe->depth_stencil->stencil[1].enabled) {
/* single-sided stencil test, use front (face=0) state */
@@ -231,22 +231,22 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
switch (ps->format) {
case PIPE_FORMAT_S8Z24_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
stencilVals[j] = tile->data.depth32[y][x] >> 24;
}
break;
case PIPE_FORMAT_Z24S8_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
stencilVals[j] = tile->data.depth32[y][x] & 0xff;
}
break;
case PIPE_FORMAT_S8_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
stencilVals[j] = tile->data.stencil8[y][x];
}
break;
@@ -258,35 +258,35 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
{
unsigned passMask, failMask;
passMask = do_stencil_test(stencilVals, func, ref, valMask);
- failMask = quad->mask & ~passMask;
- quad->mask &= passMask;
+ failMask = quad->inout.mask & ~passMask;
+ quad->inout.mask &= passMask;
if (failOp != PIPE_STENCIL_OP_KEEP) {
apply_stencil_op(stencilVals, failMask, failOp, ref, wrtMask);
}
}
- if (quad->mask) {
+ if (quad->inout.mask) {
/* now the pixels that passed the stencil test are depth tested */
if (softpipe->depth_stencil->depth.enabled) {
- const unsigned origMask = quad->mask;
+ const unsigned origMask = quad->inout.mask;
sp_depth_test_quad(qs, quad); /* quad->mask is updated */
/* update stencil buffer values according to z pass/fail result */
if (zFailOp != PIPE_STENCIL_OP_KEEP) {
- const unsigned failMask = origMask & ~quad->mask;
+ const unsigned failMask = origMask & ~quad->inout.mask;
apply_stencil_op(stencilVals, failMask, zFailOp, ref, wrtMask);
}
if (zPassOp != PIPE_STENCIL_OP_KEEP) {
- const unsigned passMask = origMask & quad->mask;
+ const unsigned passMask = origMask & quad->inout.mask;
apply_stencil_op(stencilVals, passMask, zPassOp, ref, wrtMask);
}
}
else {
/* no depth test, apply Zpass operator to stencil buffer values */
- apply_stencil_op(stencilVals, quad->mask, zPassOp, ref, wrtMask);
+ apply_stencil_op(stencilVals, quad->inout.mask, zPassOp, ref, wrtMask);
}
}
@@ -295,8 +295,8 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
switch (ps->format) {
case PIPE_FORMAT_S8Z24_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
uint s8z24 = tile->data.depth32[y][x];
s8z24 = (stencilVals[j] << 24) | (s8z24 & 0xffffff);
tile->data.depth32[y][x] = s8z24;
@@ -304,8 +304,8 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
break;
case PIPE_FORMAT_Z24S8_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
uint z24s8 = tile->data.depth32[y][x];
z24s8 = (z24s8 & 0xffffff00) | stencilVals[j];
tile->data.depth32[y][x] = z24s8;
@@ -313,8 +313,8 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
break;
case PIPE_FORMAT_S8_UNORM:
for (j = 0; j < QUAD_SIZE; j++) {
- int x = quad->x0 % TILE_SIZE + (j & 1);
- int y = quad->y0 % TILE_SIZE + (j >> 1);
+ int x = quad->input.x0 % TILE_SIZE + (j & 1);
+ int y = quad->input.y0 % TILE_SIZE + (j >> 1);
tile->data.stencil8[y][x] = stencilVals[j];
}
break;
@@ -322,7 +322,7 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
assert(0);
}
- if (quad->mask)
+ if (quad->inout.mask)
qs->next->run(qs->next, quad);
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_stipple.c b/src/gallium/drivers/softpipe/sp_quad_stipple.c
index f1e9b80e09..ccf37f6be5 100644
--- a/src/gallium/drivers/softpipe/sp_quad_stipple.c
+++ b/src/gallium/drivers/softpipe/sp_quad_stipple.c
@@ -7,7 +7,7 @@
#include "sp_headers.h"
#include "sp_quad.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
/**
@@ -19,17 +19,17 @@ stipple_quad(struct quad_stage *qs, struct quad_header *quad)
static const uint bit31 = 1 << 31;
static const uint bit30 = 1 << 30;
- if (quad->prim == PRIM_TRI) {
+ if (quad->input.prim == PRIM_TRI) {
struct softpipe_context *softpipe = qs->softpipe;
/* need to invert Y to index into OpenGL's stipple pattern */
int y0, y1;
uint stipple0, stipple1;
if (softpipe->rasterizer->origin_lower_left) {
- y0 = softpipe->framebuffer.height - 1 - quad->y0;
+ y0 = softpipe->framebuffer.height - 1 - quad->input.y0;
y1 = y0 - 1;
}
else {
- y0 = quad->y0;
+ y0 = quad->input.y0;
y1 = y0 + 1;
}
stipple0 = softpipe->poly_stipple.stipple[y0 % 32];
@@ -37,18 +37,18 @@ stipple_quad(struct quad_stage *qs, struct quad_header *quad)
#if 1
{
- const int col0 = quad->x0 % 32;
+ const int col0 = quad->input.x0 % 32;
if ((stipple0 & (bit31 >> col0)) == 0)
- quad->mask &= ~MASK_TOP_LEFT;
+ quad->inout.mask &= ~MASK_TOP_LEFT;
if ((stipple0 & (bit30 >> col0)) == 0)
- quad->mask &= ~MASK_TOP_RIGHT;
+ quad->inout.mask &= ~MASK_TOP_RIGHT;
if ((stipple1 & (bit31 >> col0)) == 0)
- quad->mask &= ~MASK_BOTTOM_LEFT;
+ quad->inout.mask &= ~MASK_BOTTOM_LEFT;
if ((stipple1 & (bit30 >> col0)) == 0)
- quad->mask &= ~MASK_BOTTOM_RIGHT;
+ quad->inout.mask &= ~MASK_BOTTOM_RIGHT;
}
#else
/* We'd like to use this code, but we'd need to redefine
@@ -56,11 +56,11 @@ stipple_quad(struct quad_stage *qs, struct quad_header *quad)
* and similarly for the BOTTOM bits. But that may have undesirable
* side effects elsewhere.
*/
- const int col0 = 30 - (quad->x0 % 32);
- quad->mask &= (((stipple0 >> col0) & 0x3) |
+ const int col0 = 30 - (quad->input.x0 % 32);
+ quad->inout.mask &= (((stipple0 >> col0) & 0x3) |
(((stipple1 >> col0) & 0x3) << 2));
#endif
- if (!quad->mask)
+ if (!quad->inout.mask)
return;
}
diff --git a/src/gallium/drivers/softpipe/sp_query.c b/src/gallium/drivers/softpipe/sp_query.c
index adf9ccf64c..2106ee1d23 100644
--- a/src/gallium/drivers/softpipe/sp_query.c
+++ b/src/gallium/drivers/softpipe/sp_query.c
@@ -32,7 +32,7 @@
#include "draw/draw_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_query.h"
diff --git a/src/gallium/drivers/softpipe/sp_screen.c b/src/gallium/drivers/softpipe/sp_screen.c
index f6b3d7ac24..9644dbd168 100644
--- a/src/gallium/drivers/softpipe/sp_screen.c
+++ b/src/gallium/drivers/softpipe/sp_screen.c
@@ -26,7 +26,7 @@
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_winsys.h"
#include "pipe/p_defines.h"
#include "pipe/p_screen.h"
diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c
index b7f2f16307..bc8263c33e 100644
--- a/src/gallium/drivers/softpipe/sp_setup.c
+++ b/src/gallium/drivers/softpipe/sp_setup.c
@@ -42,8 +42,11 @@
#include "draw/draw_context.h"
#include "draw/draw_private.h"
#include "draw/draw_vertex.h"
-#include "pipe/p_util.h"
#include "pipe/p_shader_tokens.h"
+#include "pipe/p_thread.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+
#define DEBUG_VERTS 0
#define DEBUG_FRAGS 0
@@ -59,6 +62,87 @@ struct edge {
int lines; /**< number of lines on this edge */
};
+#if SP_NUM_QUAD_THREADS > 1
+
+/* Set to 1 if you want other threads to be instantly
+ * notified of pending jobs.
+ */
+#define INSTANT_NOTEMPTY_NOTIFY 0
+
+struct thread_info
+{
+ struct setup_context *setup;
+ uint id;
+ pipe_thread handle;
+};
+
+struct quad_job;
+
+typedef void (* quad_job_routine)( struct setup_context *setup, uint thread, struct quad_job *job );
+
+struct quad_job
+{
+ struct quad_header_input input;
+ struct quad_header_inout inout;
+ quad_job_routine routine;
+};
+
+#define NUM_QUAD_JOBS 64
+
+struct quad_job_que
+{
+ struct quad_job jobs[NUM_QUAD_JOBS];
+ uint first;
+ uint last;
+ pipe_mutex que_mutex;
+ pipe_condvar que_notfull_condvar;
+ pipe_condvar que_notempty_condvar;
+ uint jobs_added;
+ uint jobs_done;
+ pipe_condvar que_done_condvar;
+};
+
+static void
+add_quad_job( struct quad_job_que *que, struct quad_header *quad, quad_job_routine routine )
+{
+#if INSTANT_NOTEMPTY_NOTIFY
+ boolean empty;
+#endif
+
+ /* Wait for empty slot, see if the que is empty.
+ */
+ pipe_mutex_lock( que->que_mutex );
+ while ((que->last + 1) % NUM_QUAD_JOBS == que->first) {
+#if !INSTANT_NOTEMPTY_NOTIFY
+ pipe_condvar_broadcast( que->que_notempty_condvar );
+#endif
+ pipe_condvar_wait( que->que_notfull_condvar, que->que_mutex );
+ }
+#if INSTANT_NOTEMPTY_NOTIFY
+ empty = que->last == que->first;
+#endif
+ que->jobs_added++;
+ pipe_mutex_unlock( que->que_mutex );
+
+ /* Submit new job.
+ */
+ que->jobs[que->last].input = quad->input;
+ que->jobs[que->last].inout = quad->inout;
+ que->jobs[que->last].routine = routine;
+ que->last = (que->last + 1) % NUM_QUAD_JOBS;
+
+#if INSTANT_NOTEMPTY_NOTIFY
+ /* If the que was empty, notify consumers there's a job to be done.
+ */
+ if (empty) {
+ pipe_mutex_lock( que->que_mutex );
+ pipe_condvar_broadcast( que->que_notempty_condvar );
+ pipe_mutex_unlock( que->que_mutex );
+ }
+#endif
+}
+
+#endif
/**
* Triangle setup info (derived from draw_stage).
@@ -86,6 +170,11 @@ struct setup_context {
struct tgsi_interp_coef posCoef; /* For Z, W */
struct quad_header quad;
+#if SP_NUM_QUAD_THREADS > 1
+ struct quad_job_que que;
+ struct thread_info threads[SP_NUM_QUAD_THREADS];
+#endif
+
struct {
int left[2]; /**< [0] = row0, [1] = row1 */
int right[2];
@@ -102,8 +191,78 @@ struct setup_context {
unsigned winding; /* which winding to cull */
};
+#if SP_NUM_QUAD_THREADS > 1
+
+static PIPE_THREAD_ROUTINE( quad_thread, param )
+{
+ struct thread_info *info = (struct thread_info *) param;
+ struct quad_job_que *que = &info->setup->que;
+
+ for (;;) {
+ struct quad_job job;
+ boolean full;
+
+ /* Wait for an available job.
+ */
+ pipe_mutex_lock( que->que_mutex );
+ while (que->last == que->first)
+ pipe_condvar_wait( que->que_notempty_condvar, que->que_mutex );
+
+ /* See if the que is full.
+ */
+ full = (que->last + 1) % NUM_QUAD_JOBS == que->first;
+
+ /* Take a job and remove it from que.
+ */
+ job = que->jobs[que->first];
+ que->first = (que->first + 1) % NUM_QUAD_JOBS;
+
+ /* Notify the producer if the que is not full.
+ */
+ if (full)
+ pipe_condvar_signal( que->que_notfull_condvar );
+ pipe_mutex_unlock( que->que_mutex );
+
+ job.routine( info->setup, info->id, &job );
+
+ /* Notify the producer if that's the last finished job.
+ */
+ pipe_mutex_lock( que->que_mutex );
+ que->jobs_done++;
+ if (que->jobs_added == que->jobs_done)
+ pipe_condvar_signal( que->que_done_condvar );
+ pipe_mutex_unlock( que->que_mutex );
+ }
+ return NULL;
+}
+
+#define WAIT_FOR_COMPLETION(setup) \
+ do {\
+ pipe_mutex_lock( setup->que.que_mutex );\
+ if (!INSTANT_NOTEMPTY_NOTIFY)\
+ pipe_condvar_broadcast( setup->que.que_notempty_condvar );\
+ while (setup->que.jobs_added != setup->que.jobs_done)\
+ pipe_condvar_wait( setup->que.que_done_condvar, setup->que.que_mutex );\
+ pipe_mutex_unlock( setup->que.que_mutex );\
+ } while (0)
+#else
+
+#define WAIT_FOR_COMPLETION(setup) ((void) 0)
+
+#endif
+
+/**
+ * Test if x is NaN or +/- infinity.
+ */
+static INLINE boolean
+is_inf_or_nan(float x)
+{
+ union fi tmp;
+ tmp.f = x;
+ return !(int)((unsigned int)((tmp.i & 0x7fffffff)-0x7f800000) >> 31);
+}
static boolean cull_tri( struct setup_context *setup,
@@ -131,7 +290,7 @@ static boolean cull_tri( struct setup_context *setup,
* Clip setup->quad against the scissor/surface bounds.
*/
static INLINE void
-quad_clip(struct setup_context *setup)
+quad_clip( struct setup_context *setup, struct quad_header *quad )
{
const struct pipe_scissor_state *cliprect = &setup->softpipe->cliprect;
const int minx = (int) cliprect->minx;
@@ -139,22 +298,22 @@ quad_clip(struct setup_context *setup)
const int miny = (int) cliprect->miny;
const int maxy = (int) cliprect->maxy;
- if (setup->quad.x0 >= maxx ||
- setup->quad.y0 >= maxy ||
- setup->quad.x0 + 1 < minx ||
- setup->quad.y0 + 1 < miny) {
+ if (quad->input.x0 >= maxx ||
+ quad->input.y0 >= maxy ||
+ quad->input.x0 + 1 < minx ||
+ quad->input.y0 + 1 < miny) {
/* totally clipped */
- setup->quad.mask = 0x0;
+ quad->inout.mask = 0x0;
return;
}
- if (setup->quad.x0 < minx)
- setup->quad.mask &= (MASK_BOTTOM_RIGHT | MASK_TOP_RIGHT);
- if (setup->quad.y0 < miny)
- setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_BOTTOM_RIGHT);
- if (setup->quad.x0 == maxx - 1)
- setup->quad.mask &= (MASK_BOTTOM_LEFT | MASK_TOP_LEFT);
- if (setup->quad.y0 == maxy - 1)
- setup->quad.mask &= (MASK_TOP_LEFT | MASK_TOP_RIGHT);
+ if (quad->input.x0 < minx)
+ quad->inout.mask &= (MASK_BOTTOM_RIGHT | MASK_TOP_RIGHT);
+ if (quad->input.y0 < miny)
+ quad->inout.mask &= (MASK_BOTTOM_LEFT | MASK_BOTTOM_RIGHT);
+ if (quad->input.x0 == maxx - 1)
+ quad->inout.mask &= (MASK_BOTTOM_LEFT | MASK_TOP_LEFT);
+ if (quad->input.y0 == maxy - 1)
+ quad->inout.mask &= (MASK_TOP_LEFT | MASK_TOP_RIGHT);
}
@@ -162,35 +321,59 @@ quad_clip(struct setup_context *setup)
* Emit a quad (pass to next stage) with clipping.
*/
static INLINE void
-clip_emit_quad(struct setup_context *setup)
+clip_emit_quad( struct setup_context *setup, struct quad_header *quad, uint thread )
{
- quad_clip(setup);
- if (setup->quad.mask) {
+ quad_clip( setup, quad );
+ if (quad->inout.mask) {
struct softpipe_context *sp = setup->softpipe;
- sp->quad.first->run(sp->quad.first, &setup->quad);
+
+ sp->quad[thread].first->run( sp->quad[thread].first, quad );
}
}
+#if SP_NUM_QUAD_THREADS > 1
+
+static void
+clip_emit_quad_job( struct setup_context *setup, uint thread, struct quad_job *job )
+{
+ struct quad_header quad;
+
+ quad.input = job->input;
+ quad.inout = job->inout;
+ quad.coef = setup->quad.coef;
+ quad.posCoef = setup->quad.posCoef;
+ quad.nr_attrs = setup->quad.nr_attrs;
+ clip_emit_quad( setup, &quad, thread );
+}
+
+#define CLIP_EMIT_QUAD(setup) add_quad_job( &setup->que, &setup->quad, clip_emit_quad_job )
+
+#else
+
+#define CLIP_EMIT_QUAD(setup) clip_emit_quad( setup, &setup->quad, 0 )
+
+#endif
/**
* Emit a quad (pass to next stage). No clipping is done.
*/
static INLINE void
-emit_quad( struct setup_context *setup, int x, int y, unsigned mask )
+emit_quad( struct setup_context *setup, struct quad_header *quad, uint thread )
{
struct softpipe_context *sp = setup->softpipe;
- setup->quad.x0 = x;
- setup->quad.y0 = y;
- setup->quad.mask = mask;
+#if DEBUG_FRAGS
+ uint mask = quad->inout.mask;
+#endif
+
#if DEBUG_FRAGS
if (mask & 1) setup->numFragsEmitted++;
if (mask & 2) setup->numFragsEmitted++;
if (mask & 4) setup->numFragsEmitted++;
if (mask & 8) setup->numFragsEmitted++;
#endif
- sp->quad.first->run(sp->quad.first, &setup->quad);
+ sp->quad[thread].first->run( sp->quad[thread].first, quad );
#if DEBUG_FRAGS
- mask = setup->quad.mask;
+ mask = quad->inout.mask;
if (mask & 1) setup->numFragsWritten++;
if (mask & 2) setup->numFragsWritten++;
if (mask & 4) setup->numFragsWritten++;
@@ -198,6 +381,38 @@ emit_quad( struct setup_context *setup, int x, int y, unsigned mask )
#endif
}
+#if SP_NUM_QUAD_THREADS > 1
+
+static void
+emit_quad_job( struct setup_context *setup, uint thread, struct quad_job *job )
+{
+ struct quad_header quad;
+
+ quad.input = job->input;
+ quad.inout = job->inout;
+ quad.coef = setup->quad.coef;
+ quad.posCoef = setup->quad.posCoef;
+ quad.nr_attrs = setup->quad.nr_attrs;
+ emit_quad( setup, &quad, thread );
+}
+
+#define EMIT_QUAD(setup,x,y,mask) do {\
+ setup->quad.input.x0 = x;\
+ setup->quad.input.y0 = y;\
+ setup->quad.inout.mask = mask;\
+ add_quad_job( &setup->que, &setup->quad, emit_quad_job );\
+ } while (0)
+
+#else
+
+#define EMIT_QUAD(setup,x,y,mask) do {\
+ setup->quad.input.x0 = x;\
+ setup->quad.input.y0 = y;\
+ setup->quad.inout.mask = mask;\
+ emit_quad( setup, &setup->quad, 0 );\
+ } while (0)
+
+#endif
/**
* Given an X or Y coordinate, return the block/quad coordinate that it
@@ -237,7 +452,7 @@ static void flush_spans( struct setup_context *setup )
mask |= MASK_TOP_RIGHT;
if (x+1 >= xleft1 && x+1 < xright1)
mask |= MASK_BOTTOM_RIGHT;
- emit_quad( setup, x, setup->span.y, mask );
+ EMIT_QUAD( setup, x, setup->span.y, mask );
}
break;
@@ -251,7 +466,7 @@ static void flush_spans( struct setup_context *setup )
mask |= MASK_TOP_LEFT;
if (x+1 >= xleft0 && x+1 < xright0)
mask |= MASK_TOP_RIGHT;
- emit_quad( setup, x, setup->span.y, mask );
+ EMIT_QUAD( setup, x, setup->span.y, mask );
}
break;
@@ -265,7 +480,7 @@ static void flush_spans( struct setup_context *setup )
mask |= MASK_BOTTOM_LEFT;
if (x+1 >= xleft1 && x+1 < xright1)
mask |= MASK_BOTTOM_RIGHT;
- emit_quad( setup, x, setup->span.y, mask );
+ EMIT_QUAD( setup, x, setup->span.y, mask );
}
break;
@@ -293,6 +508,9 @@ static void print_vertex(const struct setup_context *setup,
}
#endif
+/**
+ * \return FALSE if coords are inf/nan (cull the tri), TRUE otherwise
+ */
static boolean setup_sort_vertices( struct setup_context *setup,
float det,
const float (*v0)[4],
@@ -370,17 +588,20 @@ static boolean setup_sort_vertices( struct setup_context *setup,
setup->ebot.dx * setup->emaj.dy);
setup->oneoverarea = 1.0f / area;
+
/*
debug_printf("%s one-over-area %f area %f det %f\n",
__FUNCTION__, setup->oneoverarea, area, det );
*/
+ if (is_inf_or_nan(setup->oneoverarea))
+ return FALSE;
}
/* We need to know if this is a front or back-facing triangle for:
* - the GLSL gl_FrontFacing fragment attribute (bool)
* - two-sided stencil test
*/
- setup->quad.facing = (det > 0.0) ^ (setup->softpipe->rasterizer->front_winding == PIPE_WINDING_CW);
+ setup->quad.input.facing = (det > 0.0) ^ (setup->softpipe->rasterizer->front_winding == PIPE_WINDING_CW);
return TRUE;
}
@@ -577,7 +798,7 @@ static void setup_tri_coefficients( struct setup_context *setup )
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
/* FOG.y = front/back facing XXX fix this */
- setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.facing;
+ setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.input.facing;
setup->coef[fragSlot].dadx[1] = 0.0;
setup->coef[fragSlot].dady[1] = 0.0;
}
@@ -595,18 +816,18 @@ static void setup_tri_edges( struct setup_context *setup )
float vmid_y = setup->vmid[0][1] - 0.5f;
float vmax_y = setup->vmax[0][1] - 0.5f;
- setup->emaj.sy = CEILF(vmin_y);
- setup->emaj.lines = (int) CEILF(vmax_y - setup->emaj.sy);
+ setup->emaj.sy = ceilf(vmin_y);
+ setup->emaj.lines = (int) ceilf(vmax_y - setup->emaj.sy);
setup->emaj.dxdy = setup->emaj.dx / setup->emaj.dy;
setup->emaj.sx = vmin_x + (setup->emaj.sy - vmin_y) * setup->emaj.dxdy;
- setup->etop.sy = CEILF(vmid_y);
- setup->etop.lines = (int) CEILF(vmax_y - setup->etop.sy);
+ setup->etop.sy = ceilf(vmid_y);
+ setup->etop.lines = (int) ceilf(vmax_y - setup->etop.sy);
setup->etop.dxdy = setup->etop.dx / setup->etop.dy;
setup->etop.sx = vmid_x + (setup->etop.sy - vmid_y) * setup->etop.dxdy;
- setup->ebot.sy = CEILF(vmin_y);
- setup->ebot.lines = (int) CEILF(vmid_y - setup->ebot.sy);
+ setup->ebot.sy = ceilf(vmin_y);
+ setup->ebot.lines = (int) ceilf(vmid_y - setup->ebot.sy);
setup->ebot.dxdy = setup->ebot.dx / setup->ebot.dy;
setup->ebot.sx = vmin_x + (setup->ebot.sy - vmin_y) * setup->ebot.dxdy;
}
@@ -742,11 +963,12 @@ void setup_tri( struct setup_context *setup,
if (cull_tri( setup, det ))
return;
- setup_sort_vertices( setup, det, v0, v1, v2 );
+ if (!setup_sort_vertices( setup, det, v0, v1, v2 ))
+ return;
setup_tri_coefficients( setup );
setup_tri_edges( setup );
- setup->quad.prim = PRIM_TRI;
+ setup->quad.input.prim = PRIM_TRI;
setup->span.y = 0;
setup->span.y_flags = 0;
@@ -771,6 +993,8 @@ void setup_tri( struct setup_context *setup,
flush_spans( setup );
+ WAIT_FOR_COMPLETION(setup);
+
#if DEBUG_FRAGS
printf("Tri: %u frags emitted, %u written\n",
setup->numFragsEmitted,
@@ -827,7 +1051,7 @@ line_persp_coeff(struct setup_context *setup,
* Compute the setup->coef[] array dadx, dady, a0 values.
* Must be called after setup->vmin,vmax are initialized.
*/
-static INLINE void
+static INLINE boolean
setup_line_coefficients(struct setup_context *setup,
const float (*v0)[4],
const float (*v1)[4])
@@ -836,6 +1060,7 @@ setup_line_coefficients(struct setup_context *setup,
const struct sp_fragment_shader *spfs = softpipe->fs;
const struct vertex_info *vinfo = softpipe_get_vertex_info(softpipe);
uint fragSlot;
+ float area;
/* use setup->vmin, vmax to point to vertices */
setup->vprovoke = v1;
@@ -844,9 +1069,12 @@ setup_line_coefficients(struct setup_context *setup,
setup->emaj.dx = setup->vmax[0][0] - setup->vmin[0][0];
setup->emaj.dy = setup->vmax[0][1] - setup->vmin[0][1];
- /* NOTE: this is not really 1/area */
- setup->oneoverarea = 1.0f / (setup->emaj.dx * setup->emaj.dx +
- setup->emaj.dy * setup->emaj.dy);
+
+ /* NOTE: this is not really area but something proportional to it */
+ area = setup->emaj.dx * setup->emaj.dx + setup->emaj.dy * setup->emaj.dy;
+ if (area == 0.0f || is_inf_or_nan(area))
+ return FALSE;
+ setup->oneoverarea = 1.0f / area;
/* z and w are done by linear interpolation:
*/
@@ -881,11 +1109,12 @@ setup_line_coefficients(struct setup_context *setup,
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
/* FOG.y = front/back facing XXX fix this */
- setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.facing;
+ setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.input.facing;
setup->coef[fragSlot].dadx[1] = 0.0;
setup->coef[fragSlot].dady[1] = 0.0;
}
}
+ return TRUE;
}
@@ -901,20 +1130,20 @@ plot(struct setup_context *setup, int x, int y)
const int quadY = y - iy;
const int mask = (1 << ix) << (2 * iy);
- if (quadX != setup->quad.x0 ||
- quadY != setup->quad.y0)
+ if (quadX != setup->quad.input.x0 ||
+ quadY != setup->quad.input.y0)
{
/* flush prev quad, start new quad */
- if (setup->quad.x0 != -1)
- clip_emit_quad(setup);
+ if (setup->quad.input.x0 != -1)
+ CLIP_EMIT_QUAD(setup);
- setup->quad.x0 = quadX;
- setup->quad.y0 = quadY;
- setup->quad.mask = 0x0;
+ setup->quad.input.x0 = quadX;
+ setup->quad.input.y0 = quadY;
+ setup->quad.inout.mask = 0x0;
}
- setup->quad.mask |= mask;
+ setup->quad.inout.mask |= mask;
}
@@ -942,18 +1171,19 @@ setup_line(struct setup_context *setup,
print_vertex(setup, v1);
#endif
- assert(v0[0][0] < 1.0e9);
- assert(v0[0][1] < 1.0e9);
- assert(v1[0][0] < 1.0e9);
- assert(v1[0][1] < 1.0e9);
-
if (setup->softpipe->no_rast)
return;
if (dx == 0 && dy == 0)
return;
- setup_line_coefficients(setup, v0, v1);
+ if (!setup_line_coefficients(setup, v0, v1))
+ return;
+
+ assert(v0[0][0] < 1.0e9);
+ assert(v0[0][1] < 1.0e9);
+ assert(v1[0][0] < 1.0e9);
+ assert(v1[0][1] < 1.0e9);
if (dx < 0) {
dx = -dx; /* make positive */
@@ -974,16 +1204,16 @@ setup_line(struct setup_context *setup,
assert(dx >= 0);
assert(dy >= 0);
- setup->quad.x0 = setup->quad.y0 = -1;
- setup->quad.mask = 0x0;
- setup->quad.prim = PRIM_LINE;
+ setup->quad.input.x0 = setup->quad.input.y0 = -1;
+ setup->quad.inout.mask = 0x0;
+ setup->quad.input.prim = PRIM_LINE;
/* XXX temporary: set coverage to 1.0 so the line appears
* if AA mode happens to be enabled.
*/
- setup->quad.coverage[0] =
- setup->quad.coverage[1] =
- setup->quad.coverage[2] =
- setup->quad.coverage[3] = 1.0;
+ setup->quad.input.coverage[0] =
+ setup->quad.input.coverage[1] =
+ setup->quad.input.coverage[2] =
+ setup->quad.input.coverage[3] = 1.0;
if (dx > dy) {
/*** X-major line ***/
@@ -1027,9 +1257,11 @@ setup_line(struct setup_context *setup,
}
/* draw final quad */
- if (setup->quad.mask) {
- clip_emit_quad(setup);
+ if (setup->quad.inout.mask) {
+ CLIP_EMIT_QUAD(setup);
}
+
+ WAIT_FOR_COMPLETION(setup);
}
@@ -1123,22 +1355,22 @@ setup_point( struct setup_context *setup,
if (spfs->info.input_semantic_name[fragSlot] == TGSI_SEMANTIC_FOG) {
/* FOG.y = front/back facing XXX fix this */
- setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.facing;
+ setup->coef[fragSlot].a0[1] = 1.0f - setup->quad.input.facing;
setup->coef[fragSlot].dadx[1] = 0.0;
setup->coef[fragSlot].dady[1] = 0.0;
}
}
- setup->quad.prim = PRIM_POINT;
+ setup->quad.input.prim = PRIM_POINT;
if (halfSize <= 0.5 && !round) {
/* special case for 1-pixel points */
const int ix = ((int) x) & 1;
const int iy = ((int) y) & 1;
- setup->quad.x0 = (int) x - ix;
- setup->quad.y0 = (int) y - iy;
- setup->quad.mask = (1 << ix) << (2 * iy);
- clip_emit_quad(setup);
+ setup->quad.input.x0 = (int) x - ix;
+ setup->quad.input.y0 = (int) y - iy;
+ setup->quad.inout.mask = (1 << ix) << (2 * iy);
+ CLIP_EMIT_QUAD(setup);
}
else {
if (round) {
@@ -1158,15 +1390,15 @@ setup_point( struct setup_context *setup,
for (ix = ixmin; ix <= ixmax; ix += 2) {
float dx, dy, dist2, cover;
- setup->quad.mask = 0x0;
+ setup->quad.inout.mask = 0x0;
dx = (ix + 0.5f) - x;
dy = (iy + 0.5f) - y;
dist2 = dx * dx + dy * dy;
if (dist2 <= rmax2) {
cover = 1.0F - (dist2 - rmin2) * cscale;
- setup->quad.coverage[QUAD_TOP_LEFT] = MIN2(cover, 1.0f);
- setup->quad.mask |= MASK_TOP_LEFT;
+ setup->quad.input.coverage[QUAD_TOP_LEFT] = MIN2(cover, 1.0f);
+ setup->quad.inout.mask |= MASK_TOP_LEFT;
}
dx = (ix + 1.5f) - x;
@@ -1174,8 +1406,8 @@ setup_point( struct setup_context *setup,
dist2 = dx * dx + dy * dy;
if (dist2 <= rmax2) {
cover = 1.0F - (dist2 - rmin2) * cscale;
- setup->quad.coverage[QUAD_TOP_RIGHT] = MIN2(cover, 1.0f);
- setup->quad.mask |= MASK_TOP_RIGHT;
+ setup->quad.input.coverage[QUAD_TOP_RIGHT] = MIN2(cover, 1.0f);
+ setup->quad.inout.mask |= MASK_TOP_RIGHT;
}
dx = (ix + 0.5f) - x;
@@ -1183,8 +1415,8 @@ setup_point( struct setup_context *setup,
dist2 = dx * dx + dy * dy;
if (dist2 <= rmax2) {
cover = 1.0F - (dist2 - rmin2) * cscale;
- setup->quad.coverage[QUAD_BOTTOM_LEFT] = MIN2(cover, 1.0f);
- setup->quad.mask |= MASK_BOTTOM_LEFT;
+ setup->quad.input.coverage[QUAD_BOTTOM_LEFT] = MIN2(cover, 1.0f);
+ setup->quad.inout.mask |= MASK_BOTTOM_LEFT;
}
dx = (ix + 1.5f) - x;
@@ -1192,14 +1424,14 @@ setup_point( struct setup_context *setup,
dist2 = dx * dx + dy * dy;
if (dist2 <= rmax2) {
cover = 1.0F - (dist2 - rmin2) * cscale;
- setup->quad.coverage[QUAD_BOTTOM_RIGHT] = MIN2(cover, 1.0f);
- setup->quad.mask |= MASK_BOTTOM_RIGHT;
+ setup->quad.input.coverage[QUAD_BOTTOM_RIGHT] = MIN2(cover, 1.0f);
+ setup->quad.inout.mask |= MASK_BOTTOM_RIGHT;
}
- if (setup->quad.mask) {
- setup->quad.x0 = ix;
- setup->quad.y0 = iy;
- clip_emit_quad(setup);
+ if (setup->quad.inout.mask) {
+ setup->quad.input.x0 = ix;
+ setup->quad.input.y0 = iy;
+ CLIP_EMIT_QUAD(setup);
}
}
}
@@ -1243,14 +1475,16 @@ setup_point( struct setup_context *setup,
mask &= (MASK_BOTTOM_LEFT | MASK_TOP_LEFT);
}
- setup->quad.mask = mask;
- setup->quad.x0 = ix;
- setup->quad.y0 = iy;
- clip_emit_quad(setup);
+ setup->quad.inout.mask = mask;
+ setup->quad.input.x0 = ix;
+ setup->quad.input.y0 = iy;
+ CLIP_EMIT_QUAD(setup);
}
}
}
}
+
+ WAIT_FOR_COMPLETION(setup);
}
void setup_prepare( struct setup_context *setup )
@@ -1275,7 +1509,9 @@ void setup_prepare( struct setup_context *setup )
/* Note: nr_attrs is only used for debugging (vertex printing) */
setup->quad.nr_attrs = draw_num_vs_outputs(sp->draw);
- sp->quad.first->begin(sp->quad.first);
+ for (i = 0; i < SP_NUM_QUAD_THREADS; i++) {
+ sp->quad[i].first->begin( sp->quad[i].first );
+ }
if (sp->reduced_api_prim == PIPE_PRIM_TRIANGLES &&
sp->rasterizer->fill_cw == PIPE_POLYGON_MODE_FILL &&
@@ -1303,11 +1539,31 @@ void setup_destroy_context( struct setup_context *setup )
struct setup_context *setup_create_context( struct softpipe_context *softpipe )
{
struct setup_context *setup = CALLOC_STRUCT(setup_context);
+#if SP_NUM_QUAD_THREADS > 1
+ uint i;
+#endif
setup->softpipe = softpipe;
setup->quad.coef = setup->coef;
setup->quad.posCoef = &setup->posCoef;
+#if SP_NUM_QUAD_THREADS > 1
+ setup->que.first = 0;
+ setup->que.last = 0;
+ pipe_mutex_init( setup->que.que_mutex );
+ pipe_condvar_init( setup->que.que_notfull_condvar );
+ pipe_condvar_init( setup->que.que_notempty_condvar );
+ setup->que.jobs_added = 0;
+ setup->que.jobs_done = 0;
+ pipe_condvar_init( setup->que.que_done_condvar );
+ for (i = 0; i < SP_NUM_QUAD_THREADS; i++) {
+ setup->threads[i].setup = setup;
+ setup->threads[i].id = i;
+ setup->threads[i].handle = pipe_thread_create( quad_thread, &setup->threads[i] );
+ }
+#endif
+
return setup;
}
+
diff --git a/src/gallium/drivers/softpipe/sp_state_blend.c b/src/gallium/drivers/softpipe/sp_state_blend.c
index 2d40d6bd8f..384fe559af 100644
--- a/src/gallium/drivers/softpipe/sp_state_blend.c
+++ b/src/gallium/drivers/softpipe/sp_state_blend.c
@@ -28,7 +28,7 @@
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_state.h"
diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c
index f10a1fa471..6b6a4c3ff3 100644
--- a/src/gallium/drivers/softpipe/sp_state_derived.c
+++ b/src/gallium/drivers/softpipe/sp_state_derived.c
@@ -25,7 +25,8 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "pipe/p_shader_tokens.h"
#include "draw/draw_context.h"
#include "draw/draw_vertex.h"
diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c
index 76fe6bfef9..e5b609cf6c 100644
--- a/src/gallium/drivers/softpipe/sp_state_fs.c
+++ b/src/gallium/drivers/softpipe/sp_state_fs.c
@@ -30,7 +30,7 @@
#include "sp_fs.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "pipe/p_winsys.h"
#include "pipe/p_shader_tokens.h"
@@ -152,7 +152,7 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
assert(index == 0);
/* note: reference counting */
- pipe_buffer_reference(ws,
+ winsys_buffer_reference(ws,
&softpipe->constants[shader].buffer,
buf ? buf->buffer : NULL);
softpipe->constants[shader].size = buf ? buf->size : 0;
diff --git a/src/gallium/drivers/softpipe/sp_state_rasterizer.c b/src/gallium/drivers/softpipe/sp_state_rasterizer.c
index 98e04352db..87b7219683 100644
--- a/src/gallium/drivers/softpipe/sp_state_rasterizer.c
+++ b/src/gallium/drivers/softpipe/sp_state_rasterizer.c
@@ -26,7 +26,7 @@
**************************************************************************/
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_state.h"
#include "draw/draw_context.h"
diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c
index 033288a0aa..99a28c0d7e 100644
--- a/src/gallium/drivers/softpipe/sp_state_sampler.c
+++ b/src/gallium/drivers/softpipe/sp_state_sampler.c
@@ -29,7 +29,7 @@
* Brian Paul
*/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
#include "pipe/p_inlines.h"
#include "draw/draw_context.h"
diff --git a/src/gallium/drivers/softpipe/sp_surface.c b/src/gallium/drivers/softpipe/sp_surface.c
index 7dc15c38d1..6ade732698 100644
--- a/src/gallium/drivers/softpipe/sp_surface.c
+++ b/src/gallium/drivers/softpipe/sp_surface.c
@@ -25,129 +25,14 @@
*
**************************************************************************/
-#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
-#include "pipe/p_inlines.h"
-#include "pipe/p_winsys.h"
-#include "util/p_tile.h"
+#include "util/u_rect.h"
#include "sp_context.h"
-#include "sp_surface.h"
-/**
- * Copy a rectangular region from one surface to another.
- * Surfaces must have same bpp.
- *
- * Assumes all values are within bounds -- no checking at this level -
- * do it higher up if required.
- */
-static void
-sp_surface_copy(struct pipe_context *pipe,
- boolean do_flip,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- struct pipe_surface *src,
- unsigned srcx, unsigned srcy, unsigned width, unsigned height)
-{
- void *dst_map = pipe->screen->surface_map( pipe->screen,
- dst,
- PIPE_BUFFER_USAGE_CPU_WRITE );
-
- const void *src_map = pipe->screen->surface_map( pipe->screen,
- src,
- PIPE_BUFFER_USAGE_CPU_READ );
-
- assert(dst->block.size == src->block.size);
- assert(dst->block.width == src->block.width);
- assert(dst->block.height == src->block.height);
- assert(src_map);
- assert(dst_map);
-
- /* If do_flip, invert src_y position and pass negative src stride */
- pipe_copy_rect(dst_map,
- &dst->block,
- dst->stride,
- dstx, dsty,
- width, height,
- src_map,
- do_flip ? -(int) src->stride : src->stride,
- srcx, do_flip ? src->height - 1 - srcy : srcy);
-
- pipe->screen->surface_unmap(pipe->screen, src);
- pipe->screen->surface_unmap(pipe->screen, dst);
-}
-
-
-static void *
-get_pointer(struct pipe_surface *dst, void *dst_map, unsigned x, unsigned y)
-{
- return (char *)dst_map + y / dst->block.height * dst->stride + x / dst->block.width * dst->block.size;
-}
-
-
-#define UBYTE_TO_USHORT(B) ((B) | ((B) << 8))
-
-
-/**
- * Fill a rectangular sub-region. Need better logic about when to
- * push buffers into AGP - will currently do so whenever possible.
- */
-static void
-sp_surface_fill(struct pipe_context *pipe,
- struct pipe_surface *dst,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height, unsigned value)
-{
- unsigned i, j;
- void *dst_map = pipe->screen->surface_map( pipe->screen,
- dst,
- PIPE_BUFFER_USAGE_CPU_WRITE );
-
- assert(dst->stride > 0);
-
-
- switch (dst->block.size) {
- case 1:
- case 2:
- case 4:
- pipe_fill_rect(dst_map, &dst->block, dst->stride, dstx, dsty, width, height, value);
- break;
- case 8:
- {
- /* expand the 4-byte clear value to an 8-byte value */
- ushort *row = (ushort *) get_pointer(dst, dst_map, dstx, dsty);
- ushort val0 = UBYTE_TO_USHORT((value >> 0) & 0xff);
- ushort val1 = UBYTE_TO_USHORT((value >> 8) & 0xff);
- ushort val2 = UBYTE_TO_USHORT((value >> 16) & 0xff);
- ushort val3 = UBYTE_TO_USHORT((value >> 24) & 0xff);
- val0 = (val0 << 8) | val0;
- val1 = (val1 << 8) | val1;
- val2 = (val2 << 8) | val2;
- val3 = (val3 << 8) | val3;
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++) {
- row[j*4+0] = val0;
- row[j*4+1] = val1;
- row[j*4+2] = val2;
- row[j*4+3] = val3;
- }
- row += dst->stride/2;
- }
- }
- break;
- default:
- assert(0);
- break;
- }
-
- pipe->screen->surface_unmap(pipe->screen, dst);
-}
-
-
void
sp_init_surface_functions(struct softpipe_context *sp)
{
- sp->pipe.surface_copy = sp_surface_copy;
- sp->pipe.surface_fill = sp_surface_fill;
+ sp->pipe.surface_copy = util_surface_copy;
+ sp->pipe.surface_fill = util_surface_fill;
}
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index 01f4d0ca81..49250ec084 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -39,8 +39,9 @@
#include "sp_tile_cache.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
-#include "pipe/p_util.h"
#include "tgsi/tgsi_exec.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
/*
@@ -50,7 +51,7 @@
* Also note, FRAC(x) doesn't truly return the fractional part of x for x < 0.
* Instead, if x < 0 then FRAC(x) = 1 - true_frac(x).
*/
-#define FRAC(f) ((f) - ifloor(f))
+#define FRAC(f) ((f) - util_ifloor(f))
/**
@@ -99,7 +100,7 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
case PIPE_TEX_WRAP_REPEAT:
/* s limited to [0,1) */
/* i limited to [0,size-1] */
- i = ifloor(s * size);
+ i = util_ifloor(s * size);
i = REMAINDER(i, size);
return i;
case PIPE_TEX_WRAP_CLAMP:
@@ -110,7 +111,7 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
else if (s >= 1.0F)
i = size - 1;
else
- i = ifloor(s * size);
+ i = util_ifloor(s * size);
return i;
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
{
@@ -123,7 +124,7 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
else if (s > max)
i = size - 1;
else
- i = ifloor(s * size);
+ i = util_ifloor(s * size);
}
return i;
case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
@@ -137,14 +138,14 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
else if (s >= max)
i = size;
else
- i = ifloor(s * size);
+ i = util_ifloor(s * size);
}
return i;
case PIPE_TEX_WRAP_MIRROR_REPEAT:
{
const float min = 1.0F / (2.0F * size);
const float max = 1.0F - min;
- const int flr = ifloor(s);
+ const int flr = util_ifloor(s);
float u;
if (flr & 1)
u = 1.0F - (s - (float) flr);
@@ -155,20 +156,20 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
else if (u > max)
i = size - 1;
else
- i = ifloor(u * size);
+ i = util_ifloor(u * size);
}
return i;
case PIPE_TEX_WRAP_MIRROR_CLAMP:
{
/* s limited to [0,1] */
/* i limited to [0,size-1] */
- const float u = FABSF(s);
+ const float u = fabsf(s);
if (u <= 0.0F)
i = 0;
else if (u >= 1.0F)
i = size - 1;
else
- i = ifloor(u * size);
+ i = util_ifloor(u * size);
}
return i;
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
@@ -177,13 +178,13 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
/* i limited to [0, size-1] */
const float min = 1.0F / (2.0F * size);
const float max = 1.0F - min;
- const float u = FABSF(s);
+ const float u = fabsf(s);
if (u < min)
i = 0;
else if (u > max)
i = size - 1;
else
- i = ifloor(u * size);
+ i = util_ifloor(u * size);
}
return i;
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER:
@@ -192,13 +193,13 @@ nearest_texcoord(unsigned wrapMode, float s, unsigned size)
/* i limited to [0, size-1] */
const float min = -1.0F / (2.0F * size);
const float max = 1.0F - min;
- const float u = FABSF(s);
+ const float u = fabsf(s);
if (u < min)
i = -1;
else if (u > max)
i = size;
else
- i = ifloor(u * size);
+ i = util_ifloor(u * size);
}
return i;
default:
@@ -225,7 +226,7 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
switch (wrapMode) {
case PIPE_TEX_WRAP_REPEAT:
u = s * size - 0.5F;
- *i0 = REMAINDER(ifloor(u), size);
+ *i0 = REMAINDER(util_ifloor(u), size);
*i1 = REMAINDER(*i0 + 1, size);
break;
case PIPE_TEX_WRAP_CLAMP:
@@ -236,7 +237,7 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
else
u = s * size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
break;
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
@@ -247,7 +248,7 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
else
u = s * size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
if (*i0 < 0)
*i0 = 0;
@@ -265,19 +266,19 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
else
u = s * size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
}
break;
case PIPE_TEX_WRAP_MIRROR_REPEAT:
{
- const int flr = ifloor(s);
+ const int flr = util_ifloor(s);
if (flr & 1)
u = 1.0F - (s - (float) flr);
else
u = s - (float) flr;
u = (u * size) - 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
if (*i0 < 0)
*i0 = 0;
@@ -286,23 +287,23 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
}
break;
case PIPE_TEX_WRAP_MIRROR_CLAMP:
- u = FABSF(s);
+ u = fabsf(s);
if (u >= 1.0F)
u = (float) size;
else
u *= size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
break;
case PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE:
- u = FABSF(s);
+ u = fabsf(s);
if (u >= 1.0F)
u = (float) size;
else
u *= size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
if (*i0 < 0)
*i0 = 0;
@@ -313,7 +314,7 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
{
const float min = -1.0F / (2.0F * size);
const float max = 1.0F - min;
- u = FABSF(s);
+ u = fabsf(s);
if (u <= min)
u = min * size;
else if (u >= max)
@@ -321,7 +322,7 @@ linear_texcoord(unsigned wrapMode, float s, unsigned size,
else
u *= size;
u -= 0.5F;
- *i0 = ifloor(u);
+ *i0 = util_ifloor(u);
*i1 = *i0 + 1;
}
break;
@@ -342,12 +343,12 @@ nearest_texcoord_unnorm(unsigned wrapMode, float s, unsigned size)
int i;
switch (wrapMode) {
case PIPE_TEX_WRAP_CLAMP:
- i = ifloor(s);
+ i = util_ifloor(s);
return CLAMP(i, 0, (int) 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) );
+ return util_ifloor( CLAMP(s, 0.5F, (float) size - 0.5F) );
default:
assert(0);
return 0;
@@ -367,7 +368,7 @@ linear_texcoord_unnorm(unsigned wrapMode, float s, unsigned size,
case PIPE_TEX_WRAP_CLAMP:
/* Not exactly what the spec says, but it matches NVIDIA output */
s = CLAMP(s - 0.5F, 0.0f, (float) size - 1.0f);
- *i0 = ifloor(s);
+ *i0 = util_ifloor(s);
*i1 = *i0 + 1;
break;
case PIPE_TEX_WRAP_CLAMP_TO_EDGE:
@@ -375,7 +376,7 @@ linear_texcoord_unnorm(unsigned wrapMode, float s, unsigned size,
case PIPE_TEX_WRAP_CLAMP_TO_BORDER:
s = CLAMP(s, 0.5F, (float) size - 0.5F);
s -= 0.5F;
- *i0 = ifloor(s);
+ *i0 = util_ifloor(s);
*i1 = *i0 + 1;
if (*i1 > (int) size - 1)
*i1 = size - 1;
@@ -401,7 +402,7 @@ choose_cube_face(float rx, float ry, float rz, float *newS, float *newT)
+rz TEXTURE_CUBE_MAP_POSITIVE_Z_EXT +rx -ry rz
-rz TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT -rx -ry rz
*/
- const float arx = FABSF(rx), ary = FABSF(ry), arz = FABSF(rz);
+ const float arx = fabsf(rx), ary = fabsf(ry), arz = fabsf(rz);
unsigned face;
float sc, tc, ma;
@@ -476,16 +477,16 @@ compute_lambda(struct tgsi_sampler *sampler,
{
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);
+ dsdx = fabsf(dsdx);
+ dsdy = fabsf(dsdy);
rho = MAX2(dsdx, dsdy) * sampler->texture->width[0];
}
if (t) {
float dtdx = t[QUAD_BOTTOM_RIGHT] - t[QUAD_BOTTOM_LEFT];
float dtdy = t[QUAD_TOP_LEFT] - t[QUAD_BOTTOM_LEFT];
float max;
- dtdx = FABSF(dtdx);
- dtdy = FABSF(dtdy);
+ dtdx = fabsf(dtdx);
+ dtdy = fabsf(dtdy);
max = MAX2(dtdx, dtdy) * sampler->texture->height[0];
rho = MAX2(rho, max);
}
@@ -493,13 +494,13 @@ compute_lambda(struct tgsi_sampler *sampler,
float dpdx = p[QUAD_BOTTOM_RIGHT] - p[QUAD_BOTTOM_LEFT];
float dpdy = p[QUAD_TOP_LEFT] - p[QUAD_BOTTOM_LEFT];
float max;
- dpdx = FABSF(dpdx);
- dpdy = FABSF(dpdy);
+ dpdx = fabsf(dpdx);
+ dpdy = fabsf(dpdy);
max = MAX2(dpdx, dpdy) * sampler->texture->depth[0];
rho = MAX2(rho, max);
}
- lambda = LOG2(rho);
+ lambda = util_fast_log2(rho);
lambda += lodbias + sampler->state->lod_bias;
lambda = CLAMP(lambda, sampler->state->min_lod, sampler->state->max_lod);
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index f775591352..cb48035771 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -33,8 +33,9 @@
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
#include "pipe/p_inlines.h"
-#include "pipe/p_util.h"
#include "pipe/p_winsys.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
#include "sp_context.h"
#include "sp_state.h"
@@ -191,7 +192,7 @@ softpipe_texture_blanket(struct pipe_screen * screen,
spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height[0]);
spt->stride[0] = stride[0];
- pipe_buffer_reference(screen->winsys, &spt->buffer, buffer);
+ pipe_buffer_reference(screen, &spt->buffer, buffer);
return &spt->base;
}
@@ -207,7 +208,7 @@ softpipe_texture_release(struct pipe_screen *screen,
if (--(*pt)->refcount <= 0) {
struct softpipe_texture *spt = softpipe_texture(*pt);
- pipe_buffer_reference(screen->winsys, &spt->buffer, NULL);
+ pipe_buffer_reference(screen, &spt->buffer, NULL);
FREE(spt);
}
*pt = NULL;
@@ -230,7 +231,7 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
if (ps) {
assert(ps->refcount);
assert(ps->winsys);
- pipe_buffer_reference(ws, &ps->buffer, spt->buffer);
+ pipe_buffer_reference(screen, &ps->buffer, spt->buffer);
ps->format = pt->format;
ps->block = pt->block;
ps->width = pt->width[level];
@@ -306,7 +307,7 @@ softpipe_surface_map( struct pipe_screen *screen,
return NULL;
}
- map = screen->winsys->buffer_map( screen->winsys, surface->buffer, flags );
+ map = pipe_buffer_map( screen, surface->buffer, flags );
if (map == NULL)
return NULL;
@@ -330,7 +331,7 @@ static void
softpipe_surface_unmap(struct pipe_screen *screen,
struct pipe_surface *surface)
{
- screen->winsys->buffer_unmap( screen->winsys, surface->buffer );
+ pipe_buffer_unmap( screen, surface->buffer );
}
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c
index 57c12ffe33..b50c984513 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
@@ -32,9 +32,9 @@
* Brian Paul
*/
-#include "pipe/p_util.h"
#include "pipe/p_inlines.h"
-#include "util/p_tile.h"
+#include "util/u_memory.h"
+#include "util/u_tile.h"
#include "sp_context.h"
#include "sp_surface.h"
#include "sp_texture.h"
diff --git a/src/gallium/drivers/trace/README b/src/gallium/drivers/trace/README
index 81da610bd5..e7a2f12b02 100644
--- a/src/gallium/drivers/trace/README
+++ b/src/gallium/drivers/trace/README
@@ -1,37 +1,64 @@
+ TRACE PIPE DRIVER
+
+
+= About =
+
This directory contains a Gallium3D pipe driver which traces all incoming calls.
+
+= Build Instructions =
+
To build, invoke scons on the top dir as
scons statetrackers=mesa drivers=softpipe,i915simple,trace winsys=xlib
+
+= Usage =
+
To use do
ln -s libGL.so build/linux-x86-debug/gallium/winsys/xlib/libGL.so.1
export LD_LIBRARY_PATH=$PWD/build/linux-x86-debug/gallium/winsys/xlib
- export GALLIUM_TRACE=y
ensure the right libGL.so is being picked by doing
- ldd `which glxingo`
+ ldd progs/trivial/tri
and then try running
- glxinfo
+ GALLIUM_TRACE=tri.trace progs/trivial/tri
-which should create a gallium.*.trace file, which is an XML file. You can view
-copying trace.xsl and trace.css to the same directory, and opening with a
-XSLT capable browser like Firefox or Internet Explorer. It often happens that
-the trace file was not properly terminated, and a
+which should create a tri.trace file, which is an XML file. You can view copying
+trace.xsl to the same directory, and opening with a XSLT capable browser such as
+Firefox or Internet Explorer.
- </trace>
-
-closing tag is missing from the file end. Add it before try to open or
-further transform it by doing
- echo '</trace>' >> gallium.??.trace
+= Integrating =
+
+You can integrate the trace pipe driver either inside the state tracker or the
+winsys. The procedure on both cases is the same. Let's assume you have a
+pipe_screen and a pipe_context pair obtained by the usual means (variable and
+function names are just for illustration purposes):
+
+ real_screen = real_screen_create(...);
+
+ real_context = real_context_create(...);
+
+The trace screen and pipe_context is then created by doing
+
+ trace_screen = trace_screen_create(real_screen);
+
+ trace_context = trace_context_create(trace_screen, real_context);
+
+You can then simply use trace_screen and trace_context instead of real_screen
+and real_context.
+
+Do not call trace_winsys_create. Simply pass trace_screen->winsys or
+trace_context->winsys in places you would pass winsys.
+You can create as many contexts you wish. Just ensure that you don't mistake
+trace_screen with real_screen when creating them.
-This is still work in progress.
--
Jose Fonseca <jrfonseca@tungstengraphics.com>
diff --git a/src/gallium/drivers/trace/SConscript b/src/gallium/drivers/trace/SConscript
index 35507e21e4..0a6bfb8f4c 100644
--- a/src/gallium/drivers/trace/SConscript
+++ b/src/gallium/drivers/trace/SConscript
@@ -3,14 +3,14 @@ Import('*')
env = env.Clone()
trace = env.ConvenienceLibrary(
- target = 'trace',
- source = [
+ target = 'trace',
+ source = [
'tr_context.c',
'tr_dump.c',
- 'tr_screen.c',
+ 'tr_screen.c',
'tr_state.c',
- 'tr_stream.c',
+ 'tr_texture.c',
'tr_winsys.c',
- ])
+ ])
Export('trace') \ No newline at end of file
diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c
index f82126370c..1dd7719379 100644
--- a/src/gallium/drivers/trace/tr_context.c
+++ b/src/gallium/drivers/trace/tr_context.c
@@ -25,33 +25,75 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
+#include "pipe/p_screen.h"
-#include "tr_stream.h"
#include "tr_dump.h"
#include "tr_state.h"
-#include "tr_winsys.h"
#include "tr_screen.h"
+#include "tr_texture.h"
+#include "tr_winsys.h"
#include "tr_context.h"
+static INLINE struct pipe_texture *
+trace_texture_unwrap(struct trace_context *tr_ctx,
+ struct pipe_texture *texture)
+{
+ struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
+ struct trace_texture *tr_tex;
+
+ if(!texture)
+ return NULL;
+
+ tr_tex = trace_texture(tr_scr, texture);
+
+ assert(tr_tex->texture);
+ assert(tr_tex->texture->screen == tr_scr->screen);
+ return tr_tex->texture;
+}
+
+
+static INLINE struct pipe_surface *
+trace_surface_unwrap(struct trace_context *tr_ctx,
+ struct pipe_surface *surface)
+{
+ struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
+ struct trace_texture *tr_tex;
+ struct trace_surface *tr_surf;
+
+ if(!surface)
+ return NULL;
+
+ assert(surface->texture);
+ if(!surface->texture)
+ return surface;
+
+ tr_tex = trace_texture(tr_scr, surface->texture);
+ tr_surf = trace_surface(tr_tex, surface);
+
+ assert(tr_surf->surface);
+ assert(tr_surf->surface->texture->screen == tr_scr->screen);
+ return tr_surf->surface;
+}
+
+
static INLINE void
trace_context_set_edgeflags(struct pipe_context *_pipe,
const unsigned *bitfield)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "set_edgeflags");
+ trace_dump_call_begin("pipe_context", "set_edgeflags");
- trace_dump_arg(stream, ptr, pipe);
+ trace_dump_arg(ptr, pipe);
/* FIXME: we don't know how big this array is */
- trace_dump_arg(stream, ptr, bitfield);
+ trace_dump_arg(ptr, bitfield);
pipe->set_edgeflags(pipe, bitfield);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -60,22 +102,21 @@ trace_context_draw_arrays(struct pipe_context *_pipe,
unsigned mode, unsigned start, unsigned count)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
boolean result;
- trace_dump_call_begin(stream, "pipe_context", "draw_arrays");
+ trace_dump_call_begin("pipe_context", "draw_arrays");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, uint, mode);
- trace_dump_arg(stream, uint, start);
- trace_dump_arg(stream, uint, count);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, mode);
+ trace_dump_arg(uint, start);
+ trace_dump_arg(uint, count);
result = pipe->draw_arrays(pipe, mode, start, count);;
- trace_dump_ret(stream, bool, result);
+ trace_dump_ret(bool, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -88,24 +129,25 @@ trace_context_draw_elements(struct pipe_context *_pipe,
unsigned mode, unsigned start, unsigned count)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
boolean result;
- trace_dump_call_begin(stream, "pipe_context", "draw_elements");
+ trace_winsys_user_buffer_update(_pipe->winsys, indexBuffer);
+
+ trace_dump_call_begin("pipe_context", "draw_elements");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, indexBuffer);
- trace_dump_arg(stream, uint, indexSize);
- trace_dump_arg(stream, uint, mode);
- trace_dump_arg(stream, uint, start);
- trace_dump_arg(stream, uint, count);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, indexBuffer);
+ trace_dump_arg(uint, indexSize);
+ trace_dump_arg(uint, mode);
+ trace_dump_arg(uint, start);
+ trace_dump_arg(uint, count);
result = pipe->draw_elements(pipe, indexBuffer, indexSize, mode, start, count);;
- trace_dump_ret(stream, bool, result);
+ trace_dump_ret(bool, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -122,29 +164,30 @@ trace_context_draw_range_elements(struct pipe_context *_pipe,
unsigned count)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
boolean result;
- trace_dump_call_begin(stream, "pipe_context", "draw_range_elements");
+ trace_winsys_user_buffer_update(_pipe->winsys, indexBuffer);
+
+ trace_dump_call_begin("pipe_context", "draw_range_elements");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, indexBuffer);
- trace_dump_arg(stream, uint, indexSize);
- trace_dump_arg(stream, uint, minIndex);
- trace_dump_arg(stream, uint, maxIndex);
- trace_dump_arg(stream, uint, mode);
- trace_dump_arg(stream, uint, start);
- trace_dump_arg(stream, uint, count);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, indexBuffer);
+ trace_dump_arg(uint, indexSize);
+ trace_dump_arg(uint, minIndex);
+ trace_dump_arg(uint, maxIndex);
+ trace_dump_arg(uint, mode);
+ trace_dump_arg(uint, start);
+ trace_dump_arg(uint, count);
result = pipe->draw_range_elements(pipe,
indexBuffer,
indexSize, minIndex, maxIndex,
mode, start, count);
- trace_dump_ret(stream, bool, result);
+ trace_dump_ret(bool, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -155,20 +198,19 @@ trace_context_create_query(struct pipe_context *_pipe,
unsigned query_type)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
struct pipe_query *result;
- trace_dump_call_begin(stream, "pipe_context", "create_query");
+ trace_dump_call_begin("pipe_context", "create_query");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, uint, query_type);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, query_type);
result = pipe->create_query(pipe, query_type);;
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -179,17 +221,16 @@ trace_context_destroy_query(struct pipe_context *_pipe,
struct pipe_query *query)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "destroy_query");
+ trace_dump_call_begin("pipe_context", "destroy_query");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, query);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, query);
pipe->destroy_query(pipe, query);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -198,17 +239,16 @@ trace_context_begin_query(struct pipe_context *_pipe,
struct pipe_query *query)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "begin_query");
+ trace_dump_call_begin("pipe_context", "begin_query");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, query);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, query);
pipe->begin_query(pipe, query);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -217,17 +257,16 @@ trace_context_end_query(struct pipe_context *_pipe,
struct pipe_query *query)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "end_query");
+ trace_dump_call_begin("pipe_context", "end_query");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, query);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, query);
pipe->end_query(pipe, query);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -238,22 +277,21 @@ trace_context_get_query_result(struct pipe_context *_pipe,
uint64 *presult)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
uint64 result;
boolean _result;
- trace_dump_call_begin(stream, "pipe_context", "get_query_result");
+ trace_dump_call_begin("pipe_context", "get_query_result");
- trace_dump_arg(stream, ptr, pipe);
+ trace_dump_arg(ptr, pipe);
_result = pipe->get_query_result(pipe, query, wait, presult);;
result = *presult;
- trace_dump_arg(stream, uint, result);
- trace_dump_ret(stream, bool, _result);
+ trace_dump_arg(uint, result);
+ trace_dump_ret(bool, _result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return _result;
}
@@ -264,20 +302,19 @@ trace_context_create_blend_state(struct pipe_context *_pipe,
const struct pipe_blend_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
void * result;
- trace_dump_call_begin(stream, "pipe_context", "create_blend_state");
+ trace_dump_call_begin("pipe_context", "create_blend_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, blend_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(blend_state, state);
result = pipe->create_blend_state(pipe, state);;
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -288,17 +325,16 @@ trace_context_bind_blend_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "bind_blend_state");
+ trace_dump_call_begin("pipe_context", "bind_blend_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->bind_blend_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -307,17 +343,16 @@ trace_context_delete_blend_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "delete_blend_state");
+ trace_dump_call_begin("pipe_context", "delete_blend_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->delete_blend_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -326,20 +361,19 @@ trace_context_create_sampler_state(struct pipe_context *_pipe,
const struct pipe_sampler_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
void * result;
- trace_dump_call_begin(stream, "pipe_context", "create_sampler_state");
+ trace_dump_call_begin("pipe_context", "create_sampler_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(sampler_state, state);
result = pipe->create_sampler_state(pipe, state);;
- trace_dump_ret(stream, sampler_state, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -350,18 +384,17 @@ trace_context_bind_sampler_states(struct pipe_context *_pipe,
unsigned num_states, void **states)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "bind_sampler_states");
+ trace_dump_call_begin("pipe_context", "bind_sampler_states");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, uint, num_states);
- trace_dump_arg_array(stream, ptr, states, num_states);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, num_states);
+ trace_dump_arg_array(ptr, states, num_states);
pipe->bind_sampler_states(pipe, num_states, states);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -370,17 +403,16 @@ trace_context_delete_sampler_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "delete_sampler_state");
+ trace_dump_call_begin("pipe_context", "delete_sampler_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->delete_sampler_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -389,20 +421,19 @@ trace_context_create_rasterizer_state(struct pipe_context *_pipe,
const struct pipe_rasterizer_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
void * result;
- trace_dump_call_begin(stream, "pipe_context", "create_rasterizer_state");
+ trace_dump_call_begin("pipe_context", "create_rasterizer_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, rasterizer_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(rasterizer_state, state);
result = pipe->create_rasterizer_state(pipe, state);;
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -413,17 +444,16 @@ trace_context_bind_rasterizer_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "bind_rasterizer_state");
+ trace_dump_call_begin("pipe_context", "bind_rasterizer_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->bind_rasterizer_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -432,17 +462,16 @@ trace_context_delete_rasterizer_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "delete_rasterizer_state");
+ trace_dump_call_begin("pipe_context", "delete_rasterizer_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->delete_rasterizer_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -451,20 +480,19 @@ trace_context_create_depth_stencil_alpha_state(struct pipe_context *_pipe,
const struct pipe_depth_stencil_alpha_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
void * result;
- trace_dump_call_begin(stream, "pipe_context", "create_depth_stencil_alpha_state");
+ trace_dump_call_begin("pipe_context", "create_depth_stencil_alpha_state");
result = pipe->create_depth_stencil_alpha_state(pipe, state);;
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, depth_stencil_alpha_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(depth_stencil_alpha_state, state);
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -475,17 +503,16 @@ trace_context_bind_depth_stencil_alpha_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "bind_depth_stencil_alpha_state");
+ trace_dump_call_begin("pipe_context", "bind_depth_stencil_alpha_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->bind_depth_stencil_alpha_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -494,17 +521,16 @@ trace_context_delete_depth_stencil_alpha_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "delete_depth_stencil_alpha_state");
+ trace_dump_call_begin("pipe_context", "delete_depth_stencil_alpha_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->delete_depth_stencil_alpha_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -513,20 +539,19 @@ trace_context_create_fs_state(struct pipe_context *_pipe,
const struct pipe_shader_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
void * result;
- trace_dump_call_begin(stream, "pipe_context", "create_fs_state");
+ trace_dump_call_begin("pipe_context", "create_fs_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, shader_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(shader_state, state);
result = pipe->create_fs_state(pipe, state);;
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -537,17 +562,16 @@ trace_context_bind_fs_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "bind_fs_state");
+ trace_dump_call_begin("pipe_context", "bind_fs_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->bind_fs_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -556,17 +580,16 @@ trace_context_delete_fs_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "delete_fs_state");
+ trace_dump_call_begin("pipe_context", "delete_fs_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->delete_fs_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -575,20 +598,19 @@ trace_context_create_vs_state(struct pipe_context *_pipe,
const struct pipe_shader_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
void * result;
- trace_dump_call_begin(stream, "pipe_context", "create_vs_state");
+ trace_dump_call_begin("pipe_context", "create_vs_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, shader_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(shader_state, state);
result = pipe->create_vs_state(pipe, state);;
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -599,17 +621,16 @@ trace_context_bind_vs_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "bind_vs_state");
+ trace_dump_call_begin("pipe_context", "bind_vs_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->bind_vs_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -618,17 +639,16 @@ trace_context_delete_vs_state(struct pipe_context *_pipe,
void *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "delete_vs_state");
+ trace_dump_call_begin("pipe_context", "delete_vs_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, state);
pipe->delete_vs_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -637,17 +657,16 @@ trace_context_set_blend_color(struct pipe_context *_pipe,
const struct pipe_blend_color *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "set_blend_color");
+ trace_dump_call_begin("pipe_context", "set_blend_color");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, blend_color, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(blend_color, state);
pipe->set_blend_color(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -656,17 +675,16 @@ trace_context_set_clip_state(struct pipe_context *_pipe,
const struct pipe_clip_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "set_clip_state");
+ trace_dump_call_begin("pipe_context", "set_clip_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, clip_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(clip_state, state);
pipe->set_clip_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -676,19 +694,20 @@ trace_context_set_constant_buffer(struct pipe_context *_pipe,
const struct pipe_constant_buffer *buffer)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "set_constant_buffer");
+ trace_winsys_user_buffer_update(_pipe->winsys, (struct pipe_buffer *)buffer);
+
+ trace_dump_call_begin("pipe_context", "set_constant_buffer");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, uint, shader);
- trace_dump_arg(stream, uint, index);
- trace_dump_arg(stream, constant_buffer, buffer);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, shader);
+ trace_dump_arg(uint, index);
+ trace_dump_arg(constant_buffer, buffer);
pipe->set_constant_buffer(pipe, shader, index, buffer);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -697,17 +716,27 @@ trace_context_set_framebuffer_state(struct pipe_context *_pipe,
const struct pipe_framebuffer_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
+ struct pipe_framebuffer_state unwrapped_state;
+ unsigned i;
+
+ /* Unwrap the input state */
+ memcpy(&unwrapped_state, state, sizeof(unwrapped_state));
+ for(i = 0; i < state->num_cbufs; ++i)
+ unwrapped_state.cbufs[i] = trace_surface_unwrap(tr_ctx, state->cbufs[i]);
+ for(i = state->num_cbufs; i < PIPE_MAX_COLOR_BUFS; ++i)
+ unwrapped_state.cbufs[i] = NULL;
+ unwrapped_state.zsbuf = trace_surface_unwrap(tr_ctx, state->zsbuf);
+ state = &unwrapped_state;
+
+ trace_dump_call_begin("pipe_context", "set_framebuffer_state");
- trace_dump_call_begin(stream, "pipe_context", "set_framebuffer_state");
-
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, framebuffer_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(framebuffer_state, state);
pipe->set_framebuffer_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -716,17 +745,16 @@ trace_context_set_polygon_stipple(struct pipe_context *_pipe,
const struct pipe_poly_stipple *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "set_polygon_stipple");
+ trace_dump_call_begin("pipe_context", "set_polygon_stipple");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, poly_stipple, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(poly_stipple, state);
pipe->set_polygon_stipple(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -735,17 +763,16 @@ trace_context_set_scissor_state(struct pipe_context *_pipe,
const struct pipe_scissor_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "set_scissor_state");
+ trace_dump_call_begin("pipe_context", "set_scissor_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, scissor_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(scissor_state, state);
pipe->set_scissor_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -754,17 +781,16 @@ trace_context_set_viewport_state(struct pipe_context *_pipe,
const struct pipe_viewport_state *state)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "set_viewport_state");
+ trace_dump_call_begin("pipe_context", "set_viewport_state");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, viewport_state, state);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(viewport_state, state);
pipe->set_viewport_state(pipe, state);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -774,18 +800,23 @@ trace_context_set_sampler_textures(struct pipe_context *_pipe,
struct pipe_texture **textures)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
+ struct pipe_texture *unwrapped_textures[PIPE_MAX_SAMPLERS];
+ unsigned i;
+
+ for(i = 0; i < num_textures; ++i)
+ unwrapped_textures[i] = trace_texture_unwrap(tr_ctx, textures[i]);
+ textures = unwrapped_textures;
- trace_dump_call_begin(stream, "pipe_context", "set_sampler_textures");
+ trace_dump_call_begin("pipe_context", "set_sampler_textures");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, uint, num_textures);
- trace_dump_arg_array(stream, ptr, textures, num_textures);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, num_textures);
+ trace_dump_arg_array(ptr, textures, num_textures);
pipe->set_sampler_textures(pipe, num_textures, textures);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -795,21 +826,24 @@ trace_context_set_vertex_buffers(struct pipe_context *_pipe,
const struct pipe_vertex_buffer *buffers)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
+ unsigned i;
+
+ for(i = 0; i < num_buffers; ++i)
+ trace_winsys_user_buffer_update(_pipe->winsys, buffers[i].buffer);
- trace_dump_call_begin(stream, "pipe_context", "set_vertex_buffers");
+ trace_dump_call_begin("pipe_context", "set_vertex_buffers");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, uint, num_buffers);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, num_buffers);
- trace_dump_arg_begin(stream, "buffers");
- trace_dump_struct_array(stream, vertex_buffer, buffers, num_buffers);
- trace_dump_arg_end(stream);
+ trace_dump_arg_begin("buffers");
+ trace_dump_struct_array(vertex_buffer, buffers, num_buffers);
+ trace_dump_arg_end();
pipe->set_vertex_buffers(pipe, num_buffers, buffers);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -819,21 +853,20 @@ trace_context_set_vertex_elements(struct pipe_context *_pipe,
const struct pipe_vertex_element *elements)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "set_vertex_elements");
+ trace_dump_call_begin("pipe_context", "set_vertex_elements");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, uint, num_elements);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, num_elements);
- trace_dump_arg_begin(stream, "elements");
- trace_dump_struct_array(stream, vertex_element, elements, num_elements);
- trace_dump_arg_end(stream);
+ trace_dump_arg_begin("elements");
+ trace_dump_struct_array(vertex_element, elements, num_elements);
+ trace_dump_arg_end();
pipe->set_vertex_elements(pipe, num_elements, elements);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -847,27 +880,29 @@ trace_context_surface_copy(struct pipe_context *_pipe,
unsigned width, unsigned height)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "surface_copy");
-
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, bool, do_flip);
- trace_dump_arg(stream, ptr, dest);
- trace_dump_arg(stream, uint, destx);
- trace_dump_arg(stream, uint, desty);
- trace_dump_arg(stream, ptr, src);
- trace_dump_arg(stream, uint, srcx);
- trace_dump_arg(stream, uint, srcy);
- trace_dump_arg(stream, uint, width);
- trace_dump_arg(stream, uint, height);
+ dest = trace_surface_unwrap(tr_ctx, dest);
+ src = trace_surface_unwrap(tr_ctx, src);
+
+ trace_dump_call_begin("pipe_context", "surface_copy");
+
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(bool, do_flip);
+ trace_dump_arg(ptr, dest);
+ trace_dump_arg(uint, destx);
+ trace_dump_arg(uint, desty);
+ trace_dump_arg(ptr, src);
+ trace_dump_arg(uint, srcx);
+ trace_dump_arg(uint, srcy);
+ trace_dump_arg(uint, width);
+ trace_dump_arg(uint, height);
pipe->surface_copy(pipe, do_flip,
dest, destx, desty,
src, srcx, srcy, width, height);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -879,21 +914,22 @@ trace_context_surface_fill(struct pipe_context *_pipe,
unsigned value)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "surface_fill");
+ dst = trace_surface_unwrap(tr_ctx, dst);
+
+ trace_dump_call_begin("pipe_context", "surface_fill");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, dst);
- trace_dump_arg(stream, uint, dstx);
- trace_dump_arg(stream, uint, dsty);
- trace_dump_arg(stream, uint, width);
- trace_dump_arg(stream, uint, height);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, dst);
+ trace_dump_arg(uint, dstx);
+ trace_dump_arg(uint, dsty);
+ trace_dump_arg(uint, width);
+ trace_dump_arg(uint, height);
pipe->surface_fill(pipe, dst, dstx, dsty, width, height, value);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -903,18 +939,19 @@ trace_context_clear(struct pipe_context *_pipe,
unsigned clearValue)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "clear");
+ surface = trace_surface_unwrap(tr_ctx, surface);
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, ptr, surface);
- trace_dump_arg(stream, uint, clearValue);
+ trace_dump_call_begin("pipe_context", "clear");
+
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(ptr, surface);
+ trace_dump_arg(uint, clearValue);
pipe->clear(pipe, surface, clearValue);;
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -924,18 +961,19 @@ trace_context_flush(struct pipe_context *_pipe,
struct pipe_fence_handle **fence)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "flush");
+ trace_dump_call_begin("pipe_context", "flush");
- trace_dump_arg(stream, ptr, pipe);
- trace_dump_arg(stream, uint, flags);
- trace_dump_arg(stream, ptr, fence);
+ trace_dump_arg(ptr, pipe);
+ trace_dump_arg(uint, flags);
pipe->flush(pipe, flags, fence);;
- trace_dump_call_end(stream);
+ if(fence)
+ trace_dump_ret(ptr, *fence);
+
+ trace_dump_call_end();
}
@@ -943,36 +981,38 @@ static INLINE void
trace_context_destroy(struct pipe_context *_pipe)
{
struct trace_context *tr_ctx = trace_context(_pipe);
- struct trace_stream *stream = tr_ctx->stream;
struct pipe_context *pipe = tr_ctx->pipe;
- trace_dump_call_begin(stream, "pipe_context", "destroy");
+ trace_dump_call_begin("pipe_context", "destroy");
- trace_dump_arg(stream, ptr, pipe);
+ trace_dump_arg(ptr, pipe);
pipe->destroy(pipe);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
FREE(tr_ctx);
}
struct pipe_context *
-trace_context_create(struct pipe_context *pipe)
+trace_context_create(struct pipe_screen *screen,
+ struct pipe_context *pipe)
{
- struct trace_stream *stream;
struct trace_context *tr_ctx;
- if(!debug_get_bool_option("GALLIUM_TRACE", FALSE))
- return pipe;
+ if(!pipe)
+ goto error1;
+
+ if(!trace_dump_enabled())
+ goto error1;
tr_ctx = CALLOC_STRUCT(trace_context);
if(!tr_ctx)
- return NULL;
+ goto error1;
- tr_ctx->base.winsys = pipe->winsys;
- tr_ctx->base.screen = pipe->screen;
+ tr_ctx->base.winsys = screen->winsys;
+ tr_ctx->base.screen = screen;
tr_ctx->base.destroy = trace_context_destroy;
tr_ctx->base.set_edgeflags = trace_context_set_edgeflags;
tr_ctx->base.draw_arrays = trace_context_draw_arrays;
@@ -1017,18 +1057,16 @@ trace_context_create(struct pipe_context *pipe)
tr_ctx->base.flush = trace_context_flush;
tr_ctx->pipe = pipe;
- tr_ctx->stream = stream = trace_winsys(pipe->winsys)->stream;
- /* We don't want to trace the internal pipe calls */
- pipe->winsys = trace_winsys(pipe->winsys)->winsys;
- pipe->screen = trace_screen(pipe->screen)->screen;
-
- trace_dump_call_begin(stream, "", "pipe_context_create");
- trace_dump_arg_begin(stream, "screen");
- trace_dump_ptr(stream, pipe->screen);
- trace_dump_arg_end(stream);
- trace_dump_ret(stream, ptr, pipe);
- trace_dump_call_end(stream);
+ trace_dump_call_begin("", "pipe_context_create");
+ trace_dump_arg_begin("screen");
+ trace_dump_ptr(pipe->screen);
+ trace_dump_arg_end();
+ trace_dump_ret(ptr, pipe);
+ trace_dump_call_end();
return &tr_ctx->base;
+
+error1:
+ return pipe;
}
diff --git a/src/gallium/drivers/trace/tr_context.h b/src/gallium/drivers/trace/tr_context.h
index 2c0b0c72e4..7831900ec2 100644
--- a/src/gallium/drivers/trace/tr_context.h
+++ b/src/gallium/drivers/trace/tr_context.h
@@ -34,7 +34,9 @@
#include "pipe/p_context.h"
-struct trace_stream;
+#ifdef __cplusplus
+extern "C" {
+#endif
struct trace_context
@@ -42,8 +44,6 @@ struct trace_context
struct pipe_context base;
struct pipe_context *pipe;
-
- struct trace_stream *stream;
};
@@ -57,7 +57,12 @@ trace_context(struct pipe_context *pipe)
struct pipe_context *
-trace_context_create(struct pipe_context *pipe);
+trace_context_create(struct pipe_screen *screen,
+ struct pipe_context *pipe);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* TR_CONTEXT_H_ */
diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c
index 5269c4ddc8..a0ead0ded3 100644
--- a/src/gallium/drivers/trace/tr_dump.c
+++ b/src/gallium/drivers/trace/tr_dump.c
@@ -38,326 +38,367 @@
* @author Jose Fonseca <jrfonseca@tungstengraphics.com>
*/
+#include "pipe/p_config.h"
+
+#if defined(PIPE_OS_LINUX)
+#include <stdlib.h>
+#endif
#include "pipe/p_compiler.h"
+#include "pipe/p_debug.h"
+#include "util/u_memory.h"
#include "util/u_string.h"
+#include "util/u_stream.h"
-#include "tr_stream.h"
#include "tr_dump.h"
+static struct util_stream *stream = NULL;
+static unsigned refcount = 0;
+
+
+static INLINE void
+trace_dump_write(const char *buf, size_t size)
+{
+ if(stream)
+ util_stream_write(stream, buf, size);
+}
+
+
static INLINE void
-trace_dump_write(struct trace_stream *stream, const char *s)
+trace_dump_writes(const char *s)
{
- trace_stream_write(stream, s, strlen(s));
+ trace_dump_write(s, strlen(s));
}
static INLINE void
-trace_dump_writef(struct trace_stream *stream, const char *format, ...)
+trace_dump_writef(const char *format, ...)
{
- char buf[1024];
+ static char buf[1024];
+ unsigned len;
va_list ap;
va_start(ap, format);
- util_vsnprintf(buf, sizeof(buf), format, ap);
+ len = util_vsnprintf(buf, sizeof(buf), format, ap);
va_end(ap);
- trace_dump_write(stream, buf);
+ trace_dump_write(buf, len);
}
static INLINE void
-trace_dump_escape(struct trace_stream *stream, const char *str)
+trace_dump_escape(const char *str)
{
const unsigned char *p = (const unsigned char *)str;
unsigned char c;
while((c = *p++) != 0) {
if(c == '<')
- trace_dump_write(stream, "&lt;");
+ trace_dump_writes("&lt;");
else if(c == '>')
- trace_dump_write(stream, "&gt;");
+ trace_dump_writes("&gt;");
else if(c == '&')
- trace_dump_write(stream, "&amp;");
+ trace_dump_writes("&amp;");
else if(c == '\'')
- trace_dump_write(stream, "&apos;");
+ trace_dump_writes("&apos;");
else if(c == '\"')
- trace_dump_write(stream, "&quot;");
+ trace_dump_writes("&quot;");
else if(c >= 0x20 && c <= 0x7e)
- trace_dump_writef(stream, "%c", c);
+ trace_dump_writef("%c", c);
else
- trace_dump_writef(stream, "&#%u;", c);
+ trace_dump_writef("&#%u;", c);
}
}
static INLINE void
-trace_dump_indent(struct trace_stream *stream, unsigned level)
+trace_dump_indent(unsigned level)
{
unsigned i;
for(i = 0; i < level; ++i)
- trace_dump_write(stream, "\t");
+ trace_dump_writes("\t");
}
static INLINE void
-trace_dump_newline(struct trace_stream *stream)
+trace_dump_newline(void)
{
- trace_dump_write(stream, "\n");
+ trace_dump_writes("\n");
}
static INLINE void
-trace_dump_tag(struct trace_stream *stream,
- const char *name)
+trace_dump_tag(const char *name)
{
- trace_dump_write(stream, "<");
- trace_dump_write(stream, name);
- trace_dump_write(stream, "/>");
+ trace_dump_writes("<");
+ trace_dump_writes(name);
+ trace_dump_writes("/>");
}
static INLINE void
-trace_dump_tag_begin(struct trace_stream *stream,
- const char *name)
+trace_dump_tag_begin(const char *name)
{
- trace_dump_write(stream, "<");
- trace_dump_write(stream, name);
- trace_dump_write(stream, ">");
+ trace_dump_writes("<");
+ trace_dump_writes(name);
+ trace_dump_writes(">");
}
static INLINE void
-trace_dump_tag_begin1(struct trace_stream *stream,
- const char *name,
+trace_dump_tag_begin1(const char *name,
const char *attr1, const char *value1)
{
- trace_dump_write(stream, "<");
- trace_dump_write(stream, name);
- trace_dump_write(stream, " ");
- trace_dump_write(stream, attr1);
- trace_dump_write(stream, "='");
- trace_dump_escape(stream, value1);
- trace_dump_write(stream, "'>");
+ trace_dump_writes("<");
+ trace_dump_writes(name);
+ trace_dump_writes(" ");
+ trace_dump_writes(attr1);
+ trace_dump_writes("='");
+ trace_dump_escape(value1);
+ trace_dump_writes("'>");
}
static INLINE void
-trace_dump_tag_begin2(struct trace_stream *stream,
- const char *name,
+trace_dump_tag_begin2(const char *name,
const char *attr1, const char *value1,
const char *attr2, const char *value2)
{
- trace_dump_write(stream, "<");
- trace_dump_write(stream, name);
- trace_dump_write(stream, " ");
- trace_dump_write(stream, attr1);
- trace_dump_write(stream, "=\'");
- trace_dump_escape(stream, value1);
- trace_dump_write(stream, "\' ");
- trace_dump_write(stream, attr2);
- trace_dump_write(stream, "=\'");
- trace_dump_escape(stream, value2);
- trace_dump_write(stream, "\'>");
+ trace_dump_writes("<");
+ trace_dump_writes(name);
+ trace_dump_writes(" ");
+ trace_dump_writes(attr1);
+ trace_dump_writes("=\'");
+ trace_dump_escape(value1);
+ trace_dump_writes("\' ");
+ trace_dump_writes(attr2);
+ trace_dump_writes("=\'");
+ trace_dump_escape(value2);
+ trace_dump_writes("\'>");
}
static INLINE void
-trace_dump_tag_begin3(struct trace_stream *stream,
- const char *name,
+trace_dump_tag_begin3(const char *name,
const char *attr1, const char *value1,
const char *attr2, const char *value2,
const char *attr3, const char *value3)
{
- trace_dump_write(stream, "<");
- trace_dump_write(stream, name);
- trace_dump_write(stream, " ");
- trace_dump_write(stream, attr1);
- trace_dump_write(stream, "=\'");
- trace_dump_escape(stream, value1);
- trace_dump_write(stream, "\' ");
- trace_dump_write(stream, attr2);
- trace_dump_write(stream, "=\'");
- trace_dump_escape(stream, value2);
- trace_dump_write(stream, "\' ");
- trace_dump_write(stream, attr3);
- trace_dump_write(stream, "=\'");
- trace_dump_escape(stream, value3);
- trace_dump_write(stream, "\'>");
+ trace_dump_writes("<");
+ trace_dump_writes(name);
+ trace_dump_writes(" ");
+ trace_dump_writes(attr1);
+ trace_dump_writes("=\'");
+ trace_dump_escape(value1);
+ trace_dump_writes("\' ");
+ trace_dump_writes(attr2);
+ trace_dump_writes("=\'");
+ trace_dump_escape(value2);
+ trace_dump_writes("\' ");
+ trace_dump_writes(attr3);
+ trace_dump_writes("=\'");
+ trace_dump_escape(value3);
+ trace_dump_writes("\'>");
}
static INLINE void
-trace_dump_tag_end(struct trace_stream *stream,
- const char *name)
+trace_dump_tag_end(const char *name)
{
- trace_dump_write(stream, "</");
- trace_dump_write(stream, name);
- trace_dump_write(stream, ">");
+ trace_dump_writes("</");
+ trace_dump_writes(name);
+ trace_dump_writes(">");
}
-
-void trace_dump_trace_begin(struct trace_stream *stream,
- unsigned version)
+static void
+trace_dump_trace_close(void)
{
- trace_dump_write(stream, "<?xml version='1.0' encoding='UTF-8'?>\n");
- trace_dump_write(stream, "<?xml-stylesheet type='text/xsl' href='trace.xsl'?>\n");
- trace_dump_writef(stream, "<trace version='%u'>\n", version);
+ if(stream) {
+ trace_dump_writes("</trace>\n");
+ util_stream_close(stream);
+ stream = NULL;
+ refcount = 0;
+ }
}
+boolean trace_dump_trace_begin()
+{
+ const char *filename;
+
+ filename = debug_get_option("GALLIUM_TRACE", NULL);
+ if(!filename)
+ return FALSE;
+
+ if(!stream) {
+
+ stream = util_stream_create(filename, 0);
+ if(!stream)
+ return FALSE;
+
+ trace_dump_writes("<?xml version='1.0' encoding='UTF-8'?>\n");
+ trace_dump_writes("<?xml-stylesheet type='text/xsl' href='trace.xsl'?>\n");
+ trace_dump_writes("<trace version='0.1'>\n");
+
+#if defined(PIPE_OS_LINUX)
+ /* Linux applications rarely cleanup GL / Gallium resources so catch
+ * application exit here */
+ atexit(trace_dump_trace_close);
+#endif
+ }
+
+ ++refcount;
+
+ return TRUE;
+}
+
+boolean trace_dump_enabled(void)
+{
+ return stream ? TRUE : FALSE;
+}
-void trace_dump_trace_end(struct trace_stream *stream)
+void trace_dump_trace_end(void)
{
- trace_dump_write(stream, "</trace>\n");
+ if(stream)
+ if(!--refcount)
+ trace_dump_trace_close();
}
-void trace_dump_call_begin(struct trace_stream *stream,
- const char *klass, const char *method)
+void trace_dump_call_begin(const char *klass, const char *method)
{
- trace_dump_indent(stream, 1);
- trace_dump_tag_begin2(stream, "call", "class", klass, "method", method);
- trace_dump_newline(stream);
+ trace_dump_indent(1);
+ trace_dump_tag_begin2("call", "class", klass, "method", method);
+ trace_dump_newline();
}
-void trace_dump_call_end(struct trace_stream *stream)
+void trace_dump_call_end(void)
{
- trace_dump_indent(stream, 1);
- trace_dump_tag_end(stream, "call");
- trace_dump_newline(stream);
+ trace_dump_indent(1);
+ trace_dump_tag_end("call");
+ trace_dump_newline();
+ util_stream_flush(stream);
}
-void trace_dump_arg_begin(struct trace_stream *stream,
- const char *name)
+void trace_dump_arg_begin(const char *name)
{
- trace_dump_indent(stream, 2);
- trace_dump_tag_begin1(stream, "arg", "name", name);
+ trace_dump_indent(2);
+ trace_dump_tag_begin1("arg", "name", name);
}
-void trace_dump_arg_end(struct trace_stream *stream)
+void trace_dump_arg_end(void)
{
- trace_dump_tag_end(stream, "arg");
- trace_dump_newline(stream);
+ trace_dump_tag_end("arg");
+ trace_dump_newline();
}
-void trace_dump_ret_begin(struct trace_stream *stream)
+void trace_dump_ret_begin(void)
{
- trace_dump_indent(stream, 2);
- trace_dump_tag_begin(stream, "ret");
+ trace_dump_indent(2);
+ trace_dump_tag_begin("ret");
}
-void trace_dump_ret_end(struct trace_stream *stream)
+void trace_dump_ret_end(void)
{
- trace_dump_tag_end(stream, "ret");
- trace_dump_newline(stream);
+ trace_dump_tag_end("ret");
+ trace_dump_newline();
}
-void trace_dump_bool(struct trace_stream *stream,
- int value)
+void trace_dump_bool(int value)
{
- trace_dump_writef(stream, "<bool>%c</bool>", value ? '1' : '0');
+ trace_dump_writef("<bool>%c</bool>", value ? '1' : '0');
}
-void trace_dump_int(struct trace_stream *stream,
- long int value)
+void trace_dump_int(long long int value)
{
- trace_dump_writef(stream, "<int>%li</int>", value);
+ trace_dump_writef("<int>%lli</int>", value);
}
-void trace_dump_uint(struct trace_stream *stream,
- long unsigned value)
+void trace_dump_uint(long long unsigned value)
{
- trace_dump_writef(stream, "<uint>%lu</uint>", value);
+ trace_dump_writef("<uint>%llu</uint>", value);
}
-void trace_dump_float(struct trace_stream *stream,
- double value)
+void trace_dump_float(double value)
{
- trace_dump_writef(stream, "<float>%g</float>", value);
+ trace_dump_writef("<float>%g</float>", value);
}
-void trace_dump_bytes(struct trace_stream *stream,
- const void *data,
+void trace_dump_bytes(const void *data,
long unsigned size)
{
static const char hex_table[16] = "0123456789ABCDEF";
const uint8_t *p = data;
long unsigned i;
- trace_dump_write(stream, "<bytes>");
+ trace_dump_writes("<bytes>");
for(i = 0; i < size; ++i) {
uint8_t byte = *p++;
char hex[2];
hex[0] = hex_table[byte >> 4];
hex[1] = hex_table[byte & 0xf];
- trace_stream_write(stream, hex, 2);
+ trace_dump_write(hex, 2);
}
- trace_dump_write(stream, "</bytes>");
+ trace_dump_writes("</bytes>");
}
-void trace_dump_string(struct trace_stream *stream,
- const char *str)
+void trace_dump_string(const char *str)
{
- trace_dump_write(stream, "<string>");
- trace_dump_escape(stream, str);
- trace_dump_write(stream, "</string>");
+ trace_dump_writes("<string>");
+ trace_dump_escape(str);
+ trace_dump_writes("</string>");
}
-void trace_dump_enum(struct trace_stream *stream,
- const char *value)
+void trace_dump_enum(const char *value)
{
- trace_dump_write(stream, "<enum>");
- trace_dump_escape(stream, value);
- trace_dump_write(stream, "</enum>");
+ trace_dump_writes("<enum>");
+ trace_dump_escape(value);
+ trace_dump_writes("</enum>");
}
-void trace_dump_array_begin(struct trace_stream *stream)
+void trace_dump_array_begin(void)
{
- trace_dump_write(stream, "<array>");
+ trace_dump_writes("<array>");
}
-void trace_dump_array_end(struct trace_stream *stream)
+void trace_dump_array_end(void)
{
- trace_dump_write(stream, "</array>");
+ trace_dump_writes("</array>");
}
-void trace_dump_elem_begin(struct trace_stream *stream)
+void trace_dump_elem_begin(void)
{
- trace_dump_write(stream, "<elem>");
+ trace_dump_writes("<elem>");
}
-void trace_dump_elem_end(struct trace_stream *stream)
+void trace_dump_elem_end(void)
{
- trace_dump_write(stream, "</elem>");
+ trace_dump_writes("</elem>");
}
-void trace_dump_struct_begin(struct trace_stream *stream,
- const char *name)
+void trace_dump_struct_begin(const char *name)
{
- trace_dump_writef(stream, "<struct name='%s'>", name);
+ trace_dump_writef("<struct name='%s'>", name);
}
-void trace_dump_struct_end(struct trace_stream *stream)
+void trace_dump_struct_end(void)
{
- trace_dump_write(stream, "</struct>");
+ trace_dump_writes("</struct>");
}
-void trace_dump_member_begin(struct trace_stream *stream,
- const char *name)
+void trace_dump_member_begin(const char *name)
{
- trace_dump_writef(stream, "<member name='%s'>", name);
+ trace_dump_writef("<member name='%s'>", name);
}
-void trace_dump_member_end(struct trace_stream *stream)
+void trace_dump_member_end(void)
{
- trace_dump_write(stream, "</member>");
+ trace_dump_writes("</member>");
}
-void trace_dump_null(struct trace_stream *stream)
+void trace_dump_null(void)
{
- trace_dump_write(stream, "<null/>");
+ trace_dump_writes("<null/>");
}
-void trace_dump_ptr(struct trace_stream *stream,
- const void *value)
+void trace_dump_ptr(const void *value)
{
if(value)
- trace_dump_writef(stream, "<ptr>%p</ptr>", value);
+ trace_dump_writef("<ptr>0x%08lx</ptr>", (unsigned long)(uintptr_t)value);
else
- trace_dump_null(stream);
+ trace_dump_null();
}
diff --git a/src/gallium/drivers/trace/tr_dump.h b/src/gallium/drivers/trace/tr_dump.h
index b2367c3288..76a53731b3 100644
--- a/src/gallium/drivers/trace/tr_dump.h
+++ b/src/gallium/drivers/trace/tr_dump.h
@@ -4,7 +4,7 @@
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation streams (the
+ * 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
@@ -34,100 +34,98 @@
#define TR_DUMP_H
-#include "pipe/p_util.h"
-
-
-struct trace_stream;
-
-
-void trace_dump_trace_begin(struct trace_stream *stream, unsigned version);
-void trace_dump_trace_end(struct trace_stream *stream);
-void trace_dump_call_begin(struct trace_stream *stream, const char *klass, const char *method);
-void trace_dump_call_end(struct trace_stream *stream);
-void trace_dump_arg_begin(struct trace_stream *stream, const char *name);
-void trace_dump_arg_end(struct trace_stream *stream);
-void trace_dump_ret_begin(struct trace_stream *stream);
-void trace_dump_ret_end(struct trace_stream *stream);
-void trace_dump_bool(struct trace_stream *stream, int value);
-void trace_dump_int(struct trace_stream *stream, long int value);
-void trace_dump_uint(struct trace_stream *stream, long unsigned value);
-void trace_dump_float(struct trace_stream *stream, double value);
-void trace_dump_bytes(struct trace_stream *stream, const void *data, long unsigned size);
-void trace_dump_string(struct trace_stream *stream, const char *str);
-void trace_dump_enum(struct trace_stream *stream, const char *value);
-void trace_dump_array_begin(struct trace_stream *stream);
-void trace_dump_array_end(struct trace_stream *stream);
-void trace_dump_elem_begin(struct trace_stream *stream);
-void trace_dump_elem_end(struct trace_stream *stream);
-void trace_dump_struct_begin(struct trace_stream *stream, const char *name);
-void trace_dump_struct_end(struct trace_stream *stream);
-void trace_dump_member_begin(struct trace_stream *stream, const char *name);
-void trace_dump_member_end(struct trace_stream *stream);
-void trace_dump_null(struct trace_stream *stream);
-void trace_dump_ptr(struct trace_stream *stream, const void *value);
+#include "pipe/p_compiler.h"
+
+
+boolean trace_dump_trace_begin(void);
+boolean trace_dump_enabled(void);
+void trace_dump_trace_end(void);
+void trace_dump_call_begin(const char *klass, const char *method);
+void trace_dump_call_end(void);
+void trace_dump_arg_begin(const char *name);
+void trace_dump_arg_end(void);
+void trace_dump_ret_begin(void);
+void trace_dump_ret_end(void);
+void trace_dump_bool(int value);
+void trace_dump_int(long long int value);
+void trace_dump_uint(long long unsigned value);
+void trace_dump_float(double value);
+void trace_dump_bytes(const void *data, long unsigned size);
+void trace_dump_string(const char *str);
+void trace_dump_enum(const char *value);
+void trace_dump_array_begin(void);
+void trace_dump_array_end(void);
+void trace_dump_elem_begin(void);
+void trace_dump_elem_end(void);
+void trace_dump_struct_begin(const char *name);
+void trace_dump_struct_end(void);
+void trace_dump_member_begin(const char *name);
+void trace_dump_member_end(void);
+void trace_dump_null(void);
+void trace_dump_ptr(const void *value);
/*
* Code saving macros.
*/
-#define trace_dump_arg(_stream, _type, _arg) \
+#define trace_dump_arg(_type, _arg) \
do { \
- trace_dump_arg_begin(_stream, #_arg); \
- trace_dump_##_type(_stream, _arg); \
- trace_dump_arg_end(_stream); \
+ trace_dump_arg_begin(#_arg); \
+ trace_dump_##_type(_arg); \
+ trace_dump_arg_end(); \
} while(0)
-#define trace_dump_ret(_stream, _type, _arg) \
+#define trace_dump_ret(_type, _arg) \
do { \
- trace_dump_ret_begin(_stream); \
- trace_dump_##_type(_stream, _arg); \
- trace_dump_ret_end(_stream); \
+ trace_dump_ret_begin(); \
+ trace_dump_##_type(_arg); \
+ trace_dump_ret_end(); \
} while(0)
-#define trace_dump_array(_stream, _type, _obj, _size) \
+#define trace_dump_array(_type, _obj, _size) \
do { \
unsigned long idx; \
- trace_dump_array_begin(_stream); \
+ trace_dump_array_begin(); \
for(idx = 0; idx < (_size); ++idx) { \
- trace_dump_elem_begin(_stream); \
- trace_dump_##_type(_stream, (_obj)[idx]); \
- trace_dump_elem_end(_stream); \
+ trace_dump_elem_begin(); \
+ trace_dump_##_type((_obj)[idx]); \
+ trace_dump_elem_end(); \
} \
- trace_dump_array_end(_stream); \
+ trace_dump_array_end(); \
} while(0)
-#define trace_dump_struct_array(_stream, _type, _obj, _size) \
+#define trace_dump_struct_array(_type, _obj, _size) \
do { \
unsigned long idx; \
- trace_dump_array_begin(_stream); \
+ trace_dump_array_begin(); \
for(idx = 0; idx < (_size); ++idx) { \
- trace_dump_elem_begin(_stream); \
- trace_dump_##_type(_stream, &(_obj)[idx]); \
- trace_dump_elem_end(_stream); \
+ trace_dump_elem_begin(); \
+ trace_dump_##_type(&(_obj)[idx]); \
+ trace_dump_elem_end(); \
} \
- trace_dump_array_end(_stream); \
+ trace_dump_array_end(); \
} while(0)
-#define trace_dump_member(_stream, _type, _obj, _member) \
+#define trace_dump_member(_type, _obj, _member) \
do { \
- trace_dump_member_begin(_stream, #_member); \
- trace_dump_##_type(_stream, (_obj)->_member); \
- trace_dump_member_end(_stream); \
+ trace_dump_member_begin(#_member); \
+ trace_dump_##_type((_obj)->_member); \
+ trace_dump_member_end(); \
} while(0)
-#define trace_dump_arg_array(_stream, _type, _arg, _size) \
+#define trace_dump_arg_array(_type, _arg, _size) \
do { \
- trace_dump_arg_begin(_stream, #_arg); \
- trace_dump_array(_stream, _type, _arg, _size); \
- trace_dump_arg_end(_stream); \
+ trace_dump_arg_begin(#_arg); \
+ trace_dump_array(_type, _arg, _size); \
+ trace_dump_arg_end(); \
} while(0)
-#define trace_dump_member_array(_stream, _type, _obj, _member) \
+#define trace_dump_member_array(_type, _obj, _member) \
do { \
- trace_dump_member_begin(_stream, #_member); \
- trace_dump_array(_stream, _type, (_obj)->_member, sizeof((_obj)->_member)/sizeof((_obj)->_member[0])); \
- trace_dump_member_end(_stream); \
+ trace_dump_member_begin(#_member); \
+ trace_dump_array(_type, (_obj)->_member, sizeof((_obj)->_member)/sizeof((_obj)->_member[0])); \
+ trace_dump_member_end(); \
} while(0)
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index 27c218039e..8789f86b1a 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -25,12 +25,12 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
-#include "tr_stream.h"
#include "tr_dump.h"
#include "tr_state.h"
#include "tr_winsys.h"
+#include "tr_texture.h"
#include "tr_screen.h"
@@ -38,19 +38,18 @@ static const char *
trace_screen_get_name(struct pipe_screen *_screen)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
const char *result;
- trace_dump_call_begin(stream, "pipe_screen", "get_name");
+ trace_dump_call_begin("pipe_screen", "get_name");
- trace_dump_arg(stream, ptr, screen);
+ trace_dump_arg(ptr, screen);
result = screen->get_name(screen);
- trace_dump_ret(stream, string, result);
+ trace_dump_ret(string, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -60,19 +59,18 @@ static const char *
trace_screen_get_vendor(struct pipe_screen *_screen)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
const char *result;
- trace_dump_call_begin(stream, "pipe_screen", "get_vendor");
+ trace_dump_call_begin("pipe_screen", "get_vendor");
- trace_dump_arg(stream, ptr, screen);
+ trace_dump_arg(ptr, screen);
result = screen->get_vendor(screen);
- trace_dump_ret(stream, string, result);
+ trace_dump_ret(string, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -83,20 +81,19 @@ trace_screen_get_param(struct pipe_screen *_screen,
int param)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
int result;
- trace_dump_call_begin(stream, "pipe_screen", "get_param");
+ trace_dump_call_begin("pipe_screen", "get_param");
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, int, param);
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(int, param);
result = screen->get_param(screen, param);
- trace_dump_ret(stream, int, result);
+ trace_dump_ret(int, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -107,20 +104,19 @@ trace_screen_get_paramf(struct pipe_screen *_screen,
int param)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
float result;
- trace_dump_call_begin(stream, "pipe_screen", "get_paramf");
+ trace_dump_call_begin("pipe_screen", "get_paramf");
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, int, param);
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(int, param);
result = screen->get_paramf(screen, param);
- trace_dump_ret(stream, float, result);
+ trace_dump_ret(float, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -134,23 +130,22 @@ trace_screen_is_format_supported(struct pipe_screen *_screen,
unsigned geom_flags)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
boolean result;
- trace_dump_call_begin(stream, "pipe_screen", "is_format_supported");
+ trace_dump_call_begin("pipe_screen", "is_format_supported");
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, format, format);
- trace_dump_arg(stream, int, target);
- trace_dump_arg(stream, uint, tex_usage);
- trace_dump_arg(stream, uint, geom_flags);
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(format, format);
+ trace_dump_arg(int, target);
+ trace_dump_arg(uint, tex_usage);
+ trace_dump_arg(uint, geom_flags);
result = screen->is_format_supported(screen, format, target, tex_usage, geom_flags);
- trace_dump_ret(stream, bool, result);
+ trace_dump_ret(bool, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -161,20 +156,21 @@ trace_screen_texture_create(struct pipe_screen *_screen,
const struct pipe_texture *templat)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
struct pipe_texture *result;
- trace_dump_call_begin(stream, "pipe_screen", "texture_create");
+ trace_dump_call_begin("pipe_screen", "texture_create");
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, template, templat);
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(template, templat);
result = screen->texture_create(screen, templat);
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
+
+ result = trace_texture_create(tr_scr, result);
return result;
}
@@ -187,23 +183,24 @@ trace_screen_texture_blanket(struct pipe_screen *_screen,
struct pipe_buffer *buffer)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
unsigned pitch = *ppitch;
struct pipe_texture *result;
- trace_dump_call_begin(stream, "pipe_screen", "texture_blanket");
+ trace_dump_call_begin("pipe_screen", "texture_blanket");
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, template, templat);
- trace_dump_arg(stream, uint, pitch);
- trace_dump_arg(stream, ptr, buffer);
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(template, templat);
+ trace_dump_arg(uint, pitch);
+ trace_dump_arg(ptr, buffer);
result = screen->texture_blanket(screen, templat, ppitch, buffer);
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
+
+ trace_dump_call_end();
- trace_dump_call_end(stream);
+ result = trace_texture_create(tr_scr, result);
return result;
}
@@ -214,20 +211,36 @@ trace_screen_texture_release(struct pipe_screen *_screen,
struct pipe_texture **ptexture)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
- struct pipe_texture *texture = *ptexture;
-
- trace_dump_call_begin(stream, "pipe_screen", "texture_release");
-
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, ptr, texture);
-
- screen->texture_release(screen, ptexture);
-
- trace_dump_call_end(stream);
+ struct trace_texture *tr_tex;
+ struct pipe_texture *texture;
+
+ assert(ptexture);
+ if(*ptexture) {
+ tr_tex = trace_texture(tr_scr, *ptexture);
+ texture = tr_tex->texture;
+ assert(texture->screen == screen);
+ }
+ else
+ texture = NULL;
+
+ if (*ptexture) {
+ if (!--(*ptexture)->refcount) {
+ trace_dump_call_begin("pipe_screen", "texture_destroy");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, texture);
+
+ trace_texture_destroy(tr_scr, *ptexture);
+
+ trace_dump_call_end();
+ }
+
+ *ptexture = NULL;
+ }
}
+
static struct pipe_surface *
trace_screen_get_tex_surface(struct pipe_screen *_screen,
struct pipe_texture *texture,
@@ -236,25 +249,32 @@ trace_screen_get_tex_surface(struct pipe_screen *_screen,
unsigned usage)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
+ struct trace_texture *tr_tex;
struct pipe_surface *result;
- trace_dump_call_begin(stream, "pipe_screen", "get_tex_surface");
+ assert(texture);
+ tr_tex = trace_texture(tr_scr, texture);
+ texture = tr_tex->texture;
+ assert(texture->screen == screen);
+
+ trace_dump_call_begin("pipe_screen", "get_tex_surface");
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, ptr, texture);
- trace_dump_arg(stream, uint, face);
- trace_dump_arg(stream, uint, level);
- trace_dump_arg(stream, uint, zslice);
- trace_dump_arg(stream, uint, usage);
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, texture);
+ trace_dump_arg(uint, face);
+ trace_dump_arg(uint, level);
+ trace_dump_arg(uint, zslice);
+ trace_dump_arg(uint, usage);
result = screen->get_tex_surface(screen, texture, face, level, zslice, usage);
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
+ result = trace_surface_create(tr_tex, result);
+
return result;
}
@@ -264,18 +284,34 @@ trace_screen_tex_surface_release(struct pipe_screen *_screen,
struct pipe_surface **psurface)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
- struct pipe_surface *surface = *psurface;
-
- trace_dump_call_begin(stream, "pipe_screen", "tex_surface_release");
-
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, ptr, surface);
-
- screen->tex_surface_release(screen, psurface);
-
- trace_dump_call_end(stream);
+ struct trace_texture *tr_tex;
+ struct trace_surface *tr_surf;
+ struct pipe_surface *surface;
+
+ assert(psurface);
+ if(*psurface) {
+ tr_tex = trace_texture(tr_scr, (*psurface)->texture);
+ tr_surf = trace_surface(tr_tex, *psurface);
+ surface = tr_surf->surface;
+ }
+ else
+ surface = NULL;
+
+ if (*psurface) {
+ if (!--(*psurface)->refcount) {
+ trace_dump_call_begin("pipe_screen", "tex_surface_destroy");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, surface);
+
+ trace_surface_destroy(tr_tex, *psurface);
+
+ trace_dump_call_end();
+ }
+
+ *psurface = NULL;
+ }
}
@@ -285,23 +321,24 @@ trace_screen_surface_map(struct pipe_screen *_screen,
unsigned flags)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
- struct pipe_surface *result;
-
- trace_dump_call_begin(stream, "pipe_screen", "surface_map");
-
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, ptr, surface);
- trace_dump_arg(stream, uint, flags);
-
- result = screen->surface_map(screen, surface, flags);
-
- trace_dump_ret(stream, ptr, result);
-
- trace_dump_call_end(stream);
-
- return result;
+ struct trace_texture *tr_tex;
+ struct trace_surface *tr_surf;
+ void *map;
+
+ tr_tex = trace_texture(tr_scr, surface->texture);
+ tr_surf = trace_surface(tr_tex, surface);
+ surface = tr_surf->surface;
+
+ map = screen->surface_map(screen, surface, flags);
+ if(map) {
+ if(flags & PIPE_BUFFER_USAGE_CPU_WRITE) {
+ assert(!tr_surf->map);
+ tr_surf->map = map;
+ }
+ }
+
+ return map;
}
@@ -310,17 +347,41 @@ trace_screen_surface_unmap(struct pipe_screen *_screen,
struct pipe_surface *surface)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
-
- trace_dump_call_begin(stream, "pipe_screen", "surface_unmap");
-
- trace_dump_arg(stream, ptr, screen);
- trace_dump_arg(stream, ptr, surface);
+ struct trace_texture *tr_tex;
+ struct trace_surface *tr_surf;
+
+ tr_tex = trace_texture(tr_scr, surface->texture);
+ tr_surf = trace_surface(tr_tex, surface);
+ surface = tr_surf->surface;
+
+ if(tr_surf->map) {
+ size_t size = surface->nblocksy * surface->stride;
+
+ trace_dump_call_begin("pipe_winsys", "surface_write");
+
+ trace_dump_arg(ptr, screen);
+
+ trace_dump_arg(ptr, surface);
+
+ trace_dump_arg_begin("data");
+ trace_dump_bytes(tr_surf->map, size);
+ trace_dump_arg_end();
+
+ trace_dump_arg_begin("stride");
+ trace_dump_uint(surface->stride);
+ trace_dump_arg_end();
+
+ trace_dump_arg_begin("size");
+ trace_dump_uint(size);
+ trace_dump_arg_end();
+
+ trace_dump_call_end();
+
+ tr_surf->map = NULL;
+ }
screen->surface_unmap(screen, surface);
-
- trace_dump_call_end(stream);
}
@@ -328,17 +389,18 @@ static void
trace_screen_destroy(struct pipe_screen *_screen)
{
struct trace_screen *tr_scr = trace_screen(_screen);
- struct trace_stream *stream = tr_scr->stream;
struct pipe_screen *screen = tr_scr->screen;
- trace_dump_call_begin(stream, "pipe_screen", "destroy");
+ trace_dump_call_begin("pipe_screen", "destroy");
- trace_dump_arg(stream, ptr, screen);
+ trace_dump_arg(ptr, screen);
screen->destroy(screen);
- trace_dump_call_end(stream);
-
+ trace_dump_call_end();
+
+ trace_dump_trace_end();
+
FREE(tr_scr);
}
@@ -346,17 +408,24 @@ trace_screen_destroy(struct pipe_screen *_screen)
struct pipe_screen *
trace_screen_create(struct pipe_screen *screen)
{
- struct trace_stream *stream;
struct trace_screen *tr_scr;
+ struct pipe_winsys *winsys;
- if(!debug_get_bool_option("GALLIUM_TRACE", FALSE))
- return screen;
-
+ if(!screen)
+ goto error1;
+
+ if(!trace_dump_trace_begin())
+ goto error1;
+
tr_scr = CALLOC_STRUCT(trace_screen);
if(!tr_scr)
- return NULL;
+ goto error2;
- tr_scr->base.winsys = screen->winsys;
+ winsys = trace_winsys_create(screen->winsys);
+ if(!winsys)
+ goto error3;
+
+ tr_scr->base.winsys = winsys;
tr_scr->base.destroy = trace_screen_destroy;
tr_scr->base.get_name = trace_screen_get_name;
tr_scr->base.get_vendor = trace_screen_get_vendor;
@@ -372,17 +441,29 @@ trace_screen_create(struct pipe_screen *screen)
tr_scr->base.surface_unmap = trace_screen_surface_unmap;
tr_scr->screen = screen;
- tr_scr->stream = stream = trace_winsys(screen->winsys)->stream;
-
- /* We don't want to trace the internal pipe calls */
- screen->winsys = trace_winsys(screen->winsys)->winsys;
- trace_dump_call_begin(stream, "", "pipe_screen_create");
- trace_dump_arg_begin(stream, "winsys");
- trace_dump_ptr(stream, screen->winsys);
- trace_dump_arg_end(stream);
- trace_dump_ret(stream, ptr, screen);
- trace_dump_call_end(stream);
+ trace_dump_call_begin("", "pipe_screen_create");
+ trace_dump_arg_begin("winsys");
+ trace_dump_ptr(screen->winsys);
+ trace_dump_arg_end();
+ trace_dump_ret(ptr, screen);
+ trace_dump_call_end();
return &tr_scr->base;
+
+error3:
+ FREE(tr_scr);
+error2:
+ trace_dump_trace_end();
+error1:
+ return screen;
+}
+
+
+struct trace_screen *
+trace_screen(struct pipe_screen *screen)
+{
+ assert(screen);
+ assert(screen->destroy == trace_screen_destroy);
+ return (struct trace_screen *)screen;
}
diff --git a/src/gallium/drivers/trace/tr_screen.h b/src/gallium/drivers/trace/tr_screen.h
index 40b844778f..93fefdb9a5 100644
--- a/src/gallium/drivers/trace/tr_screen.h
+++ b/src/gallium/drivers/trace/tr_screen.h
@@ -29,35 +29,32 @@
#define TR_SCREEN_H_
-#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
#include "pipe/p_screen.h"
-struct trace_stream;
-
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct trace_screen
{
struct pipe_screen base;
struct pipe_screen *screen;
-
- struct trace_stream *stream;
};
-static INLINE struct trace_screen *
-trace_screen(struct pipe_screen *screen)
-{
- assert(screen);
- return (struct trace_screen *)screen;
-}
-
+struct trace_screen *
+trace_screen(struct pipe_screen *screen);
struct pipe_screen *
trace_screen_create(struct pipe_screen *screen);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* TR_SCREEN_H_ */
diff --git a/src/gallium/drivers/trace/tr_state.c b/src/gallium/drivers/trace/tr_state.c
index e074ae7abc..986d939e0c 100644
--- a/src/gallium/drivers/trace/tr_state.c
+++ b/src/gallium/drivers/trace/tr_state.c
@@ -27,467 +27,438 @@
#include "pipe/p_compiler.h"
+#include "util/u_memory.h"
#include "tgsi/tgsi_dump.h"
#include "tr_dump.h"
#include "tr_state.h"
-void trace_dump_format(struct trace_stream *stream,
- enum pipe_format format)
+void trace_dump_format(enum pipe_format format)
{
- trace_dump_enum(stream, pf_name(format) );
+ trace_dump_enum(pf_name(format) );
}
-void trace_dump_block(struct trace_stream *stream,
- const struct pipe_format_block *block)
+void trace_dump_block(const struct pipe_format_block *block)
{
- trace_dump_struct_begin(stream, "pipe_format_block");
- trace_dump_member(stream, uint, block, size);
- trace_dump_member(stream, uint, block, width);
- trace_dump_member(stream, uint, block, height);
- trace_dump_struct_end(stream);
+ trace_dump_struct_begin("pipe_format_block");
+ trace_dump_member(uint, block, size);
+ trace_dump_member(uint, block, width);
+ trace_dump_member(uint, block, height);
+ trace_dump_struct_end();
}
-void trace_dump_template(struct trace_stream *stream,
- const struct pipe_texture *templat)
+void trace_dump_template(const struct pipe_texture *templat)
{
- assert(templat);
if(!templat) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_texture");
+ trace_dump_struct_begin("pipe_texture");
- trace_dump_member(stream, int, templat, target);
- trace_dump_member(stream, format, templat, format);
+ trace_dump_member(int, templat, target);
+ trace_dump_member(format, templat, format);
- trace_dump_member_begin(stream, "width");
- trace_dump_array(stream, uint, templat->width, 1);
- trace_dump_member_end(stream);
+ trace_dump_member_begin("width");
+ trace_dump_array(uint, templat->width, 1);
+ trace_dump_member_end();
- trace_dump_member_begin(stream, "height");
- trace_dump_array(stream, uint, templat->height, 1);
- trace_dump_member_end(stream);
+ trace_dump_member_begin("height");
+ trace_dump_array(uint, templat->height, 1);
+ trace_dump_member_end();
- trace_dump_member_begin(stream, "depth");
- trace_dump_array(stream, uint, templat->depth, 1);
- trace_dump_member_end(stream);
+ trace_dump_member_begin("depth");
+ trace_dump_array(uint, templat->depth, 1);
+ trace_dump_member_end();
- trace_dump_member_begin(stream, "block");
- trace_dump_block(stream, &templat->block);
- trace_dump_member_end(stream);
+ trace_dump_member_begin("block");
+ trace_dump_block(&templat->block);
+ trace_dump_member_end();
- trace_dump_member(stream, uint, templat, last_level);
- trace_dump_member(stream, uint, templat, tex_usage);
+ trace_dump_member(uint, templat, last_level);
+ trace_dump_member(uint, templat, tex_usage);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_rasterizer_state(struct trace_stream *stream,
- const struct pipe_rasterizer_state *state)
+void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_rasterizer_state");
-
- trace_dump_member(stream, bool, state, flatshade);
- trace_dump_member(stream, bool, state, light_twoside);
- trace_dump_member(stream, uint, state, front_winding);
- trace_dump_member(stream, uint, state, cull_mode);
- trace_dump_member(stream, uint, state, fill_cw);
- trace_dump_member(stream, uint, state, fill_ccw);
- trace_dump_member(stream, bool, state, offset_cw);
- trace_dump_member(stream, bool, state, offset_ccw);
- trace_dump_member(stream, bool, state, scissor);
- trace_dump_member(stream, bool, state, poly_smooth);
- trace_dump_member(stream, bool, state, poly_stipple_enable);
- trace_dump_member(stream, bool, state, point_smooth);
- trace_dump_member(stream, bool, state, point_sprite);
- trace_dump_member(stream, bool, state, point_size_per_vertex);
- trace_dump_member(stream, bool, state, multisample);
- trace_dump_member(stream, bool, state, line_smooth);
- trace_dump_member(stream, bool, state, line_stipple_enable);
- trace_dump_member(stream, uint, state, line_stipple_factor);
- trace_dump_member(stream, uint, state, line_stipple_pattern);
- trace_dump_member(stream, bool, state, line_last_pixel);
- trace_dump_member(stream, bool, state, bypass_clipping);
- trace_dump_member(stream, bool, state, bypass_vs);
- trace_dump_member(stream, bool, state, origin_lower_left);
- trace_dump_member(stream, bool, state, flatshade_first);
- trace_dump_member(stream, bool, state, gl_rasterization_rules);
-
- trace_dump_member(stream, float, state, line_width);
- trace_dump_member(stream, float, state, point_size);
- trace_dump_member(stream, float, state, point_size_min);
- trace_dump_member(stream, float, state, point_size_max);
- trace_dump_member(stream, float, state, offset_units);
- trace_dump_member(stream, float, state, offset_scale);
+ trace_dump_struct_begin("pipe_rasterizer_state");
+
+ trace_dump_member(bool, state, flatshade);
+ trace_dump_member(bool, state, light_twoside);
+ trace_dump_member(uint, state, front_winding);
+ trace_dump_member(uint, state, cull_mode);
+ trace_dump_member(uint, state, fill_cw);
+ trace_dump_member(uint, state, fill_ccw);
+ trace_dump_member(bool, state, offset_cw);
+ trace_dump_member(bool, state, offset_ccw);
+ trace_dump_member(bool, state, scissor);
+ trace_dump_member(bool, state, poly_smooth);
+ trace_dump_member(bool, state, poly_stipple_enable);
+ trace_dump_member(bool, state, point_smooth);
+ trace_dump_member(bool, state, point_sprite);
+ trace_dump_member(bool, state, point_size_per_vertex);
+ trace_dump_member(bool, state, multisample);
+ trace_dump_member(bool, state, line_smooth);
+ trace_dump_member(bool, state, line_stipple_enable);
+ trace_dump_member(uint, state, line_stipple_factor);
+ trace_dump_member(uint, state, line_stipple_pattern);
+ trace_dump_member(bool, state, line_last_pixel);
+ trace_dump_member(bool, state, bypass_clipping);
+ trace_dump_member(bool, state, bypass_vs);
+ trace_dump_member(bool, state, origin_lower_left);
+ trace_dump_member(bool, state, flatshade_first);
+ trace_dump_member(bool, state, gl_rasterization_rules);
+
+ trace_dump_member(float, state, line_width);
+ trace_dump_member(float, state, point_size);
+ trace_dump_member(float, state, point_size_min);
+ trace_dump_member(float, state, point_size_max);
+ trace_dump_member(float, state, offset_units);
+ trace_dump_member(float, state, offset_scale);
- trace_dump_member_array(stream, uint, state, sprite_coord_mode);
+ trace_dump_member_array(uint, state, sprite_coord_mode);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_poly_stipple(struct trace_stream *stream,
- const struct pipe_poly_stipple *state)
+void trace_dump_poly_stipple(const struct pipe_poly_stipple *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_poly_stipple");
+ trace_dump_struct_begin("pipe_poly_stipple");
- trace_dump_member_begin(stream, "stipple");
- trace_dump_array(stream,
- uint,
+ trace_dump_member_begin("stipple");
+ trace_dump_array(uint,
state->stipple,
Elements(state->stipple));
- trace_dump_member_end(stream);
+ trace_dump_member_end();
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_viewport_state(struct trace_stream *stream,
- const struct pipe_viewport_state *state)
+void trace_dump_viewport_state(const struct pipe_viewport_state *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_viewport_state");
+ trace_dump_struct_begin("pipe_viewport_state");
- trace_dump_member_array(stream, float, state, scale);
- trace_dump_member_array(stream, float, state, translate);
+ trace_dump_member_array(float, state, scale);
+ trace_dump_member_array(float, state, translate);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_scissor_state(struct trace_stream *stream,
- const struct pipe_scissor_state *state)
+void trace_dump_scissor_state(const struct pipe_scissor_state *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_scissor_state");
+ trace_dump_struct_begin("pipe_scissor_state");
- trace_dump_member(stream, uint, state, minx);
- trace_dump_member(stream, uint, state, miny);
- trace_dump_member(stream, uint, state, maxx);
- trace_dump_member(stream, uint, state, maxy);
+ trace_dump_member(uint, state, minx);
+ trace_dump_member(uint, state, miny);
+ trace_dump_member(uint, state, maxx);
+ trace_dump_member(uint, state, maxy);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_clip_state(struct trace_stream *stream,
- const struct pipe_clip_state *state)
+void trace_dump_clip_state(const struct pipe_clip_state *state)
{
unsigned i;
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_scissor_state");
+ trace_dump_struct_begin("pipe_clip_state");
- trace_dump_member_begin(stream, "ucp");
- trace_dump_array_begin(stream);
- for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i)
- trace_dump_array(stream, float, state->ucp[i], 4);
- trace_dump_array_end(stream);
- trace_dump_member_end(stream);
+ trace_dump_member_begin("ucp");
+ trace_dump_array_begin();
+ for(i = 0; i < PIPE_MAX_CLIP_PLANES; ++i) {
+ trace_dump_elem_begin();
+ trace_dump_array(float, state->ucp[i], 4);
+ trace_dump_elem_end();
+ }
+ trace_dump_array_end();
+ trace_dump_member_end();
- trace_dump_member(stream, uint, state, nr);
+ trace_dump_member(uint, state, nr);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_constant_buffer(struct trace_stream *stream,
- const struct pipe_constant_buffer *state)
+void trace_dump_constant_buffer(const struct pipe_constant_buffer *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_constant_buffer");
+ trace_dump_struct_begin("pipe_constant_buffer");
- trace_dump_member(stream, ptr, state, buffer);
- trace_dump_member(stream, uint, state, size);
+ trace_dump_member(ptr, state, buffer);
+ trace_dump_member(uint, state, size);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_shader_state(struct trace_stream *stream,
- const struct pipe_shader_state *state)
+void trace_dump_shader_state(const struct pipe_shader_state *state)
{
static char str[8192];
- assert(state);
+
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
tgsi_dump_str(state->tokens, 0, str, sizeof(str));
- trace_dump_struct_begin(stream, "pipe_shader_state");
+ trace_dump_struct_begin("pipe_shader_state");
- trace_dump_member_begin(stream, "tokens");
- trace_dump_string(stream, str);
- trace_dump_member_end(stream);
+ trace_dump_member_begin("tokens");
+ trace_dump_string(str);
+ trace_dump_member_end();
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_depth_stencil_alpha_state(struct trace_stream *stream,
- const struct pipe_depth_stencil_alpha_state *state)
+void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state)
{
unsigned i;
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_depth_stencil_alpha_state");
+ trace_dump_struct_begin("pipe_depth_stencil_alpha_state");
- trace_dump_member_begin(stream, "depth");
- trace_dump_struct_begin(stream, "pipe_depth_state");
- trace_dump_member(stream, bool, &state->depth, enabled);
- trace_dump_member(stream, bool, &state->depth, writemask);
- trace_dump_member(stream, uint, &state->depth, func);
- trace_dump_member(stream, bool, &state->depth, occlusion_count);
- trace_dump_struct_end(stream);
- trace_dump_member_end(stream);
+ trace_dump_member_begin("depth");
+ trace_dump_struct_begin("pipe_depth_state");
+ trace_dump_member(bool, &state->depth, enabled);
+ trace_dump_member(bool, &state->depth, writemask);
+ trace_dump_member(uint, &state->depth, func);
+ trace_dump_member(bool, &state->depth, occlusion_count);
+ trace_dump_struct_end();
+ trace_dump_member_end();
- trace_dump_member_begin(stream, "stencil");
- trace_dump_array_begin(stream);
+ trace_dump_member_begin("stencil");
+ trace_dump_array_begin();
for(i = 0; i < Elements(state->stencil); ++i) {
- trace_dump_elem_begin(stream);
- trace_dump_struct_begin(stream, "pipe_stencil_state");
- trace_dump_member(stream, bool, &state->stencil[i], enabled);
- trace_dump_member(stream, uint, &state->stencil[i], func);
- trace_dump_member(stream, uint, &state->stencil[i], fail_op);
- trace_dump_member(stream, uint, &state->stencil[i], zpass_op);
- trace_dump_member(stream, uint, &state->stencil[i], zfail_op);
- trace_dump_member(stream, uint, &state->stencil[i], ref_value);
- trace_dump_member(stream, uint, &state->stencil[i], value_mask);
- trace_dump_member(stream, uint, &state->stencil[i], write_mask);
- trace_dump_struct_end(stream);
- trace_dump_elem_end(stream);
+ trace_dump_elem_begin();
+ trace_dump_struct_begin("pipe_stencil_state");
+ trace_dump_member(bool, &state->stencil[i], enabled);
+ trace_dump_member(uint, &state->stencil[i], func);
+ trace_dump_member(uint, &state->stencil[i], fail_op);
+ trace_dump_member(uint, &state->stencil[i], zpass_op);
+ trace_dump_member(uint, &state->stencil[i], zfail_op);
+ trace_dump_member(uint, &state->stencil[i], ref_value);
+ trace_dump_member(uint, &state->stencil[i], value_mask);
+ trace_dump_member(uint, &state->stencil[i], write_mask);
+ trace_dump_struct_end();
+ trace_dump_elem_end();
}
- trace_dump_array_end(stream);
- trace_dump_member_end(stream);
-
- trace_dump_member_begin(stream, "alpha");
- trace_dump_struct_begin(stream, "pipe_alpha_state");
- trace_dump_member(stream, bool, &state->alpha, enabled);
- trace_dump_member(stream, uint, &state->alpha, func);
- trace_dump_member(stream, float, &state->alpha, ref);
- trace_dump_struct_end(stream);
- trace_dump_member_end(stream);
-
- trace_dump_struct_end(stream);
+ trace_dump_array_end();
+ trace_dump_member_end();
+
+ trace_dump_member_begin("alpha");
+ trace_dump_struct_begin("pipe_alpha_state");
+ trace_dump_member(bool, &state->alpha, enabled);
+ trace_dump_member(uint, &state->alpha, func);
+ trace_dump_member(float, &state->alpha, ref);
+ trace_dump_struct_end();
+ trace_dump_member_end();
+
+ trace_dump_struct_end();
}
-void trace_dump_blend_state(struct trace_stream *stream,
- const struct pipe_blend_state *state)
+void trace_dump_blend_state(const struct pipe_blend_state *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_blend_state");
+ trace_dump_struct_begin("pipe_blend_state");
- trace_dump_member(stream, bool, state, blend_enable);
+ trace_dump_member(bool, state, blend_enable);
- trace_dump_member(stream, uint, state, rgb_func);
- trace_dump_member(stream, uint, state, rgb_src_factor);
- trace_dump_member(stream, uint, state, rgb_dst_factor);
+ trace_dump_member(uint, state, rgb_func);
+ trace_dump_member(uint, state, rgb_src_factor);
+ trace_dump_member(uint, state, rgb_dst_factor);
- trace_dump_member(stream, uint, state, alpha_func);
- trace_dump_member(stream, uint, state, alpha_src_factor);
- trace_dump_member(stream, uint, state, alpha_dst_factor);
+ trace_dump_member(uint, state, alpha_func);
+ trace_dump_member(uint, state, alpha_src_factor);
+ trace_dump_member(uint, state, alpha_dst_factor);
- trace_dump_member(stream, bool, state, logicop_enable);
- trace_dump_member(stream, uint, state, logicop_func);
+ trace_dump_member(bool, state, logicop_enable);
+ trace_dump_member(uint, state, logicop_func);
- trace_dump_member(stream, uint, state, colormask);
- trace_dump_member(stream, bool, state, dither);
+ trace_dump_member(uint, state, colormask);
+ trace_dump_member(bool, state, dither);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_blend_color(struct trace_stream *stream,
- const struct pipe_blend_color *state)
+void trace_dump_blend_color(const struct pipe_blend_color *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_blend_color");
+ trace_dump_struct_begin("pipe_blend_color");
- trace_dump_member_array(stream, float, state, color);
+ trace_dump_member_array(float, state, color);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_framebuffer_state(struct trace_stream *stream,
- const struct pipe_framebuffer_state *state)
+void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state)
{
- trace_dump_struct_begin(stream, "pipe_framebuffer_state");
+ trace_dump_struct_begin("pipe_framebuffer_state");
- trace_dump_member(stream, uint, state, width);
- trace_dump_member(stream, uint, state, height);
- trace_dump_member(stream, uint, state, num_cbufs);
- trace_dump_member_array(stream, ptr, state, cbufs);
- trace_dump_member(stream, ptr, state, zsbuf);
+ trace_dump_member(uint, state, width);
+ trace_dump_member(uint, state, height);
+ trace_dump_member(uint, state, num_cbufs);
+ trace_dump_member_array(ptr, state, cbufs);
+ trace_dump_member(ptr, state, zsbuf);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_sampler_state(struct trace_stream *stream,
- const struct pipe_sampler_state *state)
+void trace_dump_sampler_state(const struct pipe_sampler_state *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_sampler_state");
-
- trace_dump_member(stream, uint, state, wrap_s);
- trace_dump_member(stream, uint, state, wrap_t);
- trace_dump_member(stream, uint, state, wrap_r);
- trace_dump_member(stream, uint, state, min_img_filter);
- trace_dump_member(stream, uint, state, min_mip_filter);
- trace_dump_member(stream, uint, state, mag_img_filter);
- trace_dump_member(stream, bool, state, compare_mode);
- trace_dump_member(stream, uint, state, compare_func);
- trace_dump_member(stream, bool, state, normalized_coords);
- trace_dump_member(stream, uint, state, prefilter);
- trace_dump_member(stream, float, state, shadow_ambient);
- trace_dump_member(stream, float, state, lod_bias);
- trace_dump_member(stream, float, state, min_lod);
- trace_dump_member(stream, float, state, max_lod);
- trace_dump_member_array(stream, float, state, border_color);
- trace_dump_member(stream, float, state, max_anisotropy);
-
- trace_dump_struct_end(stream);
+ trace_dump_struct_begin("pipe_sampler_state");
+
+ trace_dump_member(uint, state, wrap_s);
+ trace_dump_member(uint, state, wrap_t);
+ trace_dump_member(uint, state, wrap_r);
+ trace_dump_member(uint, state, min_img_filter);
+ trace_dump_member(uint, state, min_mip_filter);
+ trace_dump_member(uint, state, mag_img_filter);
+ trace_dump_member(bool, state, compare_mode);
+ trace_dump_member(uint, state, compare_func);
+ trace_dump_member(bool, state, normalized_coords);
+ trace_dump_member(uint, state, prefilter);
+ trace_dump_member(float, state, shadow_ambient);
+ trace_dump_member(float, state, lod_bias);
+ trace_dump_member(float, state, min_lod);
+ trace_dump_member(float, state, max_lod);
+ trace_dump_member_array(float, state, border_color);
+ trace_dump_member(float, state, max_anisotropy);
+
+ trace_dump_struct_end();
}
-void trace_dump_surface(struct trace_stream *stream,
- const struct pipe_surface *state)
+void trace_dump_surface(const struct pipe_surface *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_surface");
+ trace_dump_struct_begin("pipe_surface");
- trace_dump_member(stream, ptr, state, buffer);
- trace_dump_member(stream, format, state, format);
- trace_dump_member(stream, uint, state, status);
- trace_dump_member(stream, uint, state, clear_value);
- trace_dump_member(stream, uint, state, width);
- trace_dump_member(stream, uint, state, height);
+ trace_dump_member(ptr, state, buffer);
+ trace_dump_member(format, state, format);
+ trace_dump_member(uint, state, status);
+ trace_dump_member(uint, state, clear_value);
+ trace_dump_member(uint, state, width);
+ trace_dump_member(uint, state, height);
- trace_dump_member_begin(stream, "block");
- trace_dump_block(stream, &state->block);
- trace_dump_member_end(stream);
+ trace_dump_member_begin("block");
+ trace_dump_block(&state->block);
+ trace_dump_member_end();
- trace_dump_member(stream, uint, state, nblocksx);
- trace_dump_member(stream, uint, state, nblocksy);
- trace_dump_member(stream, uint, state, stride);
- trace_dump_member(stream, uint, state, layout);
- trace_dump_member(stream, uint, state, offset);
- trace_dump_member(stream, uint, state, refcount);
- trace_dump_member(stream, uint, state, usage);
-
- trace_dump_member(stream, ptr, state, texture);
- trace_dump_member(stream, uint, state, face);
- trace_dump_member(stream, uint, state, level);
- trace_dump_member(stream, uint, state, zslice);
-
- trace_dump_struct_end(stream);
+ trace_dump_member(uint, state, nblocksx);
+ trace_dump_member(uint, state, nblocksy);
+ trace_dump_member(uint, state, stride);
+ trace_dump_member(uint, state, layout);
+ trace_dump_member(uint, state, offset);
+ trace_dump_member(uint, state, refcount);
+ trace_dump_member(uint, state, usage);
+
+ trace_dump_member(ptr, state, texture);
+ trace_dump_member(uint, state, face);
+ trace_dump_member(uint, state, level);
+ trace_dump_member(uint, state, zslice);
+
+ trace_dump_struct_end();
}
-void trace_dump_vertex_buffer(struct trace_stream *stream,
- const struct pipe_vertex_buffer *state)
+void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_vertex_buffer");
+ trace_dump_struct_begin("pipe_vertex_buffer");
- trace_dump_member(stream, uint, state, pitch);
- trace_dump_member(stream, uint, state, max_index);
- trace_dump_member(stream, uint, state, buffer_offset);
- trace_dump_member(stream, ptr, state, buffer);
+ trace_dump_member(uint, state, pitch);
+ trace_dump_member(uint, state, max_index);
+ trace_dump_member(uint, state, buffer_offset);
+ trace_dump_member(ptr, state, buffer);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
-void trace_dump_vertex_element(struct trace_stream *stream,
- const struct pipe_vertex_element *state)
+void trace_dump_vertex_element(const struct pipe_vertex_element *state)
{
- assert(state);
if(!state) {
- trace_dump_null(stream);
+ trace_dump_null();
return;
}
- trace_dump_struct_begin(stream, "pipe_vertex_element");
+ trace_dump_struct_begin("pipe_vertex_element");
- trace_dump_member(stream, uint, state, src_offset);
+ trace_dump_member(uint, state, src_offset);
- trace_dump_member(stream, uint, state, vertex_buffer_index);
- trace_dump_member(stream, uint, state, nr_components);
+ trace_dump_member(uint, state, vertex_buffer_index);
+ trace_dump_member(uint, state, nr_components);
- trace_dump_member(stream, format, state, src_format);
+ trace_dump_member(format, state, src_format);
- trace_dump_struct_end(stream);
+ trace_dump_struct_end();
}
diff --git a/src/gallium/drivers/trace/tr_state.h b/src/gallium/drivers/trace/tr_state.h
index c1df63db6a..5ae533dc66 100644
--- a/src/gallium/drivers/trace/tr_state.h
+++ b/src/gallium/drivers/trace/tr_state.h
@@ -4,7 +4,7 @@
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation streams (the
+ * 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
@@ -33,63 +33,44 @@
#include "pipe/p_shader_tokens.h"
-void trace_dump_format(struct trace_stream *stream,
- enum pipe_format format);
+void trace_dump_format(enum pipe_format format);
-void trace_dump_block(struct trace_stream *stream,
- const struct pipe_format_block *block);
+void trace_dump_block(const struct pipe_format_block *block);
-void trace_dump_template(struct trace_stream *stream,
- const struct pipe_texture *templat);
+void trace_dump_template(const struct pipe_texture *templat);
-void trace_dump_rasterizer_state(struct trace_stream *stream,
- const struct pipe_rasterizer_state *state);
+void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state);
-void trace_dump_poly_stipple(struct trace_stream *stream,
- const struct pipe_poly_stipple *state);
+void trace_dump_poly_stipple(const struct pipe_poly_stipple *state);
-void trace_dump_viewport_state(struct trace_stream *stream,
- const struct pipe_viewport_state *state);
+void trace_dump_viewport_state(const struct pipe_viewport_state *state);
-void trace_dump_scissor_state(struct trace_stream *stream,
- const struct pipe_scissor_state *state);
+void trace_dump_scissor_state(const struct pipe_scissor_state *state);
-void trace_dump_clip_state(struct trace_stream *stream,
- const struct pipe_clip_state *state);
+void trace_dump_clip_state(const struct pipe_clip_state *state);
-void trace_dump_constant_buffer(struct trace_stream *stream,
- const struct pipe_constant_buffer *state);
+void trace_dump_constant_buffer(const struct pipe_constant_buffer *state);
-void trace_dump_token(struct trace_stream *stream,
- const struct tgsi_token *token);
+void trace_dump_token(const struct tgsi_token *token);
-void trace_dump_shader_state(struct trace_stream *stream,
- const struct pipe_shader_state *state);
+void trace_dump_shader_state(const struct pipe_shader_state *state);
-void trace_dump_depth_stencil_alpha_state(struct trace_stream *stream,
- const struct pipe_depth_stencil_alpha_state *state);
+void trace_dump_depth_stencil_alpha_state(const struct pipe_depth_stencil_alpha_state *state);
-void trace_dump_blend_state(struct trace_stream *stream,
- const struct pipe_blend_state *state);
+void trace_dump_blend_state(const struct pipe_blend_state *state);
-void trace_dump_blend_color(struct trace_stream *stream,
- const struct pipe_blend_color *state);
+void trace_dump_blend_color(const struct pipe_blend_color *state);
-void trace_dump_framebuffer_state(struct trace_stream *stream,
- const struct pipe_framebuffer_state *state);
+void trace_dump_framebuffer_state(const struct pipe_framebuffer_state *state);
-void trace_dump_sampler_state(struct trace_stream *stream,
- const struct pipe_sampler_state *state);
+void trace_dump_sampler_state(const struct pipe_sampler_state *state);
-void trace_dump_surface(struct trace_stream *stream,
- const struct pipe_surface *state);
+void trace_dump_surface(const struct pipe_surface *state);
-void trace_dump_vertex_buffer(struct trace_stream *stream,
- const struct pipe_vertex_buffer *state);
+void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state);
-void trace_dump_vertex_element(struct trace_stream *stream,
- const struct pipe_vertex_element *state);
+void trace_dump_vertex_element(const struct pipe_vertex_element *state);
#endif /* TR_STATE_H */
diff --git a/src/gallium/drivers/trace/tr_stream.h b/src/gallium/drivers/trace/tr_stream.h
deleted file mode 100644
index d50fed2691..0000000000
--- a/src/gallium/drivers/trace/tr_stream.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/**************************************************************************
- *
- * 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 streams (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.
- *
- **************************************************************************/
-
-/**
- * @file
- * Cross-platform sequential access stream abstraction.
- */
-
-#ifndef TR_STREAM_H
-#define TR_STREAM_H
-
-
-#include "pipe/p_compiler.h"
-
-struct trace_stream;
-
-
-struct trace_stream *
-trace_stream_create(const char *name, const char *ext);
-
-boolean
-trace_stream_write(struct trace_stream *stream, const void *data, size_t size);
-
-void
-trace_stream_close(struct trace_stream *stream);
-
-
-#endif /* TR_STREAM_H */
diff --git a/src/gallium/drivers/trace/tr_texture.c b/src/gallium/drivers/trace/tr_texture.c
new file mode 100644
index 0000000000..440a78704a
--- /dev/null
+++ b/src/gallium/drivers/trace/tr_texture.c
@@ -0,0 +1,112 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#include "pipe/p_inlines.h"
+#include "util/u_hash_table.h"
+#include "util/u_memory.h"
+
+#include "tr_screen.h"
+#include "tr_texture.h"
+
+
+struct pipe_texture *
+trace_texture_create(struct trace_screen *tr_scr,
+ struct pipe_texture *texture)
+{
+ struct trace_texture *tr_tex;
+
+ if(!texture)
+ goto error;
+
+ assert(texture->screen == tr_scr->screen);
+
+ tr_tex = CALLOC_STRUCT(trace_texture);
+ if(!tr_tex)
+ goto error;
+
+ memcpy(&tr_tex->base, texture, sizeof(struct pipe_texture));
+ tr_tex->base.screen = &tr_scr->base;
+ tr_tex->texture = texture;
+
+ return &tr_tex->base;
+
+error:
+ pipe_texture_reference(&texture, NULL);
+ return NULL;
+}
+
+
+void
+trace_texture_destroy(struct trace_screen *tr_scr,
+ struct pipe_texture *texture)
+{
+ struct trace_texture *tr_tex = trace_texture(tr_scr, texture);
+ pipe_texture_reference(&tr_tex->texture, NULL);
+ FREE(tr_tex);
+}
+
+
+struct pipe_surface *
+trace_surface_create(struct trace_texture *tr_tex,
+ struct pipe_surface *surface)
+{
+ struct trace_surface *tr_surf;
+
+ if(!surface)
+ goto error;
+
+ assert(surface->texture == tr_tex->texture);
+
+ tr_surf = CALLOC_STRUCT(trace_surface);
+ if(!tr_surf)
+ goto error;
+
+ memcpy(&tr_surf->base, surface, sizeof(struct pipe_surface));
+
+ tr_surf->base.winsys = tr_tex->base.screen->winsys;
+ tr_surf->base.texture = NULL;
+ pipe_texture_reference(&tr_surf->base.texture, &tr_tex->base);
+ tr_surf->surface = surface;
+
+ return &tr_surf->base;
+
+error:
+ pipe_surface_reference(&surface, NULL);
+ return NULL;
+}
+
+
+void
+trace_surface_destroy(struct trace_texture *tr_tex,
+ struct pipe_surface *surface)
+{
+ struct trace_surface *tr_surf = trace_surface(tr_tex, surface);
+ pipe_texture_reference(&tr_surf->base.texture, NULL);
+ pipe_surface_reference(&tr_surf->surface, NULL);
+ FREE(tr_surf);
+}
+
diff --git a/src/gallium/drivers/trace/tr_stream.c b/src/gallium/drivers/trace/tr_texture.h
index 14cc257e15..9e72edb8a3 100644
--- a/src/gallium/drivers/trace/tr_stream.c
+++ b/src/gallium/drivers/trace/tr_texture.h
@@ -25,76 +25,71 @@
*
**************************************************************************/
-#include "pipe/p_config.h"
+#ifndef TR_TEXTURE_H_
+#define TR_TEXTURE_H_
-#if defined(PIPE_OS_LINUX)
-#include <stdio.h>
-#else
-#error Unsupported platform
-#endif
-#include "pipe/p_util.h"
+#include "pipe/p_compiler.h"
+#include "pipe/p_state.h"
-#include "tr_stream.h"
+#include "tr_screen.h"
-struct trace_stream
+struct trace_texture
{
-#if defined(PIPE_OS_LINUX)
- FILE *file;
-#endif
+ struct pipe_texture base;
+
+ struct pipe_texture *texture;
};
-struct trace_stream *
-trace_stream_create(const char *name, const char *ext)
+struct trace_surface
{
- struct trace_stream *stream;
- static unsigned file_no = 0;
- char filename[1024];
-
- stream = CALLOC_STRUCT(trace_stream);
- if(!stream)
- goto error1;
-
- snprintf(filename, sizeof(filename), "%s.%u.%s", name, file_no, ext);
-
-#if defined(PIPE_OS_LINUX)
- stream->file = fopen(filename, "w");
- if(!stream->file)
- goto error2;
-#endif
-
- return stream;
+ struct pipe_surface base;
+
+ struct pipe_surface *surface;
-error2:
- FREE(stream);
-error1:
- return NULL;
+ void *map;
+};
+
+
+static INLINE struct trace_texture *
+trace_texture(struct trace_screen *tr_scr,
+ struct pipe_texture *texture)
+{
+ if(!texture)
+ return NULL;
+ assert(texture->screen == &tr_scr->base);
+ return (struct trace_texture *)texture;
}
-boolean
-trace_stream_write(struct trace_stream *stream, const void *data, size_t size)
+static INLINE struct trace_surface *
+trace_surface(struct trace_texture *tr_tex,
+ struct pipe_surface *surface)
{
- if(!stream)
- return FALSE;
-
-#if defined(PIPE_OS_LINUX)
- return fwrite(data, size, 1, stream->file) == size ? TRUE : FALSE;
-#endif
+ if(!surface)
+ return NULL;
+ assert(surface->texture == &tr_tex->base);
+ return (struct trace_surface *)surface;
}
+struct pipe_texture *
+trace_texture_create(struct trace_screen *tr_scr,
+ struct pipe_texture *texture);
+
void
-trace_stream_close(struct trace_stream *stream)
-{
- if(!stream)
- return;
-
-#if defined(PIPE_OS_LINUX)
- fclose(stream->file);
-#endif
+trace_texture_destroy(struct trace_screen *tr_scr,
+ struct pipe_texture *texture);
- FREE(stream);
-}
+struct pipe_surface *
+trace_surface_create(struct trace_texture *tr_tex,
+ struct pipe_surface *surface);
+
+void
+trace_surface_destroy(struct trace_texture *tr_tex,
+ struct pipe_surface *surface);
+
+
+#endif /* TR_TEXTURE_H_ */
diff --git a/src/gallium/drivers/trace/tr_winsys.c b/src/gallium/drivers/trace/tr_winsys.c
index eec84a1981..177835854e 100644
--- a/src/gallium/drivers/trace/tr_winsys.c
+++ b/src/gallium/drivers/trace/tr_winsys.c
@@ -25,13 +25,13 @@
*
**************************************************************************/
-#include "pipe/p_util.h"
-#include "pipe/p_state.h"
+#include "util/u_memory.h"
#include "util/u_hash_table.h"
-#include "tr_stream.h"
#include "tr_dump.h"
#include "tr_state.h"
+#include "tr_screen.h"
+#include "tr_texture.h"
#include "tr_winsys.h"
@@ -51,19 +51,18 @@ static const char *
trace_winsys_get_name(struct pipe_winsys *_winsys)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
const char *result;
- trace_dump_call_begin(stream, "pipe_winsys", "get_name");
+ trace_dump_call_begin("pipe_winsys", "get_name");
- trace_dump_arg(stream, ptr, winsys);
+ trace_dump_arg(ptr, winsys);
result = winsys->get_name(winsys);
- trace_dump_ret(stream, string, result);
+ trace_dump_ret(string, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -75,18 +74,27 @@ trace_winsys_flush_frontbuffer(struct pipe_winsys *_winsys,
void *context_private)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
+
+ assert(surface);
+ if(surface->texture) {
+ struct trace_screen *tr_scr = trace_screen(surface->texture->screen);
+ struct trace_texture *tr_tex = trace_texture(tr_scr, surface->texture);
+ struct trace_surface *tr_surf = trace_surface(tr_tex, surface);
+ surface = tr_surf->surface;
+ }
- trace_dump_call_begin(stream, "pipe_winsys", "flush_frontbuffer");
+ trace_dump_call_begin("pipe_winsys", "flush_frontbuffer");
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, ptr, surface);
- trace_dump_arg(stream, ptr, context_private);
+ trace_dump_arg(ptr, winsys);
+ trace_dump_arg(ptr, surface);
+ /* XXX: hide, as there is nothing we can do with this
+ trace_dump_arg(ptr, context_private);
+ */
winsys->flush_frontbuffer(winsys, surface, context_private);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -94,20 +102,21 @@ static struct pipe_surface *
trace_winsys_surface_alloc(struct pipe_winsys *_winsys)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_surface *result;
- trace_dump_call_begin(stream, "pipe_winsys", "surface_alloc");
+ trace_dump_call_begin("pipe_winsys", "surface_alloc");
- trace_dump_arg(stream, ptr, winsys);
+ trace_dump_arg(ptr, winsys);
result = winsys->surface_alloc(winsys);
- trace_dump_ret(stream, ptr, result);
+ trace_dump_ret(ptr, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
+ assert(!result || !result->texture);
+
return result;
}
@@ -121,19 +130,20 @@ trace_winsys_surface_alloc_storage(struct pipe_winsys *_winsys,
unsigned tex_usage)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
int result;
- trace_dump_call_begin(stream, "pipe_winsys", "surface_alloc_storage");
+ assert(surface && !surface->texture);
+
+ trace_dump_call_begin("pipe_winsys", "surface_alloc_storage");
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, ptr, surface);
- trace_dump_arg(stream, uint, width);
- trace_dump_arg(stream, uint, height);
- trace_dump_arg(stream, format, format);
- trace_dump_arg(stream, uint, flags);
- trace_dump_arg(stream, uint, tex_usage);
+ trace_dump_arg(ptr, winsys);
+ trace_dump_arg(ptr, surface);
+ trace_dump_arg(uint, width);
+ trace_dump_arg(uint, height);
+ trace_dump_arg(format, format);
+ trace_dump_arg(uint, flags);
+ trace_dump_arg(uint, tex_usage);
result = winsys->surface_alloc_storage(winsys,
surface,
@@ -142,9 +152,9 @@ trace_winsys_surface_alloc_storage(struct pipe_winsys *_winsys,
flags,
tex_usage);
- trace_dump_ret(stream, int, result);
+ trace_dump_ret(int, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -155,18 +165,19 @@ trace_winsys_surface_release(struct pipe_winsys *_winsys,
struct pipe_surface **psurface)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_surface *surface = *psurface;
- trace_dump_call_begin(stream, "pipe_winsys", "surface_release");
+ assert(psurface && *psurface && !(*psurface)->texture);
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, ptr, surface);
+ trace_dump_call_begin("pipe_winsys", "surface_release");
+
+ trace_dump_arg(ptr, winsys);
+ trace_dump_arg(ptr, surface);
winsys->surface_release(winsys, psurface);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -177,22 +188,21 @@ trace_winsys_buffer_create(struct pipe_winsys *_winsys,
unsigned size)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_buffer *buffer;
- trace_dump_call_begin(stream, "pipe_winsys", "buffer_create");
+ trace_dump_call_begin("pipe_winsys", "buffer_create");
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, uint, alignment);
- trace_dump_arg(stream, uint, usage);
- trace_dump_arg(stream, uint, size);
+ trace_dump_arg(ptr, winsys);
+ trace_dump_arg(uint, alignment);
+ trace_dump_arg(uint, usage);
+ trace_dump_arg(uint, size);
buffer = winsys->buffer_create(winsys, alignment, usage, size);
- trace_dump_ret(stream, ptr, buffer);
+ trace_dump_ret(ptr, buffer);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
/* Zero the buffer to avoid dumping uninitialized memory */
if(buffer->usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
@@ -210,30 +220,71 @@ trace_winsys_buffer_create(struct pipe_winsys *_winsys,
static struct pipe_buffer *
trace_winsys_user_buffer_create(struct pipe_winsys *_winsys,
- void *ptr,
- unsigned bytes)
+ void *data,
+ unsigned size)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_buffer *result;
- trace_dump_call_begin(stream, "pipe_winsys", "user_buffer_create");
+ trace_dump_call_begin("pipe_winsys", "user_buffer_create");
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, ptr, ptr);
- trace_dump_arg(stream, uint, bytes);
+ trace_dump_arg(ptr, winsys);
+ trace_dump_arg_begin("data");
+ trace_dump_bytes(data, size);
+ trace_dump_arg_end();
+ trace_dump_arg(uint, size);
- result = winsys->user_buffer_create(winsys, ptr, bytes);
+ result = winsys->user_buffer_create(winsys, data, size);
+
+ trace_dump_ret(ptr, result);
- trace_dump_ret(stream, ptr, result);
+ trace_dump_call_end();
- trace_dump_call_end(stream);
+ /* XXX: Mark the user buffers. (we should wrap pipe_buffers, but is is
+ * impossible to do so while texture-less surfaces are still around */
+ if(result) {
+ assert(!(result->usage & TRACE_BUFFER_USAGE_USER));
+ result->usage |= TRACE_BUFFER_USAGE_USER;
+ }
return result;
}
+void
+trace_winsys_user_buffer_update(struct pipe_winsys *_winsys,
+ struct pipe_buffer *buffer)
+{
+ struct trace_winsys *tr_ws = trace_winsys(_winsys);
+ struct pipe_winsys *winsys = tr_ws->winsys;
+ const void *map;
+
+ if(buffer && buffer->usage & TRACE_BUFFER_USAGE_USER) {
+ map = winsys->buffer_map(winsys, buffer, PIPE_BUFFER_USAGE_CPU_READ);
+ if(map) {
+ trace_dump_call_begin("pipe_winsys", "buffer_write");
+
+ trace_dump_arg(ptr, winsys);
+
+ trace_dump_arg(ptr, buffer);
+
+ trace_dump_arg_begin("data");
+ trace_dump_bytes(map, buffer->size);
+ trace_dump_arg_end();
+
+ trace_dump_arg_begin("size");
+ trace_dump_uint(buffer->size);
+ trace_dump_arg_end();
+
+ trace_dump_call_end();
+
+ winsys->buffer_unmap(winsys, buffer);
+ }
+ }
+}
+
+
static void *
trace_winsys_buffer_map(struct pipe_winsys *_winsys,
struct pipe_buffer *buffer,
@@ -260,27 +311,26 @@ trace_winsys_buffer_unmap(struct pipe_winsys *_winsys,
struct pipe_buffer *buffer)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
const void *map;
map = hash_table_get(tr_ws->buffer_maps, buffer);
if(map) {
- trace_dump_call_begin(stream, "pipe_winsys", "buffer_write");
+ trace_dump_call_begin("pipe_winsys", "buffer_write");
- trace_dump_arg(stream, ptr, winsys);
+ trace_dump_arg(ptr, winsys);
- trace_dump_arg(stream, ptr, buffer);
+ trace_dump_arg(ptr, buffer);
- trace_dump_arg_begin(stream, "data");
- trace_dump_bytes(stream, map, buffer->size);
- trace_dump_arg_end(stream);
+ trace_dump_arg_begin("data");
+ trace_dump_bytes(map, buffer->size);
+ trace_dump_arg_end();
- trace_dump_arg_begin(stream, "size");
- trace_dump_uint(stream, buffer->size);
- trace_dump_arg_end(stream);
+ trace_dump_arg_begin("size");
+ trace_dump_uint(buffer->size);
+ trace_dump_arg_end();
- trace_dump_call_end(stream);
+ trace_dump_call_end();
hash_table_remove(tr_ws->buffer_maps, buffer);
}
@@ -294,17 +344,16 @@ trace_winsys_buffer_destroy(struct pipe_winsys *_winsys,
struct pipe_buffer *buffer)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
- trace_dump_call_begin(stream, "pipe_winsys", "buffer_destroy");
+ trace_dump_call_begin("pipe_winsys", "buffer_destroy");
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, ptr, buffer);
+ trace_dump_arg(ptr, winsys);
+ trace_dump_arg(ptr, buffer);
winsys->buffer_destroy(winsys, buffer);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -314,19 +363,18 @@ trace_winsys_fence_reference(struct pipe_winsys *_winsys,
struct pipe_fence_handle *src)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
struct pipe_fence_handle *dst = *pdst;
- trace_dump_call_begin(stream, "pipe_winsys", "fence_reference");
+ trace_dump_call_begin("pipe_winsys", "fence_reference");
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, ptr, dst);
- trace_dump_arg(stream, ptr, src);
+ trace_dump_arg(ptr, winsys);
+ trace_dump_arg(ptr, dst);
+ trace_dump_arg(ptr, src);
winsys->fence_reference(winsys, pdst, src);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
}
@@ -336,21 +384,20 @@ trace_winsys_fence_signalled(struct pipe_winsys *_winsys,
unsigned flag)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
int result;
- trace_dump_call_begin(stream, "pipe_winsys", "fence_signalled");
+ trace_dump_call_begin("pipe_winsys", "fence_signalled");
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, ptr, fence);
- trace_dump_arg(stream, uint, flag);
+ trace_dump_arg(ptr, winsys);
+ trace_dump_arg(ptr, fence);
+ trace_dump_arg(uint, flag);
result = winsys->fence_signalled(winsys, fence, flag);
- trace_dump_ret(stream, int, result);
+ trace_dump_ret(int, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -362,21 +409,20 @@ trace_winsys_fence_finish(struct pipe_winsys *_winsys,
unsigned flag)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
int result;
- trace_dump_call_begin(stream, "pipe_winsys", "fence_finish");
+ trace_dump_call_begin("pipe_winsys", "fence_finish");
- trace_dump_arg(stream, ptr, winsys);
- trace_dump_arg(stream, ptr, fence);
- trace_dump_arg(stream, uint, flag);
+ trace_dump_arg(ptr, winsys);
+ trace_dump_arg(ptr, fence);
+ trace_dump_arg(uint, flag);
result = winsys->fence_finish(winsys, fence, flag);
- trace_dump_ret(stream, int, result);
+ trace_dump_ret(int, result);
- trace_dump_call_end(stream);
+ trace_dump_call_end();
return result;
}
@@ -386,23 +432,20 @@ static void
trace_winsys_destroy(struct pipe_winsys *_winsys)
{
struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct trace_stream *stream = tr_ws->stream;
struct pipe_winsys *winsys = tr_ws->winsys;
- trace_dump_call_begin(stream, "pipe_winsys", "destroy");
+ trace_dump_call_begin("pipe_winsys", "destroy");
- trace_dump_arg(stream, ptr, winsys);
+ trace_dump_arg(ptr, winsys);
- winsys->destroy(winsys);
+ /*
+ winsys->destroy(winsys);
+ */
- trace_dump_call_end(stream);
-
- trace_dump_trace_end(stream);
+ trace_dump_call_end();
hash_table_destroy(tr_ws->buffer_maps);
- trace_stream_close(tr_ws->stream);
-
FREE(tr_ws);
}
@@ -410,15 +453,14 @@ trace_winsys_destroy(struct pipe_winsys *_winsys)
struct pipe_winsys *
trace_winsys_create(struct pipe_winsys *winsys)
{
- struct trace_stream *stream;
struct trace_winsys *tr_ws;
- if(!debug_get_bool_option("GALLIUM_TRACE", FALSE))
- return winsys;
+ if(!winsys)
+ goto error1;
tr_ws = CALLOC_STRUCT(trace_winsys);
if(!tr_ws)
- return NULL;
+ goto error1;
tr_ws->base.destroy = trace_winsys_destroy;
tr_ws->base.get_name = trace_winsys_get_name;
@@ -437,20 +479,19 @@ trace_winsys_create(struct pipe_winsys *winsys)
tr_ws->winsys = winsys;
- tr_ws->stream = stream = trace_stream_create("gallium", "trace");
- if(!tr_ws->stream)
- return NULL;
-
tr_ws->buffer_maps = hash_table_create(trace_buffer_hash,
trace_buffer_compare);
if(!tr_ws->buffer_maps)
- return NULL;
+ goto error2;
- trace_dump_trace_begin(tr_ws->stream, 0);
-
- trace_dump_call_begin(stream, "", "pipe_winsys_create");
- trace_dump_ret(stream, ptr, winsys);
- trace_dump_call_end(stream);
+ trace_dump_call_begin("", "pipe_winsys_create");
+ trace_dump_ret(ptr, winsys);
+ trace_dump_call_end();
return &tr_ws->base;
+
+error2:
+ FREE(tr_ws);
+error1:
+ return winsys;
}
diff --git a/src/gallium/drivers/trace/tr_winsys.h b/src/gallium/drivers/trace/tr_winsys.h
index a3576da867..062ddf66a0 100644
--- a/src/gallium/drivers/trace/tr_winsys.h
+++ b/src/gallium/drivers/trace/tr_winsys.h
@@ -34,8 +34,15 @@
#include "pipe/p_winsys.h"
+/**
+ * It often happens that new data is written directly to the user buffers
+ * without mapping/unmapping. This flag marks user buffers, so that their
+ * contents can be dumpped before being used by the pipe context.
+ */
+#define TRACE_BUFFER_USAGE_USER (1 << 31)
+
+
struct hash_table;
-struct trace_stream;
struct trace_winsys
@@ -44,8 +51,6 @@ struct trace_winsys
struct pipe_winsys *winsys;
- struct trace_stream *stream;
-
struct hash_table *buffer_maps;
};
@@ -63,4 +68,9 @@ struct pipe_winsys *
trace_winsys_create(struct pipe_winsys *winsys);
+void
+trace_winsys_user_buffer_update(struct pipe_winsys *winsys,
+ struct pipe_buffer *buffer);
+
+
#endif /* TR_WINSYS_H_ */