summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorBen Skeggs <[email protected]>2008-05-05 19:44:16 +1000
committerBen Skeggs <[email protected]>2008-05-05 19:44:16 +1000
commit33d9e213ee47aab32f662caf3e7c07c2697befbe (patch)
tree20fd91d378d396e8e2ace51ee23722d98f212fcc /src/gallium
parent1e6191e0af2653aa69bd623e25d2e157662e560f (diff)
parent736f535b4f1c5e6912b5b2fe9415a3b44a678844 (diff)
Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/README.portability65
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_cache.c40
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_cache.h28
-rw-r--r--src/gallium/auxiliary/cso_cache/cso_context.c128
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_aaline.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_pipe_pstipple.c4
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_varray.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_pt_vcache.c1
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_sse.c24
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_x86sse.c61
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_x86sse.h14
-rw-r--r--src/gallium/auxiliary/sct/sct.c1
-rw-r--r--src/gallium/auxiliary/tgsi/exec/tgsi_exec.c65
-rw-r--r--src/gallium/auxiliary/tgsi/exec/tgsi_exec.h10
-rwxr-xr-xsrc/gallium/auxiliary/tgsi/exec/tgsi_sse2.c259
-rw-r--r--src/gallium/auxiliary/tgsi/util/tgsi_dump.c25
-rw-r--r--src/gallium/auxiliary/tgsi/util/tgsi_parse.c4
-rw-r--r--src/gallium/auxiliary/tgsi/util/tgsi_parse.h4
-rw-r--r--src/gallium/auxiliary/tgsi/util/tgsi_scan.c15
-rw-r--r--src/gallium/auxiliary/translate/translate_sse.c2
-rw-r--r--src/gallium/auxiliary/util/p_debug.c4
-rw-r--r--src/gallium/auxiliary/util/p_debug_mem.c7
-rw-r--r--src/gallium/auxiliary/util/p_tile.c24
-rw-r--r--src/gallium/auxiliary/util/u_blit.c2
-rw-r--r--src/gallium/auxiliary/util/u_gen_mipmap.c31
-rw-r--r--src/gallium/auxiliary/util/u_time.c6
-rw-r--r--src/gallium/drivers/i915simple/i915_debug_fp.c3
-rw-r--r--src/gallium/drivers/i915simple/i915_screen.c9
-rw-r--r--src/gallium/drivers/i915simple/i915_state_sampler.c8
-rw-r--r--src/gallium/drivers/i965simple/brw_screen.c24
-rw-r--r--src/gallium/drivers/i965simple/brw_wm_surface_state.c8
-rw-r--r--src/gallium/drivers/softpipe/sp_context.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_context.h2
-rw-r--r--src/gallium/drivers/softpipe/sp_prim_setup.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_quad_stencil.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_state_fs.c3
-rw-r--r--src/gallium/drivers/softpipe/sp_tex_sample.c14
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.c14
-rw-r--r--src/gallium/drivers/softpipe/sp_winsys.h2
-rw-r--r--src/gallium/include/pipe/p_config.h9
-rw-r--r--src/gallium/include/pipe/p_defines.h4
-rw-r--r--src/gallium/include/pipe/p_format.h19
-rw-r--r--src/gallium/include/pipe/p_inlines.h50
-rw-r--r--src/gallium/include/pipe/p_util.h64
-rw-r--r--src/gallium/winsys/xlib/xm_winsys.c331
45 files changed, 845 insertions, 556 deletions
diff --git a/src/gallium/README.portability b/src/gallium/README.portability
index ab0c1978476..18a97f449b4 100644
--- a/src/gallium/README.portability
+++ b/src/gallium/README.portability
@@ -24,6 +24,7 @@ headers in general, should stricly follow these guidelines to ensure
* Don't use variable number of macro arguments. Use static inline functions
instead.
+* Don't use C99 features.
= Standard Library =
@@ -42,3 +43,67 @@ portable way.
* Use the functions/macros in p_debug.h.
* Don't include assert.h, call abort, printf, etc.
+
+
+= Code Style =
+
+== Inherantice in C ==
+
+The main thing we do is mimic inheritance by structure containment.
+
+Here's a silly made-up example:
+
+/* base class */
+struct buffer
+{
+ int size;
+ void (*validate)(struct buffer *buf);
+};
+
+/* sub-class of bufffer */
+struct texture_buffer
+{
+ struct buffer base; /* the base class, MUST COME FIRST! */
+ int format;
+ int width, height;
+};
+
+
+Then, we'll typically have cast-wrapper functions to convert base-class
+pointers to sub-class pointers where needed:
+
+static inline struct vertex_buffer *vertex_buffer(struct buffer *buf)
+{
+ return (struct vertex_buffer *) buf;
+}
+
+
+To create/init a sub-classed object:
+
+struct buffer *create_texture_buffer(int w, int h, int format)
+{
+ struct texture_buffer *t = malloc(sizeof(*t));
+ t->format = format;
+ t->width = w;
+ t->height = h;
+ t->base.size = w * h;
+ t->base.validate = tex_validate;
+ return &t->base;
+}
+
+Example sub-class method:
+
+void tex_validate(struct buffer *buf)
+{
+ struct texture_buffer *tb = texture_buffer(buf);
+ assert(tb->format);
+ assert(tb->width);
+ assert(tb->height);
+}
+
+
+Note that we typically do not use typedefs to make "class names"; we use
+'struct whatever' everywhere.
+
+Gallium's pipe_context and the subclassed psb_context, etc are prime examples
+of this. There's also many examples in Mesa and the Mesa state tracker.
diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.c b/src/gallium/auxiliary/cso_cache/cso_cache.c
index 096875807be..36dc46ff809 100644
--- a/src/gallium/auxiliary/cso_cache/cso_cache.c
+++ b/src/gallium/auxiliary/cso_cache/cso_cache.c
@@ -43,6 +43,9 @@ struct cso_cache {
struct cso_hash *rasterizer_hash;
struct cso_hash *sampler_hash;
int max_size;
+
+ cso_sanitize_callback sanitize_cb;
+ void *sanitize_data;
};
#if 1
@@ -205,9 +208,20 @@ static INLINE void delete_cso(void *state, enum cso_cache_type type)
}
}
-static INLINE void sanitize_hash(struct cso_hash *hash, enum cso_cache_type type,
+
+static INLINE void sanitize_hash(struct cso_cache *sc,
+ struct cso_hash *hash,
+ enum cso_cache_type type,
int max_size)
{
+ if (sc->sanitize_cb)
+ sc->sanitize_cb(hash, type, max_size, sc->sanitize_data);
+}
+
+
+static INLINE void sanitize_cb(struct cso_hash *hash, enum cso_cache_type type,
+ int max_size, void *user_data)
+{
/* if we're approach the maximum size, remove fourth of the entries
* otherwise every subsequent call will go through the same */
int hash_size = cso_hash_size(hash);
@@ -231,7 +245,7 @@ cso_insert_state(struct cso_cache *sc,
void *state)
{
struct cso_hash *hash = _cso_hash_for_type(sc, type);
- sanitize_hash(hash, type, sc->max_size);
+ sanitize_hash(sc, hash, type, sc->max_size);
return cso_hash_insert(hash, hash_key, state);
}
@@ -300,6 +314,8 @@ struct cso_cache *cso_cache_create(void)
sc->rasterizer_hash = cso_hash_create();
sc->fs_hash = cso_hash_create();
sc->vs_hash = cso_hash_create();
+ sc->sanitize_cb = sanitize_cb;
+ sc->sanitize_data = 0;
return sc;
}
@@ -365,13 +381,13 @@ void cso_set_maximum_cache_size(struct cso_cache *sc, int number)
{
sc->max_size = number;
- sanitize_hash(sc->blend_hash, CSO_BLEND, sc->max_size);
- sanitize_hash(sc->depth_stencil_hash, CSO_DEPTH_STENCIL_ALPHA,
+ sanitize_hash(sc, sc->blend_hash, CSO_BLEND, sc->max_size);
+ sanitize_hash(sc, sc->depth_stencil_hash, CSO_DEPTH_STENCIL_ALPHA,
sc->max_size);
- sanitize_hash(sc->fs_hash, CSO_FRAGMENT_SHADER, sc->max_size);
- sanitize_hash(sc->vs_hash, CSO_VERTEX_SHADER, sc->max_size);
- sanitize_hash(sc->rasterizer_hash, CSO_RASTERIZER, sc->max_size);
- sanitize_hash(sc->sampler_hash, CSO_SAMPLER, sc->max_size);
+ sanitize_hash(sc, sc->fs_hash, CSO_FRAGMENT_SHADER, sc->max_size);
+ sanitize_hash(sc, sc->vs_hash, CSO_VERTEX_SHADER, sc->max_size);
+ sanitize_hash(sc, sc->rasterizer_hash, CSO_RASTERIZER, sc->max_size);
+ sanitize_hash(sc, sc->sampler_hash, CSO_SAMPLER, sc->max_size);
}
int cso_maximum_cache_size(const struct cso_cache *sc)
@@ -379,3 +395,11 @@ int cso_maximum_cache_size(const struct cso_cache *sc)
return sc->max_size;
}
+void cso_cache_set_sanitize_callback(struct cso_cache *sc,
+ cso_sanitize_callback cb,
+ void *user_data)
+{
+ sc->sanitize_cb = cb;
+ sc->sanitize_data = user_data;
+}
+
diff --git a/src/gallium/auxiliary/cso_cache/cso_cache.h b/src/gallium/auxiliary/cso_cache/cso_cache.h
index e5edbbb5566..6b5c230e8f2 100644
--- a/src/gallium/auxiliary/cso_cache/cso_cache.h
+++ b/src/gallium/auxiliary/cso_cache/cso_cache.h
@@ -84,8 +84,22 @@
extern "C" {
#endif
+enum cso_cache_type {
+ CSO_BLEND,
+ CSO_SAMPLER,
+ CSO_DEPTH_STENCIL_ALPHA,
+ CSO_RASTERIZER,
+ CSO_FRAGMENT_SHADER,
+ CSO_VERTEX_SHADER
+};
+
typedef void (*cso_state_callback)(void *ctx, void *obj);
+typedef void (*cso_sanitize_callback)(struct cso_hash *hash,
+ enum cso_cache_type type,
+ int max_size,
+ void *user_data);
+
struct cso_cache;
struct cso_blend {
@@ -130,21 +144,15 @@ struct cso_sampler {
struct pipe_context *context;
};
-
-enum cso_cache_type {
- CSO_BLEND,
- CSO_SAMPLER,
- CSO_DEPTH_STENCIL_ALPHA,
- CSO_RASTERIZER,
- CSO_FRAGMENT_SHADER,
- CSO_VERTEX_SHADER
-};
-
unsigned cso_construct_key(void *item, int item_size);
struct cso_cache *cso_cache_create(void);
void cso_cache_delete(struct cso_cache *sc);
+void cso_cache_set_sanitize_callback(struct cso_cache *sc,
+ cso_sanitize_callback cb,
+ void *user_data);
+
struct cso_hash_iter cso_insert_state(struct cso_cache *sc,
unsigned hash_key, enum cso_cache_type type,
void *state);
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c
index b4609e999bb..eef898f4865 100644
--- a/src/gallium/auxiliary/cso_cache/cso_context.c
+++ b/src/gallium/auxiliary/cso_cache/cso_context.c
@@ -80,6 +80,131 @@ struct cso_context {
};
+static boolean delete_blend_state(struct cso_context *ctx, void *state)
+{
+ struct cso_blend *cso = (struct cso_blend *)state;
+
+ if (ctx->blend == state)
+ return FALSE;
+
+ if (cso->delete_state)
+ cso->delete_state(cso->context, cso->data);
+ FREE(state);
+ return TRUE;
+}
+
+static boolean delete_depth_stencil_state(struct cso_context *ctx, void *state)
+{
+ struct cso_depth_stencil_alpha *cso = (struct cso_depth_stencil_alpha *)state;
+
+ if (ctx->depth_stencil == cso->data)
+ return FALSE;
+
+ if (cso->delete_state)
+ cso->delete_state(cso->context, cso->data);
+ FREE(state);
+
+ return TRUE;
+}
+
+static boolean delete_sampler_state(struct cso_context *ctx, void *state)
+{
+ struct cso_sampler *cso = (struct cso_sampler *)state;
+ if (cso->delete_state)
+ cso->delete_state(cso->context, cso->data);
+ FREE(state);
+ return TRUE;
+}
+
+static boolean delete_rasterizer_state(struct cso_context *ctx, void *state)
+{
+ struct cso_rasterizer *cso = (struct cso_rasterizer *)state;
+
+ if (ctx->rasterizer == cso->data)
+ return FALSE;
+ if (cso->delete_state)
+ cso->delete_state(cso->context, cso->data);
+ FREE(state);
+ return TRUE;
+}
+
+static boolean delete_fs_state(struct cso_context *ctx, void *state)
+{
+ struct cso_fragment_shader *cso = (struct cso_fragment_shader *)state;
+ if (ctx->fragment_shader == cso->data)
+ return FALSE;
+ if (cso->delete_state)
+ cso->delete_state(cso->context, cso->data);
+ FREE(state);
+ return TRUE;
+}
+
+static boolean delete_vs_state(struct cso_context *ctx, void *state)
+{
+ struct cso_vertex_shader *cso = (struct cso_vertex_shader *)state;
+ if (ctx->vertex_shader == cso->data)
+ return TRUE;
+ if (cso->delete_state)
+ cso->delete_state(cso->context, cso->data);
+ FREE(state);
+ return FALSE;
+}
+
+
+static INLINE boolean delete_cso(struct cso_context *ctx,
+ void *state, enum cso_cache_type type)
+{
+ switch (type) {
+ case CSO_BLEND:
+ return delete_blend_state(ctx, state);
+ break;
+ case CSO_SAMPLER:
+ return delete_sampler_state(ctx, state);
+ break;
+ case CSO_DEPTH_STENCIL_ALPHA:
+ return delete_depth_stencil_state(ctx, state);
+ break;
+ case CSO_RASTERIZER:
+ return delete_rasterizer_state(ctx, state);
+ break;
+ case CSO_FRAGMENT_SHADER:
+ return delete_fs_state(ctx, state);
+ break;
+ case CSO_VERTEX_SHADER:
+ return delete_vs_state(ctx, state);
+ break;
+ default:
+ assert(0);
+ FREE(state);
+ }
+ return FALSE;
+}
+
+static INLINE void sanitize_hash(struct cso_hash *hash, enum cso_cache_type type,
+ int max_size, void *user_data)
+{
+ struct cso_context *ctx = (struct cso_context *)user_data;
+ /* if we're approach the maximum size, remove fourth of the entries
+ * otherwise every subsequent call will go through the same */
+ int hash_size = cso_hash_size(hash);
+ int max_entries = (max_size > hash_size) ? max_size : hash_size;
+ int to_remove = (max_size < max_entries) * max_entries/4;
+ struct cso_hash_iter iter = cso_hash_first_node(hash);
+ if (hash_size > max_size)
+ to_remove += hash_size - max_size;
+ while (to_remove) {
+ /*remove elements until we're good */
+ /*fixme: currently we pick the nodes to remove at random*/
+ void *cso = cso_hash_iter_data(iter);
+ if (delete_cso(ctx, cso, type)) {
+ iter = cso_hash_erase(hash, iter);
+ --to_remove;
+ } else
+ iter = cso_hash_iter_next(iter);
+ }
+}
+
+
struct cso_context *cso_create_context( struct pipe_context *pipe )
{
struct cso_context *ctx = CALLOC_STRUCT(cso_context);
@@ -89,6 +214,9 @@ struct cso_context *cso_create_context( struct pipe_context *pipe )
ctx->cache = cso_cache_create();
if (ctx->cache == NULL)
goto out;
+ cso_cache_set_sanitize_callback(ctx->cache,
+ sanitize_hash,
+ ctx);
ctx->pipe = pipe;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index f05641dee66..f501b2aed41 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -392,7 +392,7 @@ aaline_create_texture(struct aaline_stage *aaline)
memset(&texTemp, 0, sizeof(texTemp));
texTemp.target = PIPE_TEXTURE_2D;
- texTemp.format = PIPE_FORMAT_U_A8; /* XXX verify supported by driver! */
+ texTemp.format = PIPE_FORMAT_A8_UNORM; /* XXX verify supported by driver! */
texTemp.last_level = MAX_TEXTURE_LEVEL;
texTemp.width[0] = 1 << MAX_TEXTURE_LEVEL;
texTemp.height[0] = 1 << MAX_TEXTURE_LEVEL;
diff --git a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
index d1d63d73bea..73ee4198580 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
@@ -256,7 +256,7 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
uint size = 4;
immed = tgsi_default_full_immediate();
immed.Immediate.Size = 1 + size; /* one for the token itself */
- immed.u.ImmediateFloat32 = (struct tgsi_immediate_float32 *) value;
+ immed.u.Pointer = (void *) value;
ctx->emit_immediate(ctx, &immed);
}
@@ -417,7 +417,7 @@ pstip_create_texture(struct pstip_stage *pstip)
memset(&texTemp, 0, sizeof(texTemp));
texTemp.target = PIPE_TEXTURE_2D;
- texTemp.format = PIPE_FORMAT_U_A8; /* XXX verify supported by driver! */
+ texTemp.format = PIPE_FORMAT_A8_UNORM; /* XXX verify supported by driver! */
texTemp.last_level = 0;
texTemp.width[0] = 32;
texTemp.height[0] = 32;
diff --git a/src/gallium/auxiliary/draw/draw_pt_varray.c b/src/gallium/auxiliary/draw/draw_pt_varray.c
index c85d8ded50c..355093f945e 100644
--- a/src/gallium/auxiliary/draw/draw_pt_varray.c
+++ b/src/gallium/auxiliary/draw/draw_pt_varray.c
@@ -200,7 +200,6 @@ static void varray_prepare(struct draw_pt_front_end *frontend,
unsigned opt)
{
struct varray_frontend *varray = (struct varray_frontend *)frontend;
- const struct pipe_rasterizer_state *rasterizer = varray->draw->rasterizer;
if (opt & PT_PIPELINE)
{
diff --git a/src/gallium/auxiliary/draw/draw_pt_vcache.c b/src/gallium/auxiliary/draw/draw_pt_vcache.c
index 2f9775814f5..6b3fb1406ba 100644
--- a/src/gallium/auxiliary/draw/draw_pt_vcache.c
+++ b/src/gallium/auxiliary/draw/draw_pt_vcache.c
@@ -225,7 +225,6 @@ static void vcache_prepare( struct draw_pt_front_end *frontend,
unsigned opt )
{
struct vcache_frontend *vcache = (struct vcache_frontend *)frontend;
- const struct pipe_rasterizer_state *rasterizer = vcache->draw->rasterizer;
if (opt & PT_PIPELINE)
{
diff --git a/src/gallium/auxiliary/draw/draw_vs_sse.c b/src/gallium/auxiliary/draw/draw_vs_sse.c
index 90926aec850..a57c938fbf1 100644
--- a/src/gallium/auxiliary/draw/draw_vs_sse.c
+++ b/src/gallium/auxiliary/draw/draw_vs_sse.c
@@ -47,21 +47,21 @@
#include "tgsi/util/tgsi_parse.h"
#define SSE_MAX_VERTICES 4
-#define SSE_SWIZZLES 0
+#define SSE_SWIZZLES 1
#if SSE_SWIZZLES
typedef void (XSTDCALL *codegen_function) (
- const struct tgsi_exec_vector *input,
- struct tgsi_exec_vector *output,
- float (*constant)[4],
- struct tgsi_exec_vector *temporary,
- float (*immediates)[4],
- const float (*aos_input)[4],
- uint num_inputs,
- uint input_stride,
- float (*aos_output)[4],
- uint num_outputs,
- uint output_stride );
+ const struct tgsi_exec_vector *input, /* 1 */
+ struct tgsi_exec_vector *output, /* 2 */
+ float (*constant)[4], /* 3 */
+ struct tgsi_exec_vector *temporary, /* 4 */
+ float (*immediates)[4], /* 5 */
+ const float (*aos_input)[4], /* 6 */
+ uint num_inputs, /* 7 */
+ uint input_stride, /* 8 */
+ float (*aos_output)[4], /* 9 */
+ uint num_outputs, /* 10 */
+ uint output_stride ); /* 11 */
#else
typedef void (XSTDCALL *codegen_function) (
const struct tgsi_exec_vector *input,
diff --git a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
index d7e22305573..4e036d9032c 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
@@ -347,9 +347,9 @@ struct x86_reg x86_get_base_reg( struct x86_reg reg )
return x86_make_reg( reg.file, reg.idx );
}
-unsigned char *x86_get_label( struct x86_function *p )
+int x86_get_label( struct x86_function *p )
{
- return p->csr;
+ return p->csr - p->store;
}
@@ -361,17 +361,22 @@ unsigned char *x86_get_label( struct x86_function *p )
void x86_jcc( struct x86_function *p,
enum x86_cc cc,
- unsigned char *label )
+ int label )
{
- intptr_t offset = pointer_to_intptr( label ) - (pointer_to_intptr( x86_get_label(p) ) + 2);
+ int offset = label - (x86_get_label(p) + 2);
DUMP_I(cc);
+ if (offset < 0) {
+ int amt = p->csr - p->store;
+ assert(amt > -offset);
+ }
+
if (offset <= 127 && offset >= -128) {
emit_1ub(p, 0x70 + cc);
emit_1b(p, (char) offset);
}
else {
- offset = pointer_to_intptr( label ) - (pointer_to_intptr( x86_get_label(p) ) + 6);
+ offset = label - (x86_get_label(p) + 6);
emit_2ub(p, 0x0f, 0x80 + cc);
emit_1i(p, offset);
}
@@ -379,8 +384,8 @@ void x86_jcc( struct x86_function *p,
/* Always use a 32bit offset for forward jumps:
*/
-unsigned char *x86_jcc_forward( struct x86_function *p,
- enum x86_cc cc )
+int x86_jcc_forward( struct x86_function *p,
+ enum x86_cc cc )
{
DUMP_I(cc);
emit_2ub(p, 0x0f, 0x80 + cc);
@@ -388,7 +393,7 @@ unsigned char *x86_jcc_forward( struct x86_function *p,
return x86_get_label(p);
}
-unsigned char *x86_jmp_forward( struct x86_function *p)
+int x86_jmp_forward( struct x86_function *p)
{
DUMP();
emit_1ub(p, 0xe9);
@@ -396,7 +401,7 @@ unsigned char *x86_jmp_forward( struct x86_function *p)
return x86_get_label(p);
}
-unsigned char *x86_call_forward( struct x86_function *p)
+int x86_call_forward( struct x86_function *p)
{
DUMP();
@@ -408,42 +413,24 @@ unsigned char *x86_call_forward( struct x86_function *p)
/* Fixup offset from forward jump:
*/
void x86_fixup_fwd_jump( struct x86_function *p,
- unsigned char *fixup )
+ int fixup )
{
- *(int *)(fixup - 4) = pointer_to_intptr( x86_get_label(p) ) - pointer_to_intptr( fixup );
+ *(int *)(p->store + fixup - 4) = x86_get_label(p) - fixup;
}
-void x86_jmp( struct x86_function *p, unsigned char *label)
+void x86_jmp( struct x86_function *p, int label)
{
DUMP_I( label );
emit_1ub(p, 0xe9);
- emit_1i(p, pointer_to_intptr( label ) - pointer_to_intptr( x86_get_label(p) ) - 4);
-}
-
-#if 0
-static unsigned char *cptr( void (*label)() )
-{
- return (unsigned char *) label;
+ emit_1i(p, label - x86_get_label(p) - 4);
}
-/* This doesn't work once we start reallocating & copying the
- * generated code on buffer fills, because the call is relative to the
- * current pc.
- */
-void x86_call( struct x86_function *p, void (*label)())
-{
- DUMP_I( label );
- emit_1ub(p, 0xe8);
- emit_1i(p, cptr(label) - x86_get_label(p) - 4);
-}
-#else
void x86_call( struct x86_function *p, struct x86_reg reg)
{
DUMP_R( reg );
emit_1ub(p, 0xff);
emit_modrm_noreg(p, 2, reg);
}
-#endif
/* michal:
@@ -462,8 +449,15 @@ void x86_push( struct x86_function *p,
struct x86_reg reg )
{
DUMP_R( reg );
- assert(reg.mod == mod_REG);
- emit_1ub(p, 0x50 + reg.idx);
+ if (reg.mod == mod_REG)
+ emit_1ub(p, 0x50 + reg.idx);
+ else
+ {
+ emit_1ub(p, 0xff);
+ emit_modrm_noreg(p, 6, reg);
+ }
+
+
p->stack_offset += 4;
}
@@ -495,6 +489,7 @@ void x86_dec( struct x86_function *p,
void x86_ret( struct x86_function *p )
{
DUMP();
+ assert(p->stack_offset == 0);
emit_1ub(p, 0xc3);
}
diff --git a/src/gallium/auxiliary/rtasm/rtasm_x86sse.h b/src/gallium/auxiliary/rtasm/rtasm_x86sse.h
index ad79b1facf8..eacaeeaf6fe 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_x86sse.h
+++ b/src/gallium/auxiliary/rtasm/rtasm_x86sse.h
@@ -124,23 +124,23 @@ struct x86_reg x86_get_base_reg( struct x86_reg reg );
/* Labels, jumps and fixup:
*/
-unsigned char *x86_get_label( struct x86_function *p );
+int x86_get_label( struct x86_function *p );
void x86_jcc( struct x86_function *p,
enum x86_cc cc,
- unsigned char *label );
+ int label );
-unsigned char *x86_jcc_forward( struct x86_function *p,
+int x86_jcc_forward( struct x86_function *p,
enum x86_cc cc );
-unsigned char *x86_jmp_forward( struct x86_function *p);
+int x86_jmp_forward( struct x86_function *p);
-unsigned char *x86_call_forward( struct x86_function *p);
+int x86_call_forward( struct x86_function *p);
void x86_fixup_fwd_jump( struct x86_function *p,
- unsigned char *fixup );
+ int fixup );
-void x86_jmp( struct x86_function *p, unsigned char *label );
+void x86_jmp( struct x86_function *p, int label );
/* void x86_call( struct x86_function *p, void (*label)() ); */
void x86_call( struct x86_function *p, struct x86_reg reg);
diff --git a/src/gallium/auxiliary/sct/sct.c b/src/gallium/auxiliary/sct/sct.c
index 97ee5882a16..5e4126e014d 100644
--- a/src/gallium/auxiliary/sct/sct.c
+++ b/src/gallium/auxiliary/sct/sct.c
@@ -209,6 +209,7 @@ remove_context_from_surface(struct sct_surface *si,
}
else {
prev = curr;
+ next = curr->next;
}
}
}
diff --git a/src/gallium/auxiliary/tgsi/exec/tgsi_exec.c b/src/gallium/auxiliary/tgsi/exec/tgsi_exec.c
index d55f907c0d3..826b432f09e 100644
--- a/src/gallium/auxiliary/tgsi/exec/tgsi_exec.c
+++ b/src/gallium/auxiliary/tgsi/exec/tgsi_exec.c
@@ -88,6 +88,10 @@
#define TEMP_OUTPUT_C TGSI_EXEC_TEMP_OUTPUT_C
#define TEMP_PRIMITIVE_I TGSI_EXEC_TEMP_PRIMITIVE_I
#define TEMP_PRIMITIVE_C TGSI_EXEC_TEMP_PRIMITIVE_C
+#define TEMP_3_I TGSI_EXEC_TEMP_THREE_I
+#define TEMP_3_C TGSI_EXEC_TEMP_THREE_C
+#define TEMP_HALF_I TGSI_EXEC_TEMP_HALF_I
+#define TEMP_HALF_C TGSI_EXEC_TEMP_HALF_C
#define TEMP_R0 TGSI_EXEC_TEMP_R0
#define FOR_EACH_CHANNEL(CHAN)\
@@ -262,6 +266,8 @@ tgsi_exec_machine_init(
mach->Temps[TEMP_2_I].xyzw[TEMP_2_C].f[i] = 2.0f;
mach->Temps[TEMP_128_I].xyzw[TEMP_128_C].f[i] = 128.0f;
mach->Temps[TEMP_M128_I].xyzw[TEMP_M128_C].f[i] = -128.0f;
+ mach->Temps[TEMP_3_I].xyzw[TEMP_3_C].f[i] = 3.0f;
+ mach->Temps[TEMP_HALF_I].xyzw[TEMP_HALF_C].f[i] = 0.5f;
}
}
@@ -1530,41 +1536,44 @@ exec_instruction(
break;
case TGSI_OPCODE_EXP:
- debug_printf("TGSI: EXP opcode not implemented\n");
- /* from ARB_v_p:
- tmp = ScalarLoad(op0);
- result.x = 2^floor(tmp);
- result.y = tmp - floor(tmp);
- result.z = RoughApprox2ToX(tmp);
- result.w = 1.0;
- */
-#if 0
- /* something like this: */
FETCH( &r[0], 0, CHAN_X );
- micro_exp2( &r[0], &r[0] );
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
+ micro_flr( &r[1], &r[0] ); /* r1 = floor(r0) */
+ if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
+ micro_exp2( &r[2], &r[1] ); /* r2 = 2 ^ r1 */
+ STORE( &r[2], 0, CHAN_X ); /* store r2 */
+ }
+ if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
+ micro_sub( &r[2], &r[0], &r[1] ); /* r2 = r0 - r1 */
+ STORE( &r[2], 0, CHAN_Y ); /* store r2 */
+ }
+ if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
+ micro_exp2( &r[2], &r[0] ); /* r2 = 2 ^ r0 */
+ STORE( &r[2], 0, CHAN_Z ); /* store r2 */
+ }
+ if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
+ STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
}
-#endif
break;
case TGSI_OPCODE_LOG:
- debug_printf("TGSI: LOG opcode not implemented\n");
- /* from ARB_v_p:
- tmp = fabs(ScalarLoad(op0));
- result.x = floor(log2(tmp));
- result.y = tmp / 2^(floor(log2(tmp)));
- result.z = RoughApproxLog2(tmp);
- result.w = 1.0;
- */
-#if 0
- /* something like this: */
FETCH( &r[0], 0, CHAN_X );
- micro_lg2( &r[0], &r[0] );
- FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( &r[0], 0, chan_index );
+ micro_abs( &r[2], &r[0] ); /* r2 = abs(r0) */
+ micro_lg2( &r[1], &r[2] ); /* r1 = lg2(r2) */
+ micro_flr( &r[0], &r[1] ); /* r0 = floor(r1) */
+ if (IS_CHANNEL_ENABLED( *inst, CHAN_X )) {
+ STORE( &r[0], 0, CHAN_X );
+ }
+ if (IS_CHANNEL_ENABLED( *inst, CHAN_Y )) {
+ micro_exp2( &r[0], &r[0] ); /* r0 = 2 ^ r0 */
+ micro_div( &r[0], &r[2], &r[0] ); /* r0 = r2 / r0 */
+ STORE( &r[0], 0, CHAN_Y );
+ }
+ if (IS_CHANNEL_ENABLED( *inst, CHAN_Z )) {
+ STORE( &r[1], 0, CHAN_Z );
+ }
+ if (IS_CHANNEL_ENABLED( *inst, CHAN_W )) {
+ STORE( &mach->Temps[TEMP_1_I].xyzw[TEMP_1_C], 0, CHAN_W );
}
-#endif
break;
case TGSI_OPCODE_MUL:
diff --git a/src/gallium/auxiliary/tgsi/exec/tgsi_exec.h b/src/gallium/auxiliary/tgsi/exec/tgsi_exec.h
index 92e2e5e9859..19bd78df3d3 100644
--- a/src/gallium/auxiliary/tgsi/exec/tgsi_exec.h
+++ b/src/gallium/auxiliary/tgsi/exec/tgsi_exec.h
@@ -133,9 +133,15 @@ struct tgsi_exec_labels
#define TGSI_EXEC_TEMP_PRIMITIVE_I 34
#define TGSI_EXEC_TEMP_PRIMITIVE_C 2
-#define TGSI_EXEC_TEMP_R0 35
+#define TGSI_EXEC_TEMP_THREE_I 34
+#define TGSI_EXEC_TEMP_THREE_C 3
-#define TGSI_EXEC_NUM_TEMPS (32 + 4)
+#define TGSI_EXEC_TEMP_HALF_I 35
+#define TGSI_EXEC_TEMP_HALF_C 0
+
+#define TGSI_EXEC_TEMP_R0 36
+
+#define TGSI_EXEC_NUM_TEMPS (32 + 5)
#define TGSI_EXEC_NUM_ADDRS 1
#define TGSI_EXEC_NUM_IMMEDIATES 256
diff --git a/src/gallium/auxiliary/tgsi/exec/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/exec/tgsi_sse2.c
index 1138f599972..8018bd7fa45 100755
--- a/src/gallium/auxiliary/tgsi/exec/tgsi_sse2.c
+++ b/src/gallium/auxiliary/tgsi/exec/tgsi_sse2.c
@@ -36,7 +36,11 @@
#ifdef PIPE_ARCH_X86
-#define HIGH_PRECISION 1 /* for 1/sqrt() */
+/* for 1/sqrt()
+ *
+ * This costs about 100fps (close to 10%) in gears:
+ */
+#define HIGH_PRECISION 1
#define FOR_EACH_CHANNEL( CHAN )\
@@ -103,15 +107,9 @@ get_output_base( void )
static struct x86_reg
get_temp_base( void )
{
-#ifdef WIN32
return x86_make_reg(
file_REG32,
reg_BX );
-#else
- return x86_make_reg(
- file_REG32,
- reg_SI );
-#endif
}
static struct x86_reg
@@ -133,14 +131,6 @@ get_immediate_base( void )
* Data access helpers.
*/
-static struct x86_reg
-get_argument(
- unsigned index )
-{
- return x86_make_disp(
- x86_make_reg( file_REG32, reg_SP ),
- (index + 1) * 4 );
-}
static struct x86_reg
get_immediate(
@@ -455,19 +445,13 @@ emit_push_gp(
{
x86_push(
func,
- get_const_base() );
- x86_push(
- func,
- get_input_base() );
+ x86_make_reg( file_REG32, reg_AX) );
x86_push(
func,
- get_output_base() );
-
- /* It is important on non-win32 platforms that temp base is pushed last.
- */
+ x86_make_reg( file_REG32, reg_CX) );
x86_push(
func,
- get_temp_base() );
+ x86_make_reg( file_REG32, reg_DX) );
}
static void
@@ -478,16 +462,13 @@ x86_pop_gp(
*/
x86_pop(
func,
- get_temp_base() );
+ x86_make_reg( file_REG32, reg_DX) );
x86_pop(
func,
- get_output_base() );
+ x86_make_reg( file_REG32, reg_CX) );
x86_pop(
func,
- get_input_base() );
- x86_pop(
- func,
- get_const_base() );
+ x86_make_reg( file_REG32, reg_AX) );
}
static void
@@ -504,19 +485,23 @@ emit_func_call_dst(
emit_push_gp(
func );
-#ifdef WIN32
- x86_push(
- func,
- get_temp( TEMP_R0, 0 ) );
-#endif
-
{
struct x86_reg ecx = x86_make_reg( file_REG32, reg_CX );
+ x86_lea(
+ func,
+ ecx,
+ get_temp( TEMP_R0, 0 ) );
+
+ x86_push( func, ecx );
x86_mov_reg_imm( func, ecx, (unsigned long) code );
x86_call( func, ecx );
+#ifndef WIN32
+ x86_pop(func, ecx );
+#endif
}
+
x86_pop_gp(
func );
@@ -577,11 +562,7 @@ static void XSTDCALL
cos4f(
float *store )
{
-#ifdef WIN32
const unsigned X = 0;
-#else
- const unsigned X = TEMP_R0 * 16;
-#endif
store[X + 0] = cosf( store[X + 0] );
store[X + 1] = cosf( store[X + 1] );
@@ -604,11 +585,8 @@ static void XSTDCALL
ex24f(
float *store )
{
-#ifdef WIN32
const unsigned X = 0;
-#else
- const unsigned X = TEMP_R0 * 16;
-#endif
+
store[X + 0] = powf( 2.0f, store[X + 0] );
store[X + 1] = powf( 2.0f, store[X + 1] );
store[X + 2] = powf( 2.0f, store[X + 2] );
@@ -641,11 +619,8 @@ static void XSTDCALL
flr4f(
float *store )
{
-#ifdef WIN32
const unsigned X = 0;
-#else
- const unsigned X = TEMP_R0 * 16;
-#endif
+
store[X + 0] = floorf( store[X + 0] );
store[X + 1] = floorf( store[X + 1] );
store[X + 2] = floorf( store[X + 2] );
@@ -667,11 +642,8 @@ static void XSTDCALL
frc4f(
float *store )
{
-#ifdef WIN32
const unsigned X = 0;
-#else
- const unsigned X = TEMP_R0 * 16;
-#endif
+
store[X + 0] -= floorf( store[X + 0] );
store[X + 1] -= floorf( store[X + 1] );
store[X + 2] -= floorf( store[X + 2] );
@@ -693,11 +665,8 @@ static void XSTDCALL
lg24f(
float *store )
{
-#ifdef WIN32
const unsigned X = 0;
-#else
- const unsigned X = TEMP_R0 * 16;
-#endif
+
store[X + 0] = LOG2( store[X + 0] );
store[X + 1] = LOG2( store[X + 1] );
store[X + 2] = LOG2( store[X + 2] );
@@ -755,11 +724,8 @@ static void XSTDCALL
pow4f(
float *store )
{
-#ifdef WIN32
const unsigned X = 0;
-#else
- const unsigned X = TEMP_R0 * 16;
-#endif
+
store[X + 0] = powf( store[X + 0], store[X + 4] );
store[X + 1] = powf( store[X + 1], store[X + 5] );
store[X + 2] = powf( store[X + 2], store[X + 6] );
@@ -795,23 +761,6 @@ emit_rcp (
make_xmm( xmm_src ) );
}
-#if HIGH_PRECISION
-static void XSTDCALL
-rsqrt4f(
- float *store )
-{
-#ifdef WIN32
- const unsigned X = 0;
-#else
- const unsigned X = TEMP_R0 * 16;
-#endif
- store[X + 0] = 1.0F / sqrtf( store[X + 0] );
- store[X + 1] = 1.0F / sqrtf( store[X + 1] );
- store[X + 2] = 1.0F / sqrtf( store[X + 2] );
- store[X + 3] = 1.0F / sqrtf( store[X + 3] );
-}
-#endif
-
static void
emit_rsqrt(
struct x86_function *func,
@@ -819,13 +768,6 @@ emit_rsqrt(
unsigned xmm_src )
{
#if HIGH_PRECISION
-#if 1
- emit_func_call_dst_src(
- func,
- xmm_dst,
- xmm_src,
- rsqrt4f );
-#else
/* Although rsqrtps() and rcpps() are low precision on some/all SSE
* implementations, it is possible to improve its precision at
* fairly low cost, using a newton/raphson step, as below:
@@ -835,21 +777,25 @@ emit_rsqrt(
*
* See: http://softwarecommunity.intel.com/articles/eng/1818.htm
*/
- /* This is some code that woudl do the above for a scalar 'a'. We
- * obviously are interested in a vector version:
- *
- * movss xmm3, a;
- * movss xmm1, half;
- * movss xmm2, three;
- * rsqrtss xmm0, xmm3;
- * mulss xmm3, xmm0;
- * mulss xmm1, xmm0;
- * mulss xmm3, xmm0;
- * subss xmm2, xmm3;
- * mulss xmm1, xmm2;
- * movss x, xmm1;
- */
-#endif
+ {
+ struct x86_reg dst = make_xmm( xmm_dst );
+ struct x86_reg src = make_xmm( xmm_src );
+ struct x86_reg tmp0 = make_xmm( 2 );
+ struct x86_reg tmp1 = make_xmm( 3 );
+
+ assert( xmm_dst != xmm_src );
+ assert( xmm_dst != 2 && xmm_dst != 3 );
+ assert( xmm_src != 2 && xmm_src != 3 );
+
+ sse_movaps( func, dst, get_temp( TGSI_EXEC_TEMP_HALF_I, TGSI_EXEC_TEMP_HALF_C ) );
+ sse_movaps( func, tmp0, get_temp( TGSI_EXEC_TEMP_THREE_I, TGSI_EXEC_TEMP_THREE_C ) );
+ sse_rsqrtps( func, tmp1, src );
+ sse_mulps( func, src, tmp1 );
+ sse_mulps( func, dst, tmp1 );
+ sse_mulps( func, src, tmp1 );
+ sse_subps( func, tmp0, src );
+ sse_mulps( func, dst, tmp0 );
+ }
#else
/* On Intel CPUs at least, this is only accurate to 12 bits -- not
* good enough.
@@ -878,11 +824,8 @@ static void XSTDCALL
sin4f(
float *store )
{
-#ifdef WIN32
const unsigned X = 0;
-#else
- const unsigned X = TEMP_R0 * 16;
-#endif
+
store[X + 0] = sinf( store[X + 0] );
store[X + 1] = sinf( store[X + 1] );
store[X + 2] = sinf( store[X + 2] );
@@ -1234,11 +1177,16 @@ emit_instruction(
switch( inst->Instruction.Opcode ) {
case TGSI_OPCODE_ARL:
+#if 0
+ /* XXX this isn't working properly (see glean vertProg1 test) */
FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
FETCH( func, *inst, 0, 0, chan_index );
emit_f2it( func, 0 );
STORE( func, *inst, 0, 0, chan_index );
}
+#else
+ return 0;
+#endif
break;
case TGSI_OPCODE_MOV:
@@ -1334,9 +1282,9 @@ emit_instruction(
case TGSI_OPCODE_RSQ:
/* TGSI_OPCODE_RECIPSQRT */
FETCH( func, *inst, 0, 0, CHAN_X );
- emit_rsqrt( func, 0, 0 );
+ emit_rsqrt( func, 1, 0 );
FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
- STORE( func, *inst, 0, 0, chan_index );
+ STORE( func, *inst, 1, 0, chan_index );
}
break;
@@ -2029,40 +1977,40 @@ emit_declaration(
}
}
-static void aos_to_soa( struct x86_function *func, uint aos, uint soa, uint num, uint stride )
+static void aos_to_soa( struct x86_function *func,
+ uint arg_aos,
+ uint arg_soa,
+ uint arg_num,
+ uint arg_stride )
{
- struct x86_reg soa_input;
- struct x86_reg aos_input;
- struct x86_reg num_inputs;
- struct x86_reg temp;
- unsigned char *inner_loop;
+ struct x86_reg soa_input = x86_make_reg( file_REG32, reg_AX );
+ struct x86_reg aos_input = x86_make_reg( file_REG32, reg_BX );
+ struct x86_reg num_inputs = x86_make_reg( file_REG32, reg_CX );
+ struct x86_reg stride = x86_make_reg( file_REG32, reg_DX );
+ int inner_loop;
- soa_input = x86_make_reg( file_REG32, reg_AX );
- aos_input = x86_make_reg( file_REG32, reg_BX );
- num_inputs = x86_make_reg( file_REG32, reg_CX );
- temp = x86_make_reg( file_REG32, reg_DX );
/* Save EBX */
x86_push( func, x86_make_reg( file_REG32, reg_BX ) );
- x86_mov( func, soa_input, get_argument( soa + 1 ) );
- x86_mov( func, aos_input, get_argument( aos + 1 ) );
- x86_mov( func, num_inputs, get_argument( num + 1 ) );
+ x86_mov( func, aos_input, x86_fn_arg( func, arg_aos ) );
+ x86_mov( func, soa_input, x86_fn_arg( func, arg_soa ) );
+ x86_mov( func, num_inputs, x86_fn_arg( func, arg_num ) );
+ x86_mov( func, stride, x86_fn_arg( func, arg_stride ) );
/* do */
inner_loop = x86_get_label( func );
{
- x86_mov( func, temp, get_argument( stride + 1 ) );
x86_push( func, aos_input );
sse_movlps( func, make_xmm( 0 ), x86_make_disp( aos_input, 0 ) );
sse_movlps( func, make_xmm( 3 ), x86_make_disp( aos_input, 8 ) );
- x86_add( func, aos_input, temp );
+ x86_add( func, aos_input, stride );
sse_movhps( func, make_xmm( 0 ), x86_make_disp( aos_input, 0 ) );
sse_movhps( func, make_xmm( 3 ), x86_make_disp( aos_input, 8 ) );
- x86_add( func, aos_input, temp );
+ x86_add( func, aos_input, stride );
sse_movlps( func, make_xmm( 1 ), x86_make_disp( aos_input, 0 ) );
sse_movlps( func, make_xmm( 4 ), x86_make_disp( aos_input, 8 ) );
- x86_add( func, aos_input, temp );
+ x86_add( func, aos_input, stride );
sse_movhps( func, make_xmm( 1 ), x86_make_disp( aos_input, 0 ) );
sse_movhps( func, make_xmm( 4 ), x86_make_disp( aos_input, 8 ) );
x86_pop( func, aos_input );
@@ -2088,7 +2036,7 @@ static void aos_to_soa( struct x86_function *func, uint aos, uint soa, uint num,
x86_jcc( func, cc_NE, inner_loop );
/* Restore EBX */
- x86_pop( func, x86_make_reg( file_REG32, reg_BX ) );
+ x86_pop( func, aos_input );
}
static void soa_to_aos( struct x86_function *func, uint aos, uint soa, uint num, uint stride )
@@ -2097,7 +2045,7 @@ static void soa_to_aos( struct x86_function *func, uint aos, uint soa, uint num,
struct x86_reg aos_output;
struct x86_reg num_outputs;
struct x86_reg temp;
- unsigned char *inner_loop;
+ int inner_loop;
soa_output = x86_make_reg( file_REG32, reg_AX );
aos_output = x86_make_reg( file_REG32, reg_BX );
@@ -2105,11 +2053,11 @@ static void soa_to_aos( struct x86_function *func, uint aos, uint soa, uint num,
temp = x86_make_reg( file_REG32, reg_DX );
/* Save EBX */
- x86_push( func, x86_make_reg( file_REG32, reg_BX ) );
+ x86_push( func, aos_output );
- x86_mov( func, soa_output, get_argument( soa + 1 ) );
- x86_mov( func, aos_output, get_argument( aos + 1 ) );
- x86_mov( func, num_outputs, get_argument( num + 1 ) );
+ x86_mov( func, soa_output, x86_fn_arg( func, soa ) );
+ x86_mov( func, aos_output, x86_fn_arg( func, aos ) );
+ x86_mov( func, num_outputs, x86_fn_arg( func, num ) );
/* do */
inner_loop = x86_get_label( func );
@@ -2126,7 +2074,7 @@ static void soa_to_aos( struct x86_function *func, uint aos, uint soa, uint num,
sse_unpcklps( func, make_xmm( 3 ), make_xmm( 4 ) );
sse_unpckhps( func, make_xmm( 5 ), make_xmm( 4 ) );
- x86_mov( func, temp, get_argument( stride + 1 ) );
+ x86_mov( func, temp, x86_fn_arg( func, stride ) );
x86_push( func, aos_output );
sse_movlps( func, x86_make_disp( aos_output, 0 ), make_xmm( 0 ) );
sse_movlps( func, x86_make_disp( aos_output, 8 ), make_xmm( 3 ) );
@@ -2150,7 +2098,7 @@ static void soa_to_aos( struct x86_function *func, uint aos, uint soa, uint num,
x86_jcc( func, cc_NE, inner_loop );
/* Restore EBX */
- x86_pop( func, x86_make_reg( file_REG32, reg_BX ) );
+ x86_pop( func, aos_output );
}
/**
@@ -2185,6 +2133,17 @@ tgsi_emit_sse2(
tgsi_parse_init( &parse, tokens );
+ /* Can't just use EDI, EBX without save/restoring them:
+ */
+ x86_push(
+ func,
+ get_immediate_base() );
+
+ x86_push(
+ func,
+ get_temp_base() );
+
+
/*
* Different function args for vertex/fragment shaders:
*/
@@ -2193,51 +2152,55 @@ tgsi_emit_sse2(
x86_mov(
func,
get_input_base(),
- get_argument( 0 ) );
+ x86_fn_arg( func, 1 ) );
/* skipping outputs argument here */
x86_mov(
func,
get_const_base(),
- get_argument( 2 ) );
+ x86_fn_arg( func, 3 ) );
x86_mov(
func,
get_temp_base(),
- get_argument( 3 ) );
+ x86_fn_arg( func, 4 ) );
x86_mov(
func,
get_coef_base(),
- get_argument( 4 ) );
+ x86_fn_arg( func, 5 ) );
x86_mov(
func,
get_immediate_base(),
- get_argument( 5 ) );
+ x86_fn_arg( func, 6 ) );
}
else {
assert(parse.FullHeader.Processor.Processor == TGSI_PROCESSOR_VERTEX);
if (do_swizzles)
- aos_to_soa( func, 5, 0, 6, 7 );
+ aos_to_soa( func,
+ 6, /* aos_input */
+ 1, /* machine->input */
+ 7, /* num_inputs */
+ 8 ); /* input_stride */
x86_mov(
func,
get_input_base(),
- get_argument( 0 ) );
+ x86_fn_arg( func, 1 ) );
x86_mov(
func,
get_output_base(),
- get_argument( 1 ) );
+ x86_fn_arg( func, 2 ) );
x86_mov(
func,
get_const_base(),
- get_argument( 2 ) );
+ x86_fn_arg( func, 3 ) );
x86_mov(
func,
get_temp_base(),
- get_argument( 3 ) );
+ x86_fn_arg( func, 4 ) );
x86_mov(
func,
get_immediate_base(),
- get_argument( 4 ) );
+ x86_fn_arg( func, 5 ) );
}
while( !tgsi_parse_end_of_tokens( &parse ) && ok ) {
@@ -2260,7 +2223,7 @@ tgsi_emit_sse2(
x86_mov(
func,
get_output_base(),
- get_argument( 1 ) );
+ x86_fn_arg( func, 2 ) );
}
}
@@ -2307,9 +2270,19 @@ tgsi_emit_sse2(
if (parse.FullHeader.Processor.Processor == TGSI_PROCESSOR_VERTEX) {
if (do_swizzles)
- soa_to_aos( func, 8, 1, 9, 10 );
+ soa_to_aos( func, 9, 2, 10, 11 );
}
+ /* Can't just use EBX, EDI without save/restoring them:
+ */
+ x86_pop(
+ func,
+ get_temp_base() );
+
+ x86_pop(
+ func,
+ get_immediate_base() );
+
#ifdef WIN32
emit_retw( func, 16 );
#else
diff --git a/src/gallium/auxiliary/tgsi/util/tgsi_dump.c b/src/gallium/auxiliary/tgsi/util/tgsi_dump.c
index 26bfc2051f2..4c65ffd7807 100644
--- a/src/gallium/auxiliary/tgsi/util/tgsi_dump.c
+++ b/src/gallium/auxiliary/tgsi/util/tgsi_dump.c
@@ -767,6 +767,31 @@ dump_instruction_short(
SID( dst->DstRegister.Index );
CHR( ']' );
+ switch (dst->DstRegisterExtModulate.Modulate) {
+ case TGSI_MODULATE_1X:
+ break;
+ case TGSI_MODULATE_2X:
+ TXT( "_2X" );
+ break;
+ case TGSI_MODULATE_4X:
+ TXT( "_4X" );
+ break;
+ case TGSI_MODULATE_8X:
+ TXT( "_8X" );
+ break;
+ case TGSI_MODULATE_HALF:
+ TXT( "_D2" );
+ break;
+ case TGSI_MODULATE_QUARTER:
+ TXT( "_D4" );
+ break;
+ case TGSI_MODULATE_EIGHTH:
+ TXT( "_D8" );
+ break;
+ default:
+ assert( 0 );
+ }
+
if( dst->DstRegister.WriteMask != TGSI_WRITEMASK_XYZW ) {
CHR( '.' );
if( dst->DstRegister.WriteMask & TGSI_WRITEMASK_X ) {
diff --git a/src/gallium/auxiliary/tgsi/util/tgsi_parse.c b/src/gallium/auxiliary/tgsi/util/tgsi_parse.c
index c3526cb71ff..5bea7738401 100644
--- a/src/gallium/auxiliary/tgsi/util/tgsi_parse.c
+++ b/src/gallium/auxiliary/tgsi/util/tgsi_parse.c
@@ -43,7 +43,7 @@ tgsi_full_token_free(
union tgsi_full_token *full_token )
{
if( full_token->Token.Type == TGSI_TOKEN_TYPE_IMMEDIATE ) {
- FREE( full_token->FullImmediate.u.Pointer );
+ FREE( (void *) full_token->FullImmediate.u.Pointer );
}
}
@@ -156,7 +156,7 @@ tgsi_parse_token(
imm->u.Pointer = MALLOC(
sizeof( struct tgsi_immediate_float32 ) * (imm->Immediate.Size - 1) );
for( i = 0; i < imm->Immediate.Size - 1; i++ ) {
- next_token( ctx, &imm->u.ImmediateFloat32[i] );
+ next_token( ctx, (struct tgsi_immediate_float32 *) &imm->u.ImmediateFloat32[i] );
}
break;
diff --git a/src/gallium/auxiliary/tgsi/util/tgsi_parse.h b/src/gallium/auxiliary/tgsi/util/tgsi_parse.h
index da0121c482e..15e76feb7ca 100644
--- a/src/gallium/auxiliary/tgsi/util/tgsi_parse.h
+++ b/src/gallium/auxiliary/tgsi/util/tgsi_parse.h
@@ -52,8 +52,8 @@ struct tgsi_full_immediate
struct tgsi_immediate Immediate;
union
{
- void *Pointer;
- struct tgsi_immediate_float32 *ImmediateFloat32;
+ const void *Pointer;
+ const struct tgsi_immediate_float32 *ImmediateFloat32;
} u;
};
diff --git a/src/gallium/auxiliary/tgsi/util/tgsi_scan.c b/src/gallium/auxiliary/tgsi/util/tgsi_scan.c
index ea4a72967d6..65650ed22a4 100644
--- a/src/gallium/auxiliary/tgsi/util/tgsi_scan.c
+++ b/src/gallium/auxiliary/tgsi/util/tgsi_scan.c
@@ -103,18 +103,14 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
info->file_max[file] = MAX2(info->file_max[file], (int)i);
if (file == TGSI_FILE_INPUT) {
- info->input_semantic_name[info->num_inputs]
- = (ubyte)fulldecl->Semantic.SemanticName;
- info->input_semantic_index[info->num_inputs]
- = (ubyte)fulldecl->Semantic.SemanticIndex;
+ info->input_semantic_name[i] = (ubyte)fulldecl->Semantic.SemanticName;
+ info->input_semantic_index[i] = (ubyte)fulldecl->Semantic.SemanticIndex;
info->num_inputs++;
}
if (file == TGSI_FILE_OUTPUT) {
- info->output_semantic_name[info->num_outputs]
- = (ubyte)fulldecl->Semantic.SemanticName;
- info->output_semantic_index[info->num_outputs]
- = (ubyte)fulldecl->Semantic.SemanticIndex;
+ info->output_semantic_name[i] = (ubyte)fulldecl->Semantic.SemanticName;
+ info->output_semantic_index[i] = (ubyte)fulldecl->Semantic.SemanticIndex;
info->num_outputs++;
}
@@ -137,6 +133,9 @@ tgsi_scan_shader(const struct tgsi_token *tokens,
}
}
+ assert( info->file_max[TGSI_FILE_INPUT] + 1 == info->num_inputs );
+ assert( info->file_max[TGSI_FILE_OUTPUT] + 1 == info->num_outputs );
+
info->uses_kill = (info->opcode_count[TGSI_OPCODE_KIL] ||
info->opcode_count[TGSI_OPCODE_KILP]);
diff --git a/src/gallium/auxiliary/translate/translate_sse.c b/src/gallium/auxiliary/translate/translate_sse.c
index f590d48b787..a54ac5a82ff 100644
--- a/src/gallium/auxiliary/translate/translate_sse.c
+++ b/src/gallium/auxiliary/translate/translate_sse.c
@@ -404,7 +404,7 @@ static boolean build_vertex_emit( struct translate_sse *p,
struct x86_reg srcEAX = x86_make_reg(file_REG32, reg_CX);
struct x86_reg countEBP = x86_make_reg(file_REG32, reg_BP);
struct x86_reg translateESI = x86_make_reg(file_REG32, reg_SI);
- uint8_t *fixup, *label;
+ int fixup, label;
unsigned j;
p->func = func;
diff --git a/src/gallium/auxiliary/util/p_debug.c b/src/gallium/auxiliary/util/p_debug.c
index 8ef28801913..4ec17466624 100644
--- a/src/gallium/auxiliary/util/p_debug.c
+++ b/src/gallium/auxiliary/util/p_debug.c
@@ -104,7 +104,7 @@ void _debug_break(void)
__asm("int3");
#elif (defined(__i386__) || defined(__386__)) && defined(__MSC__)
_asm {int 3};
-#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && !defined(WINCE)
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
EngDebugBreak();
#else
abort();
@@ -413,6 +413,7 @@ char *pf_sprint_name( char *str, enum pipe_format format )
}
+#ifdef DEBUG
void debug_print_format(const char *msg, unsigned fmt )
{
char fmtstr[80];
@@ -421,3 +422,4 @@ void debug_print_format(const char *msg, unsigned fmt )
debug_printf("%s: %s\n", msg, fmtstr);
}
+#endif
diff --git a/src/gallium/auxiliary/util/p_debug_mem.c b/src/gallium/auxiliary/util/p_debug_mem.c
index 9321cf71bbb..3b5e4fbaeea 100644
--- a/src/gallium/auxiliary/util/p_debug_mem.c
+++ b/src/gallium/auxiliary/util/p_debug_mem.c
@@ -34,9 +34,11 @@
#include "pipe/p_config.h"
-#ifdef PIPE_SUBSYSTEM_WINDOWS_DISPLAY
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
#include <windows.h>
#include <winddi.h>
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+#include <wdm.h>
#else
#include <stdio.h>
#include <stdlib.h>
@@ -52,6 +54,9 @@
#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && !defined(WINCE)
#define real_malloc(_size) EngAllocMem(0, _size, 'D3AG')
#define real_free(_ptr) EngFreeMem(_ptr)
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+#define real_malloc(_size) ExAllocatePool(0, _size)
+#define real_free(_ptr) ExFreePool(_ptr)
#else
#define real_malloc(_size) malloc(_size)
#define real_free(_ptr) free(_ptr)
diff --git a/src/gallium/auxiliary/util/p_tile.c b/src/gallium/auxiliary/util/p_tile.c
index 13175ca46e6..63e1cc6013a 100644
--- a/src/gallium/auxiliary/util/p_tile.c
+++ b/src/gallium/auxiliary/util/p_tile.c
@@ -385,7 +385,7 @@ z16_get_tile_rgba(ushort *src,
-/*** PIPE_FORMAT_U_L8 ***/
+/*** PIPE_FORMAT_L8_UNORM ***/
static void
l8_get_tile_rgba(ubyte *src,
@@ -408,7 +408,7 @@ l8_get_tile_rgba(ubyte *src,
}
-/*** PIPE_FORMAT_U_A8 ***/
+/*** PIPE_FORMAT_A8_UNORM ***/
static void
a8_get_tile_rgba(ubyte *src,
@@ -476,7 +476,7 @@ r16g16b16a16_put_tile_rgba(short *dst,
-/*** PIPE_FORMAT_U_I8 ***/
+/*** PIPE_FORMAT_I8_UNORM ***/
static void
i8_get_tile_rgba(ubyte *src,
@@ -499,7 +499,7 @@ i8_get_tile_rgba(ubyte *src,
}
-/*** PIPE_FORMAT_U_A8_L8 ***/
+/*** PIPE_FORMAT_A8L8_UNORM ***/
static void
a8_l8_get_tile_rgba(ushort *src,
@@ -708,16 +708,16 @@ pipe_get_tile_rgba(struct pipe_context *pipe,
case PIPE_FORMAT_R5G6B5_UNORM:
r5g6b5_get_tile_rgba((ushort *) packed, w, h, p, dst_stride);
break;
- case PIPE_FORMAT_U_L8:
+ case PIPE_FORMAT_L8_UNORM:
l8_get_tile_rgba((ubyte *) packed, w, h, p, dst_stride);
break;
- case PIPE_FORMAT_U_A8:
+ case PIPE_FORMAT_A8_UNORM:
a8_get_tile_rgba((ubyte *) packed, w, h, p, dst_stride);
break;
- case PIPE_FORMAT_U_I8:
+ case PIPE_FORMAT_I8_UNORM:
i8_get_tile_rgba((ubyte *) packed, w, h, p, dst_stride);
break;
- case PIPE_FORMAT_U_A8_L8:
+ case PIPE_FORMAT_A8L8_UNORM:
a8_l8_get_tile_rgba((ushort *) packed, w, h, p, dst_stride);
break;
case PIPE_FORMAT_R16G16B16A16_SNORM:
@@ -787,16 +787,16 @@ pipe_put_tile_rgba(struct pipe_context *pipe,
break;
case PIPE_FORMAT_R8G8B8A8_UNORM:
break;
- case PIPE_FORMAT_U_L8:
+ case PIPE_FORMAT_L8_UNORM:
/*l8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride);*/
break;
- case PIPE_FORMAT_U_A8:
+ case PIPE_FORMAT_A8_UNORM:
/*a8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride);*/
break;
- case PIPE_FORMAT_U_I8:
+ case PIPE_FORMAT_I8_UNORM:
/*i8_put_tile_rgba((ubyte *) packed, w, h, p, src_stride);*/
break;
- case PIPE_FORMAT_U_A8_L8:
+ case PIPE_FORMAT_A8L8_UNORM:
/*a8_l8_put_tile_rgba((ushort *) packed, w, h, p, src_stride);*/
break;
case PIPE_FORMAT_R16G16B16A16_SNORM:
diff --git a/src/gallium/auxiliary/util/u_blit.c b/src/gallium/auxiliary/util/u_blit.c
index 9e9912c6e46..568d62ced19 100644
--- a/src/gallium/auxiliary/util/u_blit.c
+++ b/src/gallium/auxiliary/util/u_blit.c
@@ -295,6 +295,8 @@ util_blit_pixels(struct blit_state *ctx,
src, srcLeft, srcTop, /* src */
srcW, srcH); /* size */
+ pipe->texture_update(pipe, tex, 0, 1 << 0);
+
/* save state (restored below) */
cso_save_blend(ctx->cso);
cso_save_depth_stencil_alpha(ctx->cso);
diff --git a/src/gallium/auxiliary/util/u_gen_mipmap.c b/src/gallium/auxiliary/util/u_gen_mipmap.c
index b8dc6c66c01..c53c5122681 100644
--- a/src/gallium/auxiliary/util/u_gen_mipmap.c
+++ b/src/gallium/auxiliary/util/u_gen_mipmap.c
@@ -493,18 +493,21 @@ format_to_type_comps(enum pipe_format pformat,
*datatype = USHORT_5_6_5;
*comps = 3;
return;
- case PIPE_FORMAT_U_L8:
- case PIPE_FORMAT_U_A8:
- case PIPE_FORMAT_U_I8:
+ case PIPE_FORMAT_L8_UNORM:
+ case PIPE_FORMAT_A8_UNORM:
+ case PIPE_FORMAT_I8_UNORM:
*datatype = UBYTE;
*comps = 1;
return;
- case PIPE_FORMAT_U_A8_L8:
+ case PIPE_FORMAT_A8L8_UNORM:
*datatype = UBYTE;
*comps = 2;
return;
default:
assert(0);
+ *datatype = UBYTE;
+ *comps = 0;
+ break;
}
}
@@ -775,23 +778,23 @@ set_vertex_data(struct gen_mipmap_state *ctx, float width, float height)
{
void *buf;
- ctx->vertices[0][0][0] = -0.5f; /*x*/
- ctx->vertices[0][0][1] = -0.5f; /*y*/
+ ctx->vertices[0][0][0] = 0.0f; /*x*/
+ ctx->vertices[0][0][1] = 0.0f; /*y*/
ctx->vertices[0][1][0] = 0.0f; /*s*/
ctx->vertices[0][1][1] = 0.0f; /*t*/
- ctx->vertices[1][0][0] = width - 0.5f; /*x*/
- ctx->vertices[1][0][1] = -0.5f; /*y*/
- ctx->vertices[1][1][0] = 1.0f; /*s*/
- ctx->vertices[1][1][1] = 0.0f; /*t*/
+ ctx->vertices[1][0][0] = width;
+ ctx->vertices[1][0][1] = 0.0f;
+ ctx->vertices[1][1][0] = 1.0f;
+ ctx->vertices[1][1][1] = 0.0f;
- ctx->vertices[2][0][0] = width - 0.5f;
- ctx->vertices[2][0][1] = height - 0.5f;
+ ctx->vertices[2][0][0] = width;
+ ctx->vertices[2][0][1] = height;
ctx->vertices[2][1][0] = 1.0f;
ctx->vertices[2][1][1] = 1.0f;
- ctx->vertices[3][0][0] = -0.5f;
- ctx->vertices[3][0][1] = height - 0.5f;
+ ctx->vertices[3][0][0] = 0.0f;
+ ctx->vertices[3][0][1] = height;
ctx->vertices[3][1][0] = 0.0f;
ctx->vertices[3][1][1] = 1.0f;
diff --git a/src/gallium/auxiliary/util/u_time.c b/src/gallium/auxiliary/util/u_time.c
index dd28ff41340..9b97050d51a 100644
--- a/src/gallium/auxiliary/util/u_time.c
+++ b/src/gallium/auxiliary/util/u_time.c
@@ -37,11 +37,11 @@
#if defined(PIPE_OS_LINUX)
#include <sys/time.h>
-#elif defined(PIPE_OS_WINDOWS)
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
#include <windows.h>
-#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
#include <winddi.h>
-#endif
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_USER)
+#include <windows.h>
#else
#error Unsupported OS
#endif
diff --git a/src/gallium/drivers/i915simple/i915_debug_fp.c b/src/gallium/drivers/i915simple/i915_debug_fp.c
index 37a3508fe14..c024a051a58 100644
--- a/src/gallium/drivers/i915simple/i915_debug_fp.c
+++ b/src/gallium/drivers/i915simple/i915_debug_fp.c
@@ -333,12 +333,11 @@ void
i915_disassemble_program(struct debug_stream *stream,
const unsigned * program, unsigned sz)
{
- unsigned size = program[0] & 0x1ff;
unsigned i;
PRINTF(stream, "\t\tBEGIN\n");
- assert(size + 2 == sz);
+ assert((program[0] & 0x1ff) + 2 == sz);
program++;
for (i = 1; i < sz; i += 3, program += 3) {
diff --git a/src/gallium/drivers/i915simple/i915_screen.c b/src/gallium/drivers/i915simple/i915_screen.c
index 9ae594ce54c..646cfd921d1 100644
--- a/src/gallium/drivers/i915simple/i915_screen.c
+++ b/src/gallium/drivers/i915simple/i915_screen.c
@@ -154,10 +154,10 @@ i915_is_format_supported( struct pipe_screen *screen,
PIPE_FORMAT_R8G8B8A8_UNORM,
PIPE_FORMAT_A8R8G8B8_UNORM,
PIPE_FORMAT_R5G6B5_UNORM,
- PIPE_FORMAT_U_L8,
- PIPE_FORMAT_U_A8,
- PIPE_FORMAT_U_I8,
- PIPE_FORMAT_U_A8_L8,
+ PIPE_FORMAT_L8_UNORM,
+ PIPE_FORMAT_A8_UNORM,
+ PIPE_FORMAT_I8_UNORM,
+ PIPE_FORMAT_A8L8_UNORM,
PIPE_FORMAT_YCBCR,
PIPE_FORMAT_YCBCR_REV,
PIPE_FORMAT_S8Z24_UNORM,
@@ -182,6 +182,7 @@ i915_is_format_supported( struct pipe_screen *screen,
break;
default:
assert(0);
+ return FALSE;
}
for (i = 0; list[i] != PIPE_FORMAT_NONE; i++) {
diff --git a/src/gallium/drivers/i915simple/i915_state_sampler.c b/src/gallium/drivers/i915simple/i915_state_sampler.c
index 84f6529a3ad..982eec4a1b0 100644
--- a/src/gallium/drivers/i915simple/i915_state_sampler.c
+++ b/src/gallium/drivers/i915simple/i915_state_sampler.c
@@ -131,13 +131,13 @@ static uint
translate_texture_format(enum pipe_format pipeFormat)
{
switch (pipeFormat) {
- case PIPE_FORMAT_U_L8:
+ case PIPE_FORMAT_L8_UNORM:
return MAPSURF_8BIT | MT_8BIT_L8;
- case PIPE_FORMAT_U_I8:
+ case PIPE_FORMAT_I8_UNORM:
return MAPSURF_8BIT | MT_8BIT_I8;
- case PIPE_FORMAT_U_A8:
+ case PIPE_FORMAT_A8_UNORM:
return MAPSURF_8BIT | MT_8BIT_A8;
- case PIPE_FORMAT_U_A8_L8:
+ case PIPE_FORMAT_A8L8_UNORM:
return MAPSURF_16BIT | MT_16BIT_AY88;
case PIPE_FORMAT_R5G6B5_UNORM:
return MAPSURF_16BIT | MT_16BIT_RGB565;
diff --git a/src/gallium/drivers/i965simple/brw_screen.c b/src/gallium/drivers/i965simple/brw_screen.c
index 6845c7abde2..b700f7e4f5d 100644
--- a/src/gallium/drivers/i965simple/brw_screen.c
+++ b/src/gallium/drivers/i965simple/brw_screen.c
@@ -141,13 +141,13 @@ brw_is_format_supported( struct pipe_screen *screen,
#if 0
/* XXX: This is broken -- rewrite if still needed. */
static const unsigned tex_supported[] = {
- PIPE_FORMAT_U_R8_G8_B8_A8,
- PIPE_FORMAT_U_A8_R8_G8_B8,
- PIPE_FORMAT_U_R5_G6_B5,
- PIPE_FORMAT_U_L8,
- PIPE_FORMAT_U_A8,
- PIPE_FORMAT_U_I8,
- PIPE_FORMAT_U_L8_A8,
+ PIPE_FORMAT_R8G8B8A8_UNORM,
+ PIPE_FORMAT_A8R8G8B8_UNORM,
+ PIPE_FORMAT_R5G6B5_UNORM,
+ PIPE_FORMAT_L8_UNORM,
+ PIPE_FORMAT_A8_UNORM,
+ PIPE_FORMAT_I8_UNORM,
+ PIPE_FORMAT_L8A8_UNORM,
PIPE_FORMAT_YCBCR,
PIPE_FORMAT_YCBCR_REV,
PIPE_FORMAT_S8_Z24,
@@ -157,16 +157,16 @@ brw_is_format_supported( struct pipe_screen *screen,
/* Actually a lot more than this - add later:
*/
static const unsigned render_supported[] = {
- PIPE_FORMAT_U_A8_R8_G8_B8,
- PIPE_FORMAT_U_R5_G6_B5,
+ PIPE_FORMAT_A8R8G8B8_UNORM,
+ PIPE_FORMAT_R5G6B5_UNORM,
};
/*
*/
static const unsigned z_stencil_supported[] = {
- PIPE_FORMAT_U_Z16,
- PIPE_FORMAT_U_Z32,
- PIPE_FORMAT_S8_Z24,
+ PIPE_FORMAT_Z16_UNORM,
+ PIPE_FORMAT_Z32_UNORM,
+ PIPE_FORMAT_S8Z24_UNORM,
};
switch (type) {
diff --git a/src/gallium/drivers/i965simple/brw_wm_surface_state.c b/src/gallium/drivers/i965simple/brw_wm_surface_state.c
index 853c743ccf4..69e56dc8bd3 100644
--- a/src/gallium/drivers/i965simple/brw_wm_surface_state.c
+++ b/src/gallium/drivers/i965simple/brw_wm_surface_state.c
@@ -57,16 +57,16 @@ static unsigned translate_tex_target( enum pipe_texture_target target )
static unsigned translate_tex_format( enum pipe_format pipe_format )
{
switch( pipe_format ) {
- case PIPE_FORMAT_U_L8:
+ case PIPE_FORMAT_L8_UNORM:
return BRW_SURFACEFORMAT_L8_UNORM;
- case PIPE_FORMAT_U_I8:
+ case PIPE_FORMAT_I8_UNORM:
return BRW_SURFACEFORMAT_I8_UNORM;
- case PIPE_FORMAT_U_A8:
+ case PIPE_FORMAT_A8_UNORM:
return BRW_SURFACEFORMAT_A8_UNORM;
- case PIPE_FORMAT_U_A8_L8:
+ case PIPE_FORMAT_A8L8_UNORM:
return BRW_SURFACEFORMAT_L8A8_UNORM;
case PIPE_FORMAT_R8G8B8_UNORM:
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index edf91ecafa3..fe9cd8375e3 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -122,7 +122,7 @@ static void softpipe_destroy( struct pipe_context *pipe )
struct pipe_context *
softpipe_create( struct pipe_screen *screen,
struct pipe_winsys *pipe_winsys,
- struct softpipe_winsys *softpipe_winsys )
+ void *unused )
{
struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
uint i;
@@ -212,8 +212,6 @@ softpipe_create( struct pipe_screen *screen,
softpipe->quad.colormask = sp_quad_colormask_stage(softpipe);
softpipe->quad.output = sp_quad_output_stage(softpipe);
- softpipe->winsys = softpipe_winsys;
-
/*
* Create drawing context and plug our rendering stage into it.
*/
diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h
index b3e2b2e4355..62eabfb30e8 100644
--- a/src/gallium/drivers/softpipe/sp_context.h
+++ b/src/gallium/drivers/softpipe/sp_context.h
@@ -57,8 +57,6 @@ struct sp_vertex_shader;
struct softpipe_context {
struct pipe_context pipe; /**< base class */
- struct softpipe_winsys *winsys; /**< window system interface */
-
/* The most recent drawing state as set by the driver:
*/
diff --git a/src/gallium/drivers/softpipe/sp_prim_setup.c b/src/gallium/drivers/softpipe/sp_prim_setup.c
index feb35d492a3..1cf9ffa632f 100644
--- a/src/gallium/drivers/softpipe/sp_prim_setup.c
+++ b/src/gallium/drivers/softpipe/sp_prim_setup.c
@@ -150,6 +150,8 @@ static void reset_stipple_counter( struct draw_stage *stage )
static void render_destroy( struct draw_stage *stage )
{
+ struct setup_stage *ssetup = setup_stage(stage);
+ setup_destroy_context(ssetup->setup);
FREE( stage );
}
diff --git a/src/gallium/drivers/softpipe/sp_quad_stencil.c b/src/gallium/drivers/softpipe/sp_quad_stencil.c
index 92a0da00833..b4c7e942fa5 100644
--- a/src/gallium/drivers/softpipe/sp_quad_stencil.c
+++ b/src/gallium/drivers/softpipe/sp_quad_stencil.c
@@ -243,7 +243,7 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
stencilVals[j] = tile->data.depth32[y][x] & 0xff;
}
break;
- case PIPE_FORMAT_U_S8:
+ 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);
@@ -311,7 +311,7 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
tile->data.depth32[y][x] = z24s8;
}
break;
- case PIPE_FORMAT_U_S8:
+ 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);
diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c
index 2921066ce36..9e77b7e91bc 100644
--- a/src/gallium/drivers/softpipe/sp_state_fs.c
+++ b/src/gallium/drivers/softpipe/sp_state_fs.c
@@ -82,10 +82,9 @@ softpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
void
softpipe_delete_fs_state(struct pipe_context *pipe, void *fs)
{
- struct softpipe_context *softpipe = softpipe_context(pipe);
struct sp_fragment_shader *state = fs;
- assert(fs != softpipe->fs);
+ assert(fs != softpipe_context(pipe)->fs);
state->delete( state );
}
diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c
index 5b63f979977..be0b57d9fa6 100644
--- a/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -1051,5 +1051,19 @@ sp_get_samples(struct tgsi_sampler *sampler,
default:
assert(0);
}
+
+#if 0 /* DEBUG */
+ {
+ int i;
+ printf("Sampled at %f, %f, %f:\n", s[0], t[0], p[0]);
+ for (i = 0; i < 4; i++) {
+ printf("Frag %d: %f %f %f %f\n", i,
+ rgba[0][i],
+ rgba[1][i],
+ rgba[2][i],
+ rgba[3][i]);
+ }
+ }
+#endif
}
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c
index edafd93d8b8..1117c0ad4c7 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
@@ -131,7 +131,7 @@ sp_destroy_tile_cache(struct softpipe_tile_cache *tc)
uint pos;
for (pos = 0; pos < NUM_ENTRIES; pos++) {
- //assert(tc->entries[pos].x < 0);
+ /*assert(tc->entries[pos].x < 0);*/
}
if (tc->surface) {
pipe_surface_reference(&tc->surface, NULL);
@@ -168,7 +168,7 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
tc->depth_stencil = (ps->format == PIPE_FORMAT_S8Z24_UNORM ||
ps->format == PIPE_FORMAT_Z16_UNORM ||
ps->format == PIPE_FORMAT_Z32_UNORM ||
- ps->format == PIPE_FORMAT_U_S8);
+ ps->format == PIPE_FORMAT_S8_UNORM);
}
}
@@ -332,8 +332,8 @@ sp_tile_cache_flush_clear(struct pipe_context *pipe,
for (x = 0; x < w; x += TILE_SIZE) {
if (is_clear_flag_set(tc->clear_flags, x, y)) {
pipe_put_tile_raw(pipe, ps,
- x, y, TILE_SIZE, TILE_SIZE,
- tc->tile.data.color32, 0/*STRIDE*/);
+ x, y, TILE_SIZE, TILE_SIZE,
+ tc->tile.data.color32, 0/*STRIDE*/);
/* do this? */
clear_clear_flag(tc->clear_flags, x, y);
@@ -367,8 +367,8 @@ sp_flush_tile_cache(struct softpipe_context *softpipe,
if (tile->x >= 0) {
if (tc->depth_stencil) {
pipe_put_tile_raw(pipe, ps,
- tile->x, tile->y, TILE_SIZE, TILE_SIZE,
- tile->data.depth32, 0/*STRIDE*/);
+ tile->x, tile->y, TILE_SIZE, TILE_SIZE,
+ tile->data.depth32, 0/*STRIDE*/);
}
else {
pipe_put_tile_rgba(pipe, ps,
@@ -385,7 +385,7 @@ sp_flush_tile_cache(struct softpipe_context *softpipe,
#endif
}
else if (tc->texture) {
- /* caching a texture, mark all entries as embpy */
+ /* caching a texture, mark all entries as empty */
for (pos = 0; pos < NUM_ENTRIES; pos++) {
tc->entries[pos].x = -1;
}
diff --git a/src/gallium/drivers/softpipe/sp_winsys.h b/src/gallium/drivers/softpipe/sp_winsys.h
index 291825dfe22..4ab666486c4 100644
--- a/src/gallium/drivers/softpipe/sp_winsys.h
+++ b/src/gallium/drivers/softpipe/sp_winsys.h
@@ -59,7 +59,7 @@ struct pipe_context;
struct pipe_context *softpipe_create( struct pipe_screen *,
struct pipe_winsys *,
- struct softpipe_winsys * );
+ void *unused );
struct pipe_screen *
diff --git a/src/gallium/include/pipe/p_config.h b/src/gallium/include/pipe/p_config.h
index e44fafeae9f..5c030bdfff3 100644
--- a/src/gallium/include/pipe/p_config.h
+++ b/src/gallium/include/pipe/p_config.h
@@ -106,7 +106,16 @@
#if defined(PIPE_SUBSYSTEM_KERNEL)
#define PIPE_SUBSYSTEM_WINDOWS_DISPLAY
#endif
+#if 0 /* FIXME */
+#define PIPE_SUBSYSTEM_WINDOWS_MINIPORT
+#endif
+#if 0 /* FIXME */
+#define PIPE_SUBSYSTEM_WINDOWS_CE
+#endif
+#if defined(PIPE_SUBSYSTEM_USER)
+#define PIPE_SUBSYSTEM_WINDOWS_USER
#endif
+#endif /* PIPE_OS_WINDOWS */
#endif /* P_CONFIG_H_ */
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 586951d9566..46a355daa21 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -192,7 +192,7 @@ enum pipe_texture_target {
#define PIPE_BUFFER_USAGE_VERTEX (1 << 5)
#define PIPE_BUFFER_USAGE_INDEX (1 << 6)
#define PIPE_BUFFER_USAGE_CONSTANT (1 << 7)
-/** Pipe driver custam usage flags should be greater or equal to this value */
+/** Pipe driver custom usage flags should be greater or equal to this value */
#define PIPE_BUFFER_USAGE_CUSTOM (1 << 16)
@@ -268,7 +268,7 @@ enum pipe_texture_target {
#define PIPE_CAP_MAX_POINT_WIDTH_AA 17
#define PIPE_CAP_MAX_TEXTURE_ANISOTROPY 18
#define PIPE_CAP_MAX_TEXTURE_LOD_BIAS 19
-#define PIPE_CAP_BITMAP_TEXCOORD_BIAS 20
+
#ifdef __cplusplus
}
diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h
index bc23fe142ea..e32212d36c3 100644
--- a/src/gallium/include/pipe/p_format.h
+++ b/src/gallium/include/pipe/p_format.h
@@ -238,10 +238,10 @@ enum pipe_format {
PIPE_FORMAT_A1R5G5B5_UNORM = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_ARGB, 1, 5, 5, 5, PIPE_FORMAT_TYPE_UNORM ),
PIPE_FORMAT_A4R4G4B4_UNORM = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_ARGB, 4, 4, 4, 4, PIPE_FORMAT_TYPE_UNORM ),
PIPE_FORMAT_R5G6B5_UNORM = _PIPE_FORMAT_RGBAZS_1 ( _PIPE_FORMAT_RGB1, 5, 6, 5, 0, PIPE_FORMAT_TYPE_UNORM ),
- PIPE_FORMAT_U_L8 = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRR1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte luminance */
- PIPE_FORMAT_U_A8 = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_000R, 0, 0, 0, 1, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte alpha */
- PIPE_FORMAT_U_I8 = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRRR, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte intensity */
- PIPE_FORMAT_U_A8_L8 = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRRG, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte alpha, luminance */
+ PIPE_FORMAT_L8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRR1, 1, 1, 1, 0, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte luminance */
+ PIPE_FORMAT_A8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_000R, 0, 0, 0, 1, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte alpha */
+ PIPE_FORMAT_I8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRRR, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte intensity */
+ PIPE_FORMAT_A8L8_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_RRRG, 1, 1, 1, 1, PIPE_FORMAT_TYPE_UNORM ), /**< ubyte alpha, luminance */
PIPE_FORMAT_YCBCR = _PIPE_FORMAT_YCBCR( 0 ),
PIPE_FORMAT_YCBCR_REV = _PIPE_FORMAT_YCBCR( 1 ),
PIPE_FORMAT_Z16_UNORM = _PIPE_FORMAT_RGBAZS_8 ( _PIPE_FORMAT_Z000, 2, 0, 0, 0, PIPE_FORMAT_TYPE_UNORM ),
@@ -327,11 +327,12 @@ enum pipe_format {
};
-/**
- * Unsigned 8-bit stencil format.
- * XXX should remove this, but S8_UNORM is a poor name
- */
-#define PIPE_FORMAT_U_S8 PIPE_FORMAT_S8_UNORM
+/** XXX remove these deprecated names */
+#define PIPE_FORMAT_U_L8 PIPE_FORMAT_L8_UNORM
+#define PIPE_FORMAT_U_A8 PIPE_FORMAT_A8_UNORM
+#define PIPE_FORMAT_U_I8 PIPE_FORMAT_I8_UNORM
+#define PIPE_FORMAT_U_A8_L8 PIPE_FORMAT_A8L8_UNORM
+#define PIPE_FORMAT_U_S8 PIPE_FORMAT_S8_UNORM
/**
diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/include/pipe/p_inlines.h
index 274f76a383f..8eb604e73f1 100644
--- a/src/gallium/include/pipe/p_inlines.h
+++ b/src/gallium/include/pipe/p_inlines.h
@@ -129,6 +129,56 @@ pipe_texture_release(struct pipe_texture **ptr)
}
+/**
+ * Convenience wrappers for winsys buffer functions.
+ */
+
+static INLINE struct pipe_buffer *
+pipe_buffer_create( struct pipe_context *pipe,
+ unsigned alignment, unsigned usage, unsigned size )
+{
+ return pipe->winsys->buffer_create(pipe->winsys, alignment, usage, size);
+}
+
+static INLINE struct pipe_buffer *
+pipe_user_buffer_create( struct pipe_context *pipe, void *ptr, unsigned size )
+{
+ return pipe->winsys->user_buffer_create(pipe->winsys, ptr, size);
+}
+
+static INLINE void
+pipe_buffer_destroy( struct pipe_context *pipe, struct pipe_buffer *buf )
+{
+ pipe->winsys->buffer_destroy(pipe->winsys, buf);
+}
+
+static INLINE void *
+pipe_buffer_map(struct pipe_context *pipe,
+ struct pipe_buffer *buf,
+ unsigned usage)
+{
+ return pipe->winsys->buffer_map(pipe->winsys, buf, usage);
+}
+
+static INLINE void
+pipe_buffer_unmap(struct pipe_context *pipe,
+ struct pipe_buffer *buf)
+{
+ pipe->winsys->buffer_unmap(pipe->winsys, buf);
+}
+
+/* XXX when we're using this everywhere, get rid of
+ * pipe_buffer_reference() above.
+ */
+static INLINE void
+pipe_reference_buffer(struct pipe_context *pipe,
+ struct pipe_buffer **ptr,
+ struct pipe_buffer *buf)
+{
+ pipe_buffer_reference(pipe->winsys, ptr, buf);
+}
+
+
#ifdef __cplusplus
}
#endif
diff --git a/src/gallium/include/pipe/p_util.h b/src/gallium/include/pipe/p_util.h
index 63301ae3aad..0e7e2466662 100644
--- a/src/gallium/include/pipe/p_util.h
+++ b/src/gallium/include/pipe/p_util.h
@@ -41,7 +41,9 @@ extern "C" {
#endif
-#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && defined(DEBUG) /* memory debugging */
+#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY) && defined(DEBUG)
+
+/* memory debugging */
#include "p_debug.h"
@@ -54,9 +56,7 @@ extern "C" {
#define REALLOC( _ptr, _old_size, _size ) \
debug_realloc( __FILE__, __LINE__, __FUNCTION__, _ptr, _old_size, _size )
-#else
-
-#if defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_DISPLAY)
void * __stdcall
EngAllocMem(
@@ -68,17 +68,33 @@ void __stdcall
EngFreeMem(
void *Mem );
-static INLINE void *
-MALLOC( unsigned size )
-{
-#ifdef WINCE
- /* TODO: Need to abstract this */
- return malloc( size );
+#define MALLOC( _size ) EngAllocMem( 0, _size, 'D3AG' )
+#define _FREE( _ptr ) EngFreeMem( _ptr )
+
+#elif defined(PIPE_SUBSYSTEM_WINDOWS_MINIPORT)
+
+void *
+ExAllocatePool(
+ unsigned long PoolType,
+ size_t NumberOfBytes);
+
+void
+ExFreePool(void *P);
+
+#define MALLOC(_size) ExAllocatePool(0, _size)
+#define _FREE(_ptr) ExFreePool(_ptr)
+
#else
- return EngAllocMem( 0, size, 'D3AG' );
+
+#define MALLOC( SIZE ) malloc( SIZE )
+#define CALLOC( COUNT, SIZE ) calloc( COUNT, SIZE )
+#define FREE( PTR ) free( PTR )
+#define REALLOC( OLDPTR, OLDSIZE, NEWSIZE ) realloc( OLDPTR, NEWSIZE )
+
#endif
-}
+
+#ifndef CALLOC
static INLINE void *
CALLOC( unsigned count, unsigned size )
{
@@ -88,20 +104,19 @@ CALLOC( unsigned count, unsigned size )
}
return ptr;
}
+#endif /* !CALLOC */
+#ifndef FREE
static INLINE void
FREE( void *ptr )
{
if( ptr ) {
-#ifdef WINCE
- /* TODO: Need to abstract this */
- free( ptr );
-#else
- EngFreeMem( ptr );
-#endif
+ _FREE( ptr );
}
}
+#endif /* !FREE */
+#ifndef REALLOC
static INLINE void *
REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
{
@@ -118,19 +133,8 @@ REALLOC( void *old_ptr, unsigned old_size, unsigned new_size )
FREE( old_ptr );
return new_ptr;
}
+#endif /* !REALLOC */
-#else /* !PIPE_SUBSYSTEM_WINDOWS_DISPLAY */
-
-#define MALLOC( SIZE ) malloc( SIZE )
-
-#define CALLOC( COUNT, SIZE ) calloc( COUNT, SIZE )
-
-#define FREE( PTR ) free( PTR )
-
-#define REALLOC( OLDPTR, OLDSIZE, NEWSIZE ) realloc( OLDPTR, NEWSIZE )
-
-#endif /* !PIPE_SUBSYSTEM_WINDOWS_DISPLAY */
-#endif /* !DEBUG */
#define MALLOC_STRUCT(T) (struct T *) MALLOC(sizeof(struct T))
diff --git a/src/gallium/winsys/xlib/xm_winsys.c b/src/gallium/winsys/xlib/xm_winsys.c
index 8a89278cde6..14c3892559b 100644
--- a/src/gallium/winsys/xlib/xm_winsys.c
+++ b/src/gallium/winsys/xlib/xm_winsys.c
@@ -37,6 +37,7 @@
#include "xmesaP.h"
#undef ASSERT
+#undef Elements
#include "pipe/p_winsys.h"
#include "pipe/p_format.h"
@@ -57,6 +58,7 @@
/**
+ * Subclass of pipe_buffer for Xlib winsys.
* Low-level OS/window system memory buffer
*/
struct xm_buffer
@@ -73,12 +75,10 @@ struct xm_buffer
#endif
};
-#if defined(USE_XSHM) && !defined(XFree86Server)
-# define XSHM_ENABLED(b) ((b)->shm)
-#else
-# define XSHM_ENABLED(b) 0
-#endif
+/**
+ * Subclass of pipe_surface for Xlib winsys
+ */
struct xmesa_surface
{
struct pipe_surface surface;
@@ -89,17 +89,8 @@ struct xmesa_surface
/**
- * Derived from softpipe_winsys.
- * We just need one extra field which indicates the pixel format to use for
- * drawing surfaces so that we're compatible with the XVisual/window format.
+ * Subclass of pipe_winsys for Xlib winsys
*/
-struct xmesa_softpipe_winsys
-{
- struct softpipe_winsys spws;
- enum pipe_format pixelformat;
-};
-
-
struct xmesa_pipe_winsys
{
struct pipe_winsys base;
@@ -108,35 +99,147 @@ struct xmesa_pipe_winsys
};
-static void alloc_shm_ximage(struct xm_buffer *b, struct xmesa_buffer *xmb,
- unsigned width, unsigned height);
/** Cast wrapper */
static INLINE struct xmesa_surface *
xmesa_surface(struct pipe_surface *ps)
{
-// assert(0);
return (struct xmesa_surface *) ps;
}
-/** cast wrapper */
-static INLINE struct xmesa_softpipe_winsys *
-xmesa_softpipe_winsys(struct softpipe_winsys *spws)
+
+/** Cast wrapper */
+static INLINE struct xm_buffer *
+xm_buffer( struct pipe_buffer *buf )
{
- return (struct xmesa_softpipe_winsys *) spws;
+ return (struct xm_buffer *)buf;
}
+
/**
- * Turn the softpipe opaque buffer pointer into a dri_bufmgr opaque
- * buffer pointer...
+ * X Shared Memory Image extension code
*/
-static INLINE struct xm_buffer *
-xm_buffer( struct pipe_buffer *buf )
+#if defined(USE_XSHM) && !defined(XFree86Server)
+
+#define XSHM_ENABLED(b) ((b)->shm)
+
+static volatile int mesaXErrorFlag = 0;
+
+/**
+ * Catches potential Xlib errors.
+ */
+static int
+mesaHandleXError(XMesaDisplay *dpy, XErrorEvent *event)
{
- return (struct xm_buffer *)buf;
+ (void) dpy;
+ (void) event;
+ mesaXErrorFlag = 1;
+ return 0;
}
+static GLboolean alloc_shm(struct xm_buffer *buf, unsigned size)
+{
+ XShmSegmentInfo *const shminfo = & buf->shminfo;
+
+ shminfo->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777);
+ if (shminfo->shmid < 0) {
+ return GL_FALSE;
+ }
+
+ shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0);
+ if (shminfo->shmaddr == (char *) -1) {
+ shmctl(shminfo->shmid, IPC_RMID, 0);
+ return GL_FALSE;
+ }
+
+ shminfo->readOnly = False;
+ return GL_TRUE;
+}
+
+
+/**
+ * Allocate a shared memory XImage back buffer for the given XMesaBuffer.
+ */
+static void
+alloc_shm_ximage(struct xm_buffer *b, struct xmesa_buffer *xmb,
+ unsigned width, unsigned height)
+{
+ /*
+ * We have to do a _lot_ of error checking here to be sure we can
+ * really use the XSHM extension. It seems different servers trigger
+ * errors at different points if the extension won't work. Therefore
+ * we have to be very careful...
+ */
+#if 0
+ GC gc;
+#endif
+ int (*old_handler)(XMesaDisplay *, XErrorEvent *);
+
+ b->tempImage = XShmCreateImage(xmb->xm_visual->display,
+ xmb->xm_visual->visinfo->visual,
+ xmb->xm_visual->visinfo->depth,
+ ZPixmap,
+ NULL,
+ &b->shminfo,
+ width, height);
+ if (b->tempImage == NULL) {
+ b->shm = 0;
+ return;
+ }
+
+
+ mesaXErrorFlag = 0;
+ old_handler = XSetErrorHandler(mesaHandleXError);
+ /* This may trigger the X protocol error we're ready to catch: */
+ XShmAttach(xmb->xm_visual->display, &b->shminfo);
+ XSync(xmb->xm_visual->display, False);
+
+ if (mesaXErrorFlag) {
+ /* we are on a remote display, this error is normal, don't print it */
+ XFlush(xmb->xm_visual->display);
+ mesaXErrorFlag = 0;
+ XDestroyImage(b->tempImage);
+ b->tempImage = NULL;
+ b->shm = 0;
+ (void) XSetErrorHandler(old_handler);
+ return;
+ }
+
+
+ /* Finally, try an XShmPutImage to be really sure the extension works */
+#if 0
+ gc = XCreateGC(xmb->xm_visual->display, xmb->drawable, 0, NULL);
+ XShmPutImage(xmb->xm_visual->display, xmb->drawable, gc,
+ b->tempImage, 0, 0, 0, 0, 1, 1 /*one pixel*/, False);
+ XSync(xmb->xm_visual->display, False);
+ XFreeGC(xmb->xm_visual->display, gc);
+ (void) XSetErrorHandler(old_handler);
+ if (mesaXErrorFlag) {
+ XFlush(xmb->xm_visual->display);
+ mesaXErrorFlag = 0;
+ XDestroyImage(b->tempImage);
+ b->tempImage = NULL;
+ b->shm = 0;
+ return;
+ }
+#endif
+}
+
+#else
+
+#define XSHM_ENABLED(b) 0
+
+static void
+alloc_shm_ximage(struct xm_buffer *b, struct xmesa_buffer *xmb,
+ unsigned width, unsigned height)
+{
+ b->shm = 0;
+}
+#endif /* USE_XSHM */
+
+
+
/* Most callbacks map direcly onto dri_bufmgr operations:
*/
@@ -313,119 +416,6 @@ xm_get_name(struct pipe_winsys *pws)
}
-#if defined(USE_XSHM) && !defined(XFree86Server)
-static volatile int mesaXErrorFlag = 0;
-
-/**
- * Catches potential Xlib errors.
- */
-static int
-mesaHandleXError(XMesaDisplay *dpy, XErrorEvent *event)
-{
- (void) dpy;
- (void) event;
- mesaXErrorFlag = 1;
- return 0;
-}
-
-
-static GLboolean alloc_shm(struct xm_buffer *buf, unsigned size)
-{
- XShmSegmentInfo *const shminfo = & buf->shminfo;
-
- shminfo->shmid = shmget(IPC_PRIVATE, size, IPC_CREAT|0777);
- if (shminfo->shmid < 0) {
- return GL_FALSE;
- }
-
- shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0);
- if (shminfo->shmaddr == (char *) -1) {
- shmctl(shminfo->shmid, IPC_RMID, 0);
- return GL_FALSE;
- }
-
- shminfo->readOnly = False;
- return GL_TRUE;
-}
-
-
-/**
- * Allocate a shared memory XImage back buffer for the given XMesaBuffer.
- */
-static void
-alloc_shm_ximage(struct xm_buffer *b, struct xmesa_buffer *xmb,
- unsigned width, unsigned height)
-{
- /*
- * We have to do a _lot_ of error checking here to be sure we can
- * really use the XSHM extension. It seems different servers trigger
- * errors at different points if the extension won't work. Therefore
- * we have to be very careful...
- */
-#if 0
- GC gc;
-#endif
- int (*old_handler)(XMesaDisplay *, XErrorEvent *);
-
- b->tempImage = XShmCreateImage(xmb->xm_visual->display,
- xmb->xm_visual->visinfo->visual,
- xmb->xm_visual->visinfo->depth,
- ZPixmap,
- NULL,
- &b->shminfo,
- width, height);
- if (b->tempImage == NULL) {
- b->shm = 0;
- return;
- }
-
-
- mesaXErrorFlag = 0;
- old_handler = XSetErrorHandler(mesaHandleXError);
- /* This may trigger the X protocol error we're ready to catch: */
- XShmAttach(xmb->xm_visual->display, &b->shminfo);
- XSync(xmb->xm_visual->display, False);
-
- if (mesaXErrorFlag) {
- /* we are on a remote display, this error is normal, don't print it */
- XFlush(xmb->xm_visual->display);
- mesaXErrorFlag = 0;
- XDestroyImage(b->tempImage);
- b->tempImage = NULL;
- b->shm = 0;
- (void) XSetErrorHandler(old_handler);
- return;
- }
-
-
- /* Finally, try an XShmPutImage to be really sure the extension works */
-#if 0
- gc = XCreateGC(xmb->xm_visual->display, xmb->drawable, 0, NULL);
- XShmPutImage(xmb->xm_visual->display, xmb->drawable, gc,
- b->tempImage, 0, 0, 0, 0, 1, 1 /*one pixel*/, False);
- XSync(xmb->xm_visual->display, False);
- XFreeGC(xmb->xm_visual->display, gc);
- (void) XSetErrorHandler(old_handler);
- if (mesaXErrorFlag) {
- XFlush(xmb->xm_visual->display);
- mesaXErrorFlag = 0;
- XDestroyImage(b->tempImage);
- b->tempImage = NULL;
- b->shm = 0;
- return;
- }
-#endif
-}
-#else
-static void
-alloc_shm_ximage(struct xm_buffer *b, struct xmesa_buffer *xmb,
- unsigned width, unsigned height)
-{
- b->shm = 0;
-}
-#endif
-
-
static struct pipe_buffer *
xm_buffer_create(struct pipe_winsys *pws,
unsigned alignment,
@@ -525,8 +515,7 @@ xm_surface_alloc_storage(struct pipe_winsys *winsys,
/**
- * Called via pipe->surface_alloc() to create new surfaces (textures,
- * renderbuffers, etc.
+ * Called via winsys->surface_alloc() to create new surfaces.
*/
static struct pipe_surface *
xm_surface_alloc(struct pipe_winsys *ws)
@@ -610,10 +599,19 @@ xmesa_get_pipe_winsys_aub(struct xmesa_visual *xm_vis)
{
static struct xmesa_pipe_winsys *ws = NULL;
- if (!ws && getenv("XM_AUB")) {
+ if (!ws) {
ws = (struct xmesa_pipe_winsys *) xmesa_create_pipe_winsys_aub();
}
- else if (!ws) {
+ return &ws->base;
+}
+
+
+static struct pipe_winsys *
+xmesa_get_pipe_winsys(struct xmesa_visual *xm_vis)
+{
+ static struct xmesa_pipe_winsys *ws = NULL;
+
+ if (!ws) {
ws = CALLOC_STRUCT(xmesa_pipe_winsys);
ws->xm_visual = xm_vis;
@@ -644,45 +642,19 @@ xmesa_get_pipe_winsys_aub(struct xmesa_visual *xm_vis)
}
-/**
- * Called via softpipe_winsys->is_format_supported().
- * This function is only called to test formats for front/back color surfaces.
- * The winsys being queried will have been created at glXCreateContext
- * time, with a pixel format corresponding to the context's visual.
- */
-static boolean
-xmesa_is_format_supported(struct softpipe_winsys *sws,
- enum pipe_format format)
-{
- struct xmesa_softpipe_winsys *xmws = xmesa_softpipe_winsys(sws);
- return (format == xmws->pixelformat);
-}
-
-
-/**
- * Return pointer to a softpipe_winsys object.
- */
-static struct softpipe_winsys *
-xmesa_get_softpipe_winsys(uint pixelformat)
-{
- struct xmesa_softpipe_winsys *xmws
- = CALLOC_STRUCT(xmesa_softpipe_winsys);
- if (!xmws)
- return NULL;
-
- xmws->spws.is_format_supported = xmesa_is_format_supported;
- xmws->pixelformat = pixelformat;
-
- return &xmws->spws;
-}
-
-
struct pipe_context *
xmesa_create_pipe_context(XMesaContext xmesa, uint pixelformat)
{
- struct pipe_winsys *pws = xmesa_get_pipe_winsys_aub(xmesa->xm_visual);
+ struct pipe_winsys *pws;
struct pipe_context *pipe;
+ if (getenv("XM_AUB")) {
+ pws = xmesa_get_pipe_winsys_aub(xmesa->xm_visual);
+ }
+ else {
+ pws = xmesa_get_pipe_winsys(xmesa->xm_visual);
+ }
+
#ifdef GALLIUM_CELL
if (!getenv("GALLIUM_NOCELL")) {
struct cell_winsys *cws = cell_get_winsys(pixelformat);
@@ -693,10 +665,9 @@ xmesa_create_pipe_context(XMesaContext xmesa, uint pixelformat)
else
#endif
{
- struct softpipe_winsys *spws = xmesa_get_softpipe_winsys(pixelformat);
struct pipe_screen *screen = softpipe_create_screen(pws);
- pipe = softpipe_create(screen, pws, spws);
+ pipe = softpipe_create(screen, pws, NULL);
}
if (pipe)